core dump

一.core dump配置
[root@scctmpdev:/root]#grep pattern /etc/sysctl.conf
kernel.core_pattern = corefile/core-%e
这个表示dump文件在可执行应用的相对目录的corefile下
[root@scctmpdev:/root]#ulimit  -c
102400

二.测试core dump
[root@scctmpdev:/root]#cat test.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char** argv)
{
int a,b, result;
a = 2;
b = 0;
result = a/b;
return 0;
}
[root@scctmpdev:/root]#gcc -g test.c  -o test
[root@scctmpdev:/root]#ll co
config.log   context.xml  corefile/    
[root@scctmpdev:/root]#ll corefile/
total 0
[root@scctmpdev:/root]#ll test
-rwxr-xr-x 1 root root 7734 Jan 29 17:06 test
[root@scctmpdev:/root]#./test
Floating point exception (core dumped)
--运行test可执行文件时发生异常进而产生dump,如下。
[root@scctmpdev:/root]#ll corefile/
total 96
-rw------- 1 root root 188416 Jan 29 17:06 core-test

原文地址:https://www.cnblogs.com/dotagg/p/8378554.html