GDB
From Cppwiki
The GNU debugger (GDB) is the debugger of choice on most Unix systems (some say it's a bit flaky on Solaris and/or SPARC), as well as on Cygwin.
$HOME/.gdbinit
By default, GDB is extremely C-centric, leaving us C++ users a bit wanting. However, it turns out that it has a number of features that make it more friendly to debug C++ code, if only you turn them on. To do this, you can add options to the file .gdbinit in your $HOME directory.
elo[i]'s .gdbinit looks something like this:
set print demangle set print asm-demangle set print object set print vtbl set overload-resolution on set print array on set print null-stop set print pretty set print object on set print static-members off set history save handle SIGPIPE nostop noprint pass
How to debug a crash
- compile with the -g option to put debugging symbols into your program: g++ -g myfile.cpp -o myprog
- Start up the debugger: gdb ./myprog
- Type run to start the program.
- When it crashes, type bt (backtrace) to see the call stack.