如何将 watch 命令输出记录到 gdb 中的文件中
How to record watch command output to a file in gdb
我想在 gdb 中使用 watch 命令记录寄存器变化,如下所示:
(gdb) watch $register-name
只要应用程序中的寄存器发生变化,gdb 就会停止,我必须按 c 键才能继续调试。有什么办法可以不用一直按回车键,而是让 gdb 将寄存器中的所有更改保存到文件中?
I have to press c to continue debugging.
请注意,按 <Enter>
将重复之前的命令(例如之前的 c
)。
Is there any way to instead of hitting enter for endless time, I just ask gdb to save all the changes in the register to a file?
当然可以:
(gdb) watch $rax
Watchpoint 2: $rax
(gdb) commands 2
Type commands for breakpoint(s) 2, one per line.
End with a line saying just "end".
>c
>end
# This is to prevent stop after every screen-full of output
(gdb) set height 0
(gdb) set logging on
Copying output to gdb.txt.
(gdb) continue
瞧:你现在已经有了 gdb.txt
中的所有更改
我想在 gdb 中使用 watch 命令记录寄存器变化,如下所示:
(gdb) watch $register-name
只要应用程序中的寄存器发生变化,gdb 就会停止,我必须按 c 键才能继续调试。有什么办法可以不用一直按回车键,而是让 gdb 将寄存器中的所有更改保存到文件中?
I have to press c to continue debugging.
请注意,按 <Enter>
将重复之前的命令(例如之前的 c
)。
Is there any way to instead of hitting enter for endless time, I just ask gdb to save all the changes in the register to a file?
当然可以:
(gdb) watch $rax
Watchpoint 2: $rax
(gdb) commands 2
Type commands for breakpoint(s) 2, one per line.
End with a line saying just "end".
>c
>end
# This is to prevent stop after every screen-full of output
(gdb) set height 0
(gdb) set logging on
Copying output to gdb.txt.
(gdb) continue
瞧:你现在已经有了 gdb.txt