Reputation: 2579
I want the program to dump core on crash on Linux for debugging purpose. How do I enable this feature - does this require any changes in the program ?
Upvotes: 3
Views: 987
Reputation: 341
In addition to Troy's answer you will have to add to e/etc/sysctl.conf - where and how you need to core to be generated - like this :
kernel.core_uses_pid=1
kenrel.core_pattern= /tmp/cores/core-%e-%p-%u-%g-%s-%t
fs.suid_dumpable=2
Upvotes: 2
Reputation: 21
If your program is user-mode program. Here is a brief tutorial.
Set the core file size to maximum
ulimit -c unlimited
Run your program
$ ./your_program
Segmentation fault (core dumped)
It would generate core dump file. Use gdb to analyze the core dump
gdb ./your_progrm core
You can reference How to Debug Using GDB for more information.
Upvotes: 2
Reputation: 7132
You can either enable it for yourself by doing:
ulimit -c unlimited
If you want this to be persistent put it in ~/.profile
Alterantively, you can enable core dumps for all users on the system put the following line in /etc/sercurity/limits.conf (at least on ubuntu):
* 0 core -1
Upvotes: 7
Reputation: 2915
Whether generate core dump or not is controlled by the shell
If you use bash.
ulimit -c unlimited
Upvotes: 2