linux: how do I generate a core file?

8k Views Asked by At

I'm using Ubuntu 10.04. I run "ulimit -c 999" then I compile and execute (gcc test.c && ./a.out) this tiny app:

#include <signal.h>

int main( void )
{
    raise( SIGSEGV );

    return 0;
}

Even though this does print a "Segmentation fault" message, I don't see a core file. What have I missed that is preventing the core file from being generated?

2

There are 2 best solutions below

2
On BEST ANSWER
ulimit -c unlimited

More about enabling core dumps here

EDIT:

Ok, I see what is the problem. Your core file limit is too low. 999 bytes (as you set it) is not enough. Increase it to something reasonable. unlimited is the best parameter.

5
On

Use the ulimit command with the -c flag to control the maximum size of core file you want to allow.