#include <stdio.h>
int main()
{
char *p = "hello world";
*(p+1) = 'X';
printf ("%s\n", p);
return (0);
}
# ./coredump_test.exe
段错误 (core dumped)
ulimit -S -c unlimited > /dev/null 2>&1
gdb 可执行文件 core_dumped文件
gdb coredump_test.exe core.10852
[root@localhost ~]# gdb coredump_test.exe core.10852
GNU gdb Fedora (6.8-27.el5)
Copyright (C) 2008 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 "i386-redhat-linux-gnu"...
warning: core file may not match specified executable file.
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./coredump_test.exe'.
Program terminated with signal 11, Segmentation fault.
[New process 10852]
#0 0x080483a2 in main () at coredump_test.c:7
7 *(p+1) = 'X';
[root@localhost syscall]# cat /proc/sys/kernel/core_pattern
|/usr/libexec/abrt-hook-ccpp /var/spool/abrt %s %c %p %u %g %t %h %e 636f726500
%p - insert pid into filename 添加pid
%u - insert current uid into filename 添加当前uid
%g - insert current gid into filename 添加当前gid
%s - insert signal that caused the coredump into the filename 添加导致产生core的信号
%t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
%h - insert hostname where the coredump happened into filename 添加主机名
%e - insert coredumping executable name into filename 添加命令名
[root@localhost syscall]# ./abort
hello world
Aborted (core dumped)
[root@localhost syscall]# ls /tmp/core
core.3438
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |