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

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

问题描述

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


如果上面的断点达到了:
print var1
call someOtherFunction
continue
done

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

解决方案

您应该查看命令命令,该命令允许您添加命中gdb命令作为断点。请参阅gdb手册的断点命令列表部分。



例如:

  break someFunction 
命令
打印var1
结束

会在 someFunction 被自动打印,自动打印var1


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

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!

解决方案

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.

For example:

break someFunction
commands
print var1
end

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

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

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