Generate core dump in TI AM335x

# Enlarge the core file size:
ulimit -c unlimited

Check result:
ulimit -a

Result should be:
> core file size          (blocks, -c) unlimited

Equivalent in code:
#include <sys/resource.h>
struct rlimit limit;
limit.rlim_cur = RLIM_INFINITY;
limit.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &limit) == 0)
{
    // success
}

# Check the core pattern is what we want
more /proc/sys/kernel/core_pattern

Recommended core pattern:
echo "core.%e.%p.%t" > /proc/sys/kernel/core_pattern

It displays the app name, process id, and timestamp

Ref: http://fcamel-life.blogspot.tw/2012/02/core-dump.html

# Ensure the crash app doesn't have registered to catch signal
If so, use the following trick in the crash app to generate core dump:

1. Register a signal handler, sig_handler, for SIGSEGV
2. In sig_handler, do things we want
3. Register the default signal handler, SIG_DFL, for incoming signal
4. Use kill() to send the incoming signal to itself

The core dump file will be generated in the folder which is the same as the crash app.

Ref: http://www.alexonlinux.com/how-to-handle-sigsegv-but-also-generate-core-dump


留言

熱門文章