编写一个必然crash 的程序
#include <stdio.h>
void crash(){
char *a=0;
*a=0;
}
int main()
{
printf("hello world\n");
crash();
printf("after crash\n");
}
执行gdb 远程调试
gdbserver :1234 a.out
运行 gdb , 运行命令 target remote :1234
必须用 file 指定可执行文件,才能看见调用函数
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400534 in ?? ()
(gdb) bt
#0 0x0000000000400534 in ?? ()
#1 0x00007fffffffe4c0 in ?? ()
#2 0x000000000040054c in ?? ()
#3 0x0000000000000000 in ?? ()
(gdb) file /home/payne/hello/a.out
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/payne/hello/a.out...done.
(gdb) bt
#0 0x0000000000400534 in fun1 () at hello.cpp:6
#1 0x000000000040054c in main () at h