Using the Gnu debugger (gdb) to debug your C++ programs

Here are a few useful gdb commands. You can get even more information about g++ and gdb from the Cygnus Support web page(follow the link to the technical library).

Before trying gdb, make sure you have used both "-Wall" and "-g" in the CFLAGS variable in Makefile. Look at any warnings produced when compiling, and see if they give you any insight into the problem (as a rule, you should not ignore a warning unless I said you could or you understand why the compiler produced it and know you don't have to worry about it).

To start gdb in emacs, type M-x gdb (return) and the program name

To start gdb in an xterm, type "gdb program-name"

gdb commands:

helpful emacs keystrokes (available once gdb is running in emacs)

Return to the page of


HTML 2.0 Checked! This page maintained by davew@cs.haverford.edu