I want to create a core dump whenever my process crashes. Currently I am following this approach:
But I want to minimize the number of steps so that:
ulimit -c unlimited
" manually.So I have two questions:
ulimit -c unlimited
"The usual solution is to build with -g and to strip off the debug information before releasing the file. Look for the 'strip' command. You keep the file with debug information and use it to debug core dumps you get from customers.
If you want to print the human readable backtrace on the users machine you'll need to distribute binaries with (some) debug information. Look for the 'backtrace()' function in glibc.
Note that core dumps will be created (if ulimit is set appropriately) even if your binary doesn't contain debug information.
The best way to ensure the creation of a core dump is probably to execute your binary from a script which sets ulimit before running the binary.