Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

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:

gcc -g -o foo foo.c

Then, to start a separate window for the debugger and load the executable, while editing foo.c within Emacs, enter:

M-x gdb

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.

This is document ackf in domains all and xsede-all.
Last modified on October 23, 2012.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.



Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.