lost and found ( for me ? )

CentOS 6 : how to enable dump core files


# cat /etc/centos-release
CentOS release 6.3 (Final)

# uname -ri
2.6.32-279.14.1.el6.x86_64 x86_64


edit /etc/sysconfig/init. add the following line.
DAEMON_COREFILE_LIMIT='unlimited'


edit /etc/profile. add the following line
ulimit -c unlimited >/dev/null 2>&1


edit sysctl.conf . specify the directory core dump files are stored.
kernel.core_pattern = '/tmp/core_dump/core'


make the directory for core dump files
# mkdir /tmp/core_dump


reboot the OS
# init 6


how to check whether or not core files are dumped.

This C program will quit immediately and dump a core file.
# cat dump_core.c
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

int main(int argc, char **argv) {
kill(getpid(),SIGQUIT);
}


compile it.
# gcc dump_core.c -o dump_core.o


execute dump_core.o
# ./dump_core.o
Quit (core dumped)


core dump file was created under /tmp directory.
file /tmp/core_dump/core.1708
/tmp/core_dump/core.1708: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from './dump_core.o'


check the dump file with gdb
# gdb ./dump_core.o /tmp/core_dump/core.1708
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-56.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/hattori/My_works/dump_core.o...(no debugging symbols found)...done.
[New Thread 1708]
Missing separate debuginfo for
Try: yum --disablerepo='*' --enablerepo='*-debug*' install /usr/lib/debug/.build-id/98/5a5bb5fc57c6305be25c76f45d8feff775cc57
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Core was generated by `./dump_core.o'.
Program terminated with signal 3, Quit.
#0  0x00007f5a2c588b87 in kill () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.80.el6_3.6.x86_64
(gdb) quit

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.