自动化 GDB 调试会话的最佳方法是什么? [英] What are the best ways to automate a GDB debugging session?
问题描述
GDB 是否有内置的脚本机制,我应该编写一个期望脚本,还是有更好的解决方案?
Does GDB have a built in scripting mechanism, should I code up an expect script, or is there an even better solution out there?
我每次都会发送相同的命令序列,并将每个命令的输出保存到一个文件中(很可能使用 GDB 的内置日志记录机制,除非有人有更好的主意).
I'll be sending the same sequence of commands every time and I'll be saving the output of each command to a file (most likely using GDB's built-in logging mechanism, unless someone has a better idea).
推荐答案
gdb
运行后执行文件.gdbinit
.所以你可以将你的命令添加到这个文件中,看看它是否适合你.这是一个 .gdbinit
示例,用于打印所有 f()
调用的回溯:
gdb
executes file .gdbinit
after running.
So you can add your commands to this file and see if it is OK for you.
This is an example of .gdbinit
in order to print backtrace for all f()
calls:
set pagination off
set logging file gdb.txt
set logging on
file a.out
b f
commands
bt
continue
end
info breakpoints
r
set logging off
quit
这篇关于自动化 GDB 调试会话的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!