Timo Dickscheid's sparse web notes.
home research programming web

Debugging and Profiling C++-Code with the standard GNU tools under Linux may not be as intuitive too many people as it is with bigger IDE's like Visual Studio, XCode or Eclipse. Although I still think that using the GNU debugger gdb and profiler gprof on the command line is feasible, there are more userfriendly choices available:

  • Nemiver is a stand-alone graphical debugger for Gnome that can use gdb as a backend. I found it intuitive, well-designed and stable. I features easy browsing of sourcecode, setting breakpoints, and especially save and resume for sessions.
  • cgdb is a curses frontend to gdb, that is, a graphical user interface on the command line. It is also intuitive, although tuned for vim-experienced users.
  • A comfortable way of profiling your code is to use the KDE call-graph viewer kcachegrind with the callgrind tool of the valgrind suite. Other than using gprof, it does not require compiling your code with special flags. It requires no more than two steps: (1) Calling your binary within the valgrind framework: valgrind --tool=callgrind [program] [arguments]. (2) Running kcachegrind on the output file kcachegrind callgrind.out.[pid]

Note that what you get with callgrind is not an exact analysis of the time your program consumed in every function and line, but rather an analysis of the cache accesses and processor instructions. This is of similar importance for many profiling purposes, but one should be aware of the differences, and read the manuals carefully for more exact usage of profilers.

On ubuntu, you get the whole setup via aptitude install valgrind-callgrind kcachegrind nemiver cgdb.