Skip to content

Instantly share code, notes, and snippets.

@pmauduit
Last active November 7, 2020 10:07
Show Gist options
  • Select an option

  • Save pmauduit/4287311784454de5d484 to your computer and use it in GitHub Desktop.

Select an option

Save pmauduit/4287311784454de5d484 to your computer and use it in GitHub Desktop.
My gdb cheat sheet
List breakpoints:
i b
Show register state:
i r
Change / relocate sources:
set substitute-path /path/to/a /another/to/a
Conditional breakpoints:
b [place] if [expr]
b truc.c:154 if a == b
Print / inspect memory segment:
x/[length]xb [*pointer]
x/128xb map->img->raw_bytes
Run (from the begining):
r [+args]
Backtrace:
bt
Print out the memory address of a variable (prefix with &):
(gdb) p & this->map->extent.minx
$11 = (double *) 0x9210f8
Put a watchpoint (breaks if memory written) on an address:
(gdb) watch * 0x9210f8
(awatch for also tracking read)
step into:
s
step over:
n
step out:
finish
UI mode:
lay src
lay asm
lay regs
Back to console mode:
CTRL+x + a
step into / next by instruction (asm):
si / ni
Print a supposed structure:
p *((FILE *) $rax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment