我想在 gdb 断点上设置一个条件,仅当某个函数名称出现在回溯中时才中断。最好的方法是什么?
问问题
2133 次
3 回答
4
比 Python 脚本更简单的解决方案是使用临时断点。
它看起来像这样:
b ParentFunction
command 1
tb FunctionImInterestedIn
c
end
每次你闯入时ParentFunction
,你都会在你真正感兴趣的函数上设置一个一次性断点,然后继续运行(大概直到你碰到那个断点)。
由于您将仅在 上中断一次,因此如果在 的上下文中多次调用并且您希望在每次调用时中断FunctionImInterestedIn
,这将不起作用。FunctionImInterestedIn
ParentFunction
于 2016-05-02T13:29:38.540 回答
3
我不确定如何完全按照您的要求进行操作,但是如果您可以访问相关函数的源代码,则可能的解决方法是true
在函数的开头设置一些全局布尔变量,并将其设置为false
就在函数退出之前。然后,您可以设置一个条件断点(使用condition
命令)以仅在此布尔变量为true
.
于 2010-11-14T13:00:01.253 回答
0
替代 rix0rrr 的答案:
b main
commands
set $inParentFunction = 0
c
end
b ParentFunction
commands
set $inParentFunction = 1
c
end
b FunctionImInterestedIn if ($inParentFunction)
于 2017-08-15T21:26:53.347 回答