GDB Info (original) (raw)
Breakpoints:
Setting and removing single breakpoints:
break (
some function)
break (
line number)
break *(
some memory address)
delete (
breakpoint number)
Removing all breakpoints:
clear
[clears current break point]clear (
some function)
clear (
some line number)
clear *(
some memory address)
Running:
run
arg1 arg2 ... starts or restarts the program with the given argumentsrun
starts or restarts the program at full speed. If restarting, uses the same arguments used last time.s
orstep
steps by one line of source code, going into function calls. This only works after the program is running, so you usually need to set a breakpoint somewhere so that you can get to where you want to start stepping.n
ornext
steps by one line of source code, not going into function callsstepi
steps by one instruction, going into function callsnexti
steps by one instruction, not going into function callsc
orcontinue
goes at full speed after a breakpointkill
end the running programenter
do the same command again.finish
step out of the current function.
Stack:
bt
orbacktrace
shows the current stack.frame
N goes to the _N_th stack frame.info locals
prints all local variables.info args
prints all of the arguments to the current function as they are now (as opposed to as they were at the top of the function).call
function calls function. Arguments can be provided. Note: this works by pushing arguments on the stack, resetting%eip
to point the the function, and letting the program run. In some circumstances, this can failwhatis
something prints the type of_something_
Command Line:
set args (
stuff)
passes_stuff_ as command line arguments to the program the next timerun
is used.file
stuff sets stuff as the program to be run and debugged.
Lazy Typing:
- Enter (the key) at an empty command prompt repeats the last command. This is especially handy for
step
andnext
commands - Ambigious abreviations will resolve to the last command with that abbreviation
Lazy Math:
print/d 0x
some hex number will convert it to decimalprint/x
some decimal number will convert it to hexprint
complicated expression will evaluate the expression and print the result in decimal or hex. You can use standard C notation, variables of your program, and register names ($eax
, etc.)
Useful Tricks:
info b
will tell you how many times a breakpoint has been hit.continue
n (orc
n) will continue past a breakpoint n times. For example, if the fourth call to a function is the one that fails, you can use "c 3
" to skip the first three calls.- You can combine the two above tricks to deal with a function that crashes after many calls. Set a breakpoint in the function, run the program, and type "
c 9999999
". When it crashes, useinfo b
to find out how many times the function was called. Then rerun the program and usecontinue
n-1 to get to the invocation that crashes.
© 2007, Geoff Kuenning
This page is maintained by Geoff Kuenning.