[The most useful cheat sheets are those with the second-rate commands
you don't use all the time!] Some keywords have explicit abbreviations (e.g.
backtrace → bt), but one can also make use of
implicit abbreviations (cut-offs) (e.g. backtrace →
ba) and substitutions (e.g. off →
0).
- Break on syscall:
b openat(breakpoint on libc function)
catch syscall openat(actual syscall) - Break on C++ exception:
catch throw - Backtrace everything:
thread apply all bt - Produce backtrace from command-line:
gdb -p 12345 -ex 'thread apply all bt' -ex quit >xyz.txt
gdb /usr/bin/prog core.file -ex 'thread apply all bt' -ex quit >xyz.txt
- Figure out thread number from PID:
thread find 12345 - Show register file:
info registers,info all-registers - Show loaded libraries etc.:
info proc mappings - Print C++ object vtable (of size N entires) in gdb:
p/a (*(void ***)this)[0]@N - Dump memory region to file (start–end, not start+length):
dump binary memory output.bin 0x50000 0x60000 - Disable notifications about petty signals:
handle SIGTSTP nostop noprint - Disable paging/page infinitely:
set pagination off
set height 0 - Disable wrapping:
set width 0 - Disable colors:
set styling enable off - Disable smart view of objects:
disable pretty-printer