The following is a collection of bindings and tips for GDB. I highly recommend installing gef for the best experience
Tips
- Set memory on stack with
set {int}<addr> = <val>
Without debug flags
r
: runc
: continue from break pointsi
: step instructionuntil [location]
: run until next instruction or locationfinish
: run until stack frame [function] returnsjump *<address>
: resume execution at addressset var=<expr>
: evaluateexpr
and set itp [/f] [expr]
: show value ofexpr
x
: hexd
: signed decimalu
: unsigned decimalo
: octalt
: binarya
: addressc
: characterf
: floating point
x [/Nuf] [expr]
: examine memory at locationN
: count of units to displayu
: unit sizeb
: bytesh
: half words (two bytes)w
: word (four bytes)g
: giant word (eight bytes)
f
: printing format, anyprint
format ors
: null terminated stringi
: machine instructions
d
: Print on each stepdisas [addr]
: display memory as machine instructionsdisas *main
to show main function
s
: execute next instruction
With debug flags
n
: continue until next line is rechedjump <line>
: resume execution atline
list
to print lines around breakpoint