Where is my main file after segfault?

When my program is segfaults, I expect coredump, but it is not. I thought that just compiling with -g was enough to get the main file. Here are the gcc lines from my makefile:

gcc -g -c client.c $(incdirs) gcc -g -o client client.o $(LIBDIRS) $(LIBS) -lrt -lidn -lssl \ /home/calls/cgi/libcurl/lib/libcurl.a -lezxml -lxmlate $(SQLIBS) 

All libraries compiled / linked to -g.

And here is the gcc version information:

 calls/cgi/client>gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20080704 (Red Hat 4.1.2-51) 

My question is: What else do I need to say gcc (or anyone else) to get the kernel file?

+8
gcc coredump
source share
2 answers

it is possible that the kernel size is 0. Try

 ulimit -a 

if he shows

 core file size (blocks, -c) 0 

then do

 ulimit -c unlimited 

(you may need to modify your profile scripts to change this forever)

+17
source share

You need to enable the core dump, in particular by setting the appropriate resource. The setrlimit system call if you want to install it in your program. Most often you need to install it in your shell, for example. with ulimit -c unlimited

And your question probably duplicates this and many others.

By the way, usually there is no gcc that flushes the kernel, it is your program (compiled by gcc or some other compiler, for example clang or tcc ).

Remember to compile your program with gcc -Wall -g .

And your question has many answers, you will find thousands or more of them with Google or another search engine.

+3
source share

All Articles