GDB 记录还原未按预期工作

gdb record restore not working as expected

本文关键字:工作 记录 还原 GDB      更新时间:2023-10-16

我有这个简单的C++程序

#include <iostream>
using namespace std;
int main() {
 cout << "Hello" << endl; 
 return 0;
}

该程序不会出现段错误。

我像这样运行 gdb:

gdb a.out
break main
run
target record
record save
s
record stop
c
quit

然后我再次调用 gdb:

gdb
record restore gdb_record.21158
[New LWP 21158]
Core was generated by `a.out'.
Program terminated with signal 5, Trace/breakpoint trap.
#0  0x08048617 in ?? ()
Segmentation fault

更新更多信息

(gdb) record save
warning: Memory read failed for corefile section, 4096 bytes at 0xffffffffff600000.
Saved core file gdb_record.6490 with execution log.
(gdb) s
Single stepping until exit from function main,
which has no line number information.
Hello
__libc_start_main (main=0x5555555551a9 <main>, argc=1, argv=0x7fffffffe108, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffe0f8) at ../csu/libc-start.c:342
342 ../csu/libc-start.c: No such file or directory.

可能是你没有用a.out启动gdb。所以应该是

gdb a.out
record restore gdb_record.21158
record goto end