gdb is the official debugger in Linux. It is a flexible and capable
debugger, but it only operates in line mode. This means there is no
full screen mode, let alone a GUI mode.
In order for a program to be ``debuggable'', it needs to have extra
symbolic tags. These tags indicate which address of the executable
corresponds to which line in which file. This is why we used
the -g option when we compiled and linked the program. If you
forget to use the -g option, the executable file can still be
debugged, but you will be reading assembly language opcodes.
To debug our test program, execute the following command:
gdb test
Note that this time, there is no ./ in front of test. This
is because we are telling gdb exactly where to find an executable,
it does not implicitly search for the file in the environment variable
PATH.
In the debugger, the first command you need to learn is help. No,
I am not kidding. Type help, and gdb will give you
some top level selections. I suggest that you read the descriptions for
``breakpoints'', ``data'', ``files'', and ``running''.
For whose who want to have at least a full-screen (text mode) debugger,
there is cgdb. This one is a little bit better, as it shows the
source code being debugged in a text window. You still need to learn
the gdb commands, but at least the tracking of the execution is
more intuitive.