firstly. test cpp file show below.
cpp// t.cpp
#include <iostream>
#include <stdio.h>
int main()
{
char* c = NULL;
printf("%d", *c);
return 0;
}
to check if the coredump enabled in your system by.
shellulimit -c // return 0 if disable. ulimit -c unlimited // this command will enable the coredump feature.
use g++ to compile the program with -g option.
shellg++ -g t.cpp -o t.o // complile ./t.o // this command will run into fail // message is "Segmentation fault (core dumped)" // and a file named "core" is generated.
now you can use gdb to debug the code.
shellgdb t.o core
done !
本文作者:Santiago Chou
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 无版权要求,都是一些日常话题。 许可协议。转载请注明出处!