GDB可以在一系列函数调用上设置断点吗?

时间:2019-03-26 12:11:46

标签: debugging gdb breakpoints gdb-python

我想在崩溃发生之前检查一些全局变量。该问题仅在特定的堆栈跟踪中重现,并且在最内层函数(或堆栈中的任何其他函数)上设置断点将无法使我足够接近。

仅当堆栈顶部包含类似内容时,我才能达到中断的结果吗?

#0 __GI_connect
#1 curl_connect
#2 get_file
#3 init_assets

只要做

b init_assets
c
b get_file
c
...

不起作用,因为多次调用了init_assets,并且每次都不调用curl,因此gdb会中断使用curl的无关代码。

1 个答案:

答案 0 :(得分:4)

您可以在$_caller_is convenience function中使用条件断点。像这样:

(gdb) break connect
Breakpoint 1 at 0x7ffff7ee6820
(gdb) cond 1 $_caller_is("curl_connect") && $_caller_is("get_file", 2) && $_caller_is("init_assets", 3)
相关问题