Coredump analysing with GDB

Load coredump with GDB

gdb <executable> <coredump>

Analysis of threads

info threads ... show running threads
thread <idx> ... switch to other thread

Analysis of stacktrace

thread apply all bt ... show the bt of all running threads
thread <idx> bt     ... show the bt of specific thread
bt [<lvls>]         ... 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

Analysis of functions/variables

list [function]      ... show source code
disas [function]     ... show disassembly
info register        ... show registers
info args            ... show parameters
info locals          ... show local variables
p $<register>        ... print register
p <variable>         ... print variable
p &<variable>        ... print address of variable
p *<variable>        ... print dereferenced variable
p *this              ... print member variables
p sizeof(<var|type>) ... print size of variable/type

Details to typical constructs

- Deref. std::shared_ptr: p *<shared_ptr>._M_ptr (or p *<shared_ptr>)
- Size of std::vector: p <vec>._M_impl._M_finish - <vec>._M_impl._M_start
- Deref. item of std::vector:  p *(<vec>._M_impl._M_start+<idx>)

Analysis of memory

x/<n><f><u> <addr> ... print memory (n: number, f: format, u: unit)

Format:
- t ... binary
- u ... unsigned decimal
- d ... decimal
- x ... hexadecimal
- o ... octal
- f ... floating point
- a ... address
- c ... char
- s ... string
- i ... instruction

Unit:
- b ... byte (8-bit integer)
- h ... half word (16-bit integer)
- w ... word (32-bit integer)
- g ... giant word (64-bit integer)