测试程序
#include <stdio.h>
void func()
{
char* p = NULL;
p[0] = 'A';
}
int main()
{
func();
printf("Hello world!");
return 0;
}
编译, 生成可执行程序
gcc -g main.cpp -o main
启动core文件
# 当前终端有效,临时环境
ulimit -c unlimited
运行程序
$ ./main
Segmentation fault (core dumped)
$ gdb main core
...
(gdb) bt
#0 0x0000563fdeaed65a in func () at main.c:6
#1 0x0000563fdeaed66e in main () at main.c:11
(gdb)
标签:core,文件,启用,gdb,func,main
From: https://www.cnblogs.com/shiguoliang/p/16533666.html