GDB is the GNU Debugger. You can run it from the command line, or preferrably, from within Emacs. You can find details about using it from the command line here.
Here's the fastest way to get started:
M-x gdbYou'll be prompted for the name of an executable. You should now have "windows," one for your gdb interaction, and the other showing your source file.
Set a breakpoint by going to the source line of the program you're debugging, and typing:
C-x [space](That's the space bar.) GDB will tell you that you've just set a breakpoint.
You can also break on function entry by typing "b functionName." Typing "d 1" deletes breakpoint 1. Typing "disable 1" disables breakpoint 1. You can enable this breakpoint again by typing "enable 1". You can delete all breakpoints by typing "d."
print aprints out the value of variable a, assuming a is valid in the current scope.
p (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).
You can also set conditional breakpoints aand watchpoints. Try "help breakpoints" for more info.
This is by no means a complete listing, but it's what you'll use most of the time.
Orignal version by email@example.com Modified by firstname.lastname@example.org, Autumn 1997.