首页 > 代码库 > coredump查原因

coredump查原因

1. dmesg |tail -n 1

2. objdump -DCI ./a.out

 

示例:

$ cat a.cpp

#include <stdio.h>

int main()
{
int *pa=NULL;
*pa=0;
return 0;
}

 

$ g++ -g a.cpp

$ ./a.out
Segmentation fault

dmesg | tail -n 1
[49481461.465836] a.out[17960]: segfault at 0 ip 0000000000400564 sp 00007fff36000540 error 6 in a.out[400000+1000]

$ objdump -DCI ./a.out | grep 400564
400564: c7 00 00 00 00 00 movl $0x0,(%rax)

$ addr2line -e ./a.out 0x400564
/data/home/ginobili/code/a.cpp:6