Skip to main site navigation
Skip to main content
Switch to text-only view
Switch to default view

COMPUTER AND INFORMATION SCIENCES

Thumbdrive in Computer
Linux C++ Debug

We have the gdb debugger installed, as well as Eclipse, which is an integrated IDE with a GUI similar to VisualStudio and contains a debugger.

gdb is the GNU debugger and can be run directly from the command line (terminal).

 1.  Compile your program with debug information, and give it a name. -g is the option that allows the program to run in a debugger.
 g++ -g -o filename filename.cc
 2.  Start debugging program. Include execution name of program on command line.
   gdb filename
 3.  Use break line number or break function name to add a break point.
 4.  Type run to start running the program.
5.  Type clear to erase the breakpoint on the current line when the program stops at a break point.
 6.  Type bt to see the backtrack of function calls when the execution stops at a break point.
 7.  Type print expression to see the value of a variable or expression.
 8.  Type step to execute one line of code or cont to continue the execution of the program until the next break point.
9.  Type stop to stop the execution of the program or quit to exit gdb altogether.

 Return to Computer Laboratory Page