I have written a simple C++ program like this:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello.";
return 0;
}
Now I want to debug it. So what will be the command for it so my control goes to every line?
I have written a simple C++ program like this:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello.";
return 0;
}
Now I want to debug it. So what will be the command for it so my control goes to every line?
You can use gdb for this:
$ gdb hello
This will start gdb and prompt you for what to do next. The next command executes one line of source and stops at the next line.
I found a basic GDB tutorial that may be helpful.
Don't forget to compile your source code using -g option.
Like this: g++ -g helloWorld.cc
This is going to create an a.out executable file.
You'll be able to debug your a.out exe using gdb ./a.out command.
Another tool you may use it's ddd basically a GUI for gdb.
Good luck
I always thought emacs provided a pretty user-friendly front-end to gdb...
E.g.
(That should suffice to get you started. Emacs being emacs, there are always more features...)
g++ -Wall -Wextra hello.cc -g -o hello because compiler warnings are really helpful.In the C++ Programming course I did in Sweden there was a part of the laboratory about the GNU Debugger. I never used it after, but here there is a paper explaining the basic usage, as far as I remember is in chapter 2.