GDB is the GNU Debugger. For more information, see the man pages or the on-line GDB documentation. Sadly, help from within gdb is difficult to navigate.
Here is a quick way to get started:
gdb programname coreThe latter will allow you to examine the coredump as if the program was running and had just faulted.
Set a breakpoint by the
break fileA.c:mainwhich places a breakpoint in the main function in fileA.c
break fileA.c:125which places a breakpoint at line 125 of fileB.c
Typing "d 1" deletes breakpoint 1. Typing "disable 1" disables breakpoint 1. You can enable this breakpoint again by typing "enable 1".
print aprints out the value of variable a, assuming a is valid in the current scope.
print (char) acasts a to a char before printing it out.
print f(123)execute any function f with arguments 123, and print its return value. This can have side effects.
x 0xfaf47print out the contents of a given memory address.
display xprint out the value of x whenever the program is stopped.
continue resumes normal execution of the program until a breakpoint is hit.
finish resumes normal execution of the program until the end of this procedure or a breakpoint is hit (which ever comes first).
This is by no means a complete listing, but it's what you'll use most of the time.
Supports emacs-like editing of command line (ctrl-a, -e, -f, -b, -d will move you around the line. ctrl-p, -n will move you through the history of previous commands, just like in tcsh).
Original by firstname.lastname@example.org. Modified by email@example.com, Autumn 1997.