Coredump analysing (GDB)

Setup

$ cat /proc/sys/kernel/core_pattern ... get coredumps location
$ gdb <executable> <coredump>       ... load coredump with GDB

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 [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

Convenience Variables

p $_siginfo ... show signal details

Containers

p <vec>._M_impl._M_start+<idx> ... get item of vector

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)