gdb 脚本:在选定的断点处执行命令 [英] gdb scripting: execute commands at selected breakpoint

查看:41
本文介绍了gdb 脚本:在选定的断点处执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 gdb 脚本中预定义一些断点,并在这些断点处调用一些特殊命令,然后自动继续程序执行.因此,理想情况下,我想要一个如下所示的 gdb 脚本:

I'd like to predefine some breakpoints in a gdb script and to invoke some special commands at these breakpoints and afterwards to automatically continue the program execution. So, ideally, I'd like to have a gdb script like the following:

b someFunction
...
if breakpoint from above reached do:
  print var1
  call someOtherFunction
  continue
done

另外一个不幸的事实是,我不能依赖 python 接口来使用断点,因为我目前工作的服务器上的 gdb 版本太旧了!

Additionally an unfortunate fact is, that I can't rely on the python interface for using breakpoints, as the gdb version at the server I currently work at is too old!

推荐答案

您应该看看 command 命令,它使您能够在遇到断点时添加 gdb 命令.请参阅 gdb 手册的断点命令列表部分.

You should take a look at the command command, which enables you to add gdb commands as a breakpoint is hit. See the breakpoint command list section of the gdb manual.

例如:

break someFunction
commands
print var1
end

someFunction 上的断点被命中时,会自动打印 var1.

will, when the breakpoint on someFunction is hit, automatically print var1.

这篇关于gdb 脚本:在选定的断点处执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆