//core.cpp内容
#include <iostream>
using namespace std;
int main()
{
int a[100];
a[-100000]=50;
cout << a[-100000]<<endl;
return 0;
}
具体操作如下:
fzu@fzu-desktop:~/ac$ ulimit -c unlimited
fzu@fzu-desktop:~/ac$ g++ -g core.cpp
fzu@fzu-desktop:~/ac$ ./a.out
段错误 (core dumped)
fzu@fzu-desktop:~/ac$ gdb -core=core
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
(no debugging symbols found)
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
[New process 9634]
#0 0x080486f4 in ?? ()
(gdb) file ./a.out
Reading symbols from /home/fzu/ac/a.out...done.
(gdb) bt
#0 main () at core.cpp:6
(gdb)