Setup
$ cat /proc/sys/kernel/core_pattern ... get coredumps location $ ulimit -c ... check max coredump size $ gdb <executable> <coredump> ... load coredump with GDB
Details ▼
Activate cordumps for the current session
- Set coredump size to unlimited
$ ulimit -c unlimited
- Set pattern to store coredump
$ sudo sysctl -w kernel.core_pattern=/tmp/core.%e.%p.%t
Threads & Stack
info threads ... show running threads thread apply all bt ... show the bt of all running threads thread <idx> bt ... show the bt of specific thread thread <idx> ... switch to other thread bt [<lvl's>] ... show the bt of the current thread up ... move up in bt down ... move down in bt f <idx> ... select frame <idx> info f ... shows selected frame
Functions & Variables
list [function] ... show source code disas [/<m>] [function] ... show disassembly <m> (mode) - b ... prints bytes and instruction (in memory order) - m ... prints assembly and sources (not useful with optimized code) - r ... prints bytes and instruction (in instruction order) - s ... prints assembly and sources info register ... show registers info args ... show parameters info locals ... show local variables ptype [variable] ... show type of variable p[/<f>] $<register> ... print register p[/<f>] <variable> ... print variable p[/<f>] &<variable> ... print address of variable p[/<f>] *<variable> ... print dereferenced variable p[/<f>] *this ... print member variables p[/<f>] sizeof(<var|type>) ... print size of variable/type <f> (format) - t ... binary - x ... hexadecimal - d ... signed decimal - u ... unsigned decimal - o ... octal - a ... address - c ... character - f ... float point - s ... string
Details ▼
Convenience Variables
p $_siginfo ... show signal details
Containers
p <vec>._M_impl._M_start+<idx> ... get item of vector
Memory
info proc mappings ... show memory mapping x/<n><f><u> <addr> ... print memory <n> (number) <f> (format) - Basic types see <f> for print - i ... instruction <u> (unit) - b ... byte (8-bit integer) - h ... half word (16-bit integer) - w ... word (32-bit integer) - g ... giant word (64-bit integer)
Details ▼
- Print current instruction: x/i $pc
Additional
– Basic assembler instructions (x64, A64)
– Adding dependencies to coredump (GDB)
– Unwind the stack even if GDB can’t? (ARM)
– Print stack frames from stack (GDB)