GDB - gnu's debugger (C/C++, and others)


Starting Running Breakpoints Data Files Stack

The BASH Shell
gcc -g files to compile w/debugging information
gdb exe_name start the debugger w/the program exe_name
gdb -c core_file load core_file into debugger
gdb exe_name core_file load exe_name and core_file into debugger (useful for stacktrace)
Running Your Program
run start the loaded program running
continue c continues until next breakpoint
next execute next source line, skipping over function calls
step execute next source line, stepping into function calls
kill halts execution of program being debugged
Breakpoints
break break at line or function
disable disables (but doesn't clear) breakpoints, listed by number (and separated by spaces)
clear [lineNr] [functionName] clears all breaks at specified line # or function
watch expr stops execution whenever expr changes
enable Cancels the disable command. Takes the same arguments
Data
print expr prints value of expr, any expression the context understands
display expr prints value of expr each time execution stops
Files
Stack
backtrace bt shows you the stack trace (most recent at top)

This collection is, by far, incomplete.  Just a quick and dirty list to get going, for budding programmers new to Unix.  If you think of something that should really be in here (or see any errors), please let me know: kschmidt@cs.drexel.edu