假设core文件和可执行程序在同一个目录,core文件为core.1234,可执行文件为test
1、执行命令 gdb core.1234
提示core.1234 : not in executable format: File format not recognized
2、file ./test
提示 Reading symbols from test...done.
3、l ,显示程序行
4、b 311
Breakpoint 1 at 0x804de4a: file src/test.cpp, line 331.
b 312...
Breakpoint 1 at 0x804de8c: file src/test.cpp, line 332.
在程序311和312等这些行设置断点。
5、r (run)
运行程序,会在停在311行
6、s(step)
下一步,如果有函数,会进入函数,如果用n(next) 就不会进入函数中,只会运行当前调用函数的行
7、p a[0]
print 打印值
8、bt 查看栈
还有其它命令,不一一列举。