Within Emacs on Unix, how can I debug a C or C++ program?
You can debug a C or C++ program using GDB,
the GNU debugger, which was developed by the same
organization that released Emacs. You can easily integrate
it with Emacs to interactively debug programs. While you can use it
from the Unix prompt, it has additional functionality when
you use it within the Emacs editor. To use GDB, first compile your
program using the -g option in cc or
gcc:
Then, to start a separate window for the debugger and load the
executable, while editing foo.c within Emacs, enter:
GDB is very similar to the dbx debugger. The
run command will run a program, and the step
command will execute a program step by step.
For more help, refer to Step-by-step example for using GDB within Emacs to debug a C or C++ program. You could also use the
help command inside of GDB to access nested information
on other commands and their syntax.
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
This document was developed with support from National Science Foundation (NSF) grant OCI-1053575. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.
Last modified on October 23, 2012.







