GDB Commands Reference
Command Description Example
r[un] Run to next breakpoint or to end (gdb) run
b[reak] <name> Set a breakpoint at function <name> (gdb) break main
b <class>::<name> Set a breakpoint in <class> (gdb) break MyClass::func
b <class>::<tab> List all members in <class> (gdb) break MyClass::<tab>
i[nfo] b List breakpoints (gdb) info breakpoints
dis[able] <n> Disable breakpoint <n> (gdb) disable 1
en[able] <n> Enable breakpoint <n> (gdb) enable 1
d[elete] <n> Delete breakpoint <n> (gdb) delete 1
d[elete] Delete all breakpoints (gdb) delete
cond[ition] <n> <expr> Stop at breakpoint <n> only if <expr> is true (gdb) condition 1 x > 5
cond <n> Make breakpoint <n> unconditional (gdb) condition 1
s[tep] Single-step, descending into functions (gdb) step
n[ext] Single-step without descending into functions (gdb) next
fin[ish] Finish current function, loop, etc. (gdb) finish
c[ontinue] Continue to next breakpoint or end (gdb) continue
u[ntil] <line> Run until it reaches the given line (gdb) until 42
jump <location> Set execution to a new location (gdb) jump main
p[rint] <name> Print value of variable <name> (gdb) print x
p *<name> Print what is pointed to by <name> (gdb) print *ptr
p/x <name> Print value of <name> in hex format (gdb) print/x x
p <name> @ <n> Print <n> values starting at <name> (gdb) print arr@5
p <chars><tab> List all variables starting with <chars> (gdb) print var<tab>
up Go up one context level on stack (gdb) up
do[wn] Go down one level (only possible after up) (gdb) down
l[ist] Show lines of code surrounding the current point (gdb) list
h[elp] Get help on gdb commands (gdb) help
h[elp] <cmd> Get help on a specific gdb command (gdb) help run
q[uit] Exit gdb (gdb) quit
Page 1