The configuration file /proc/sys/kernel/core_pattern
defines the default behaviour when a crash occurs.
If it contains a single word such as core
, a core dump will be generated on the current directory with that name.
If the first character of its content is |
, then the core file will be piped to a process, such as Apport (|/usr/share/apport/apport %p %s %c
).
To enable core dumps for your current terminal session ignoring the default action:
ulimit -c unlimited
Then core dumps will be generated in the current directory, named core
.
gdb /path/to/binary /path/to/core
Then, you can generate a stack trace:
(gdb) bt
or print a variable or expression:
(gdb) print expr