EECS 280
gdb
Command Summary
1. Compiling
To use
gdb, you will need to first compile your program using the g++ with the –g
flag.
% g++ -g
projX.cpp –o projX.exe
2. Running gdb
/ Command line options
% gdb
projX.exe
Starts gdb and loads the projX.exe
executable into the debugger.
% gdb –help
Lists all the options with a brief summary
for each
% gdb projX.exe –core=<core
file>
Starts
gdb, loads the projX.exe executable and processes core file information. Useful if your program has a segmentation
fault.
3. gdb Commands
help (h)
Brings up
the help options.
run (r)
(Re)starts
running your program. Can add command
line optionsyou’re your program here.
quit (q)
Stop
running your program and quits gdb.
break (b)
Set a
breakpoint at current position.
break <function>
Break at specified function in
current file.
break <file>:<function>
Break at function in specified file.
break <line num>
Break at line number in current
file.
break <file>:<line num>
Break at line number in specified
file.
delete
(d)
Remove lowest
breakpoint number.
delete <breakpoint num>
Delete specified breakpoint.
info breakpoints
List all the breakpoints and their numbers.
continue
(c)
Continue
executing.
next (n)
Executes
next line (does not enter functions).
until (u)
Executes
until end of current loop structure.
step (s)
Executes
next line (enters functions).
list (l)
Shows
code surrounding current line number.
list <function>
Show code at start of specified function.
list <line num>
Show code surrounding specified line
number.
print <expression>
Show value of the expression.
print <array var>@<num>
Show first num values in the specified
array.
display <expression>
Like
print, but expression is shown at every “step” through the program.
undisplay <display num>
Stop displaying the specified
display expression.
4. More
information
% man gdb
Adapted from the
GNU gdb manual page.
Last Update: D. Emerson 9/7/2002 10:36:15 AM