Skip to content

Instantly share code, notes, and snippets.

@dgoguerra
Last active August 29, 2015 13:56
Show Gist options
  • Save dgoguerra/8953214 to your computer and use it in GitHub Desktop.
Save dgoguerra/8953214 to your computer and use it in GitHub Desktop.
Generating and viewing core dumps

Enable generating core dumps

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.

Opening a core dump

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment