GDB Cheat Sheet
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>: evaluateexprand set itp [/f] [expr]: show value ofexprx: 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, anyprintformat ors: null terminated stringi: machine instructions
d: Print on each stepdisas [addr]: display memory as machine instructionsdisas *mainto show main function
s: execute next instruction
With debug flags
n: continue until next line is rechedjump <line>: resume execution atlinelistto print lines around breakpoint