1、sudo su
2、vim /etc/profile
添加 ulimit -c unlimited
3、在你的主目录下创建core文件夹,比如我在/home/ji下创建core文件夹
4、vim /etc/sysctl.conf
添加
kernel.core_pattern=/home/ji/core/core_%e_%p_%t
kernel.core_uses_pid=0
说明:
%e 文件名
%p 进程pid
%t 时间
5、reboot 重启电脑
6、编译一个测试文件,a.c
#include <stdio.h>
int main(void)
{
int *a = NULL;
*a = 0x1;
return 0;
}
7、gcc -g a.c -o a.out
8、运行a.out,看一下core文件夹下面有没有core文件