我想调试一些程序。我需要回溯所有对某个函数的调用,例如puts。
现在我使用这样的gdb script
set width 0
set height 0
set verbose off
break puts
commands 1
backtrace
continue
end但是开始的时候
gdb --batch --command=script --args ./some_program arguments给出一个错误:
Function "puts" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
/root/script:5: Error in sourced command file:
No breakpoint number 1.如何在脚本中为库调用设置断点?
发布于 2010-03-10 00:03:15
试着这样做:
set width 0
set height 0
set verbose off
start # runs to main, so shared libraries are loaded
# after you reach main, GDB should have libc symbols, "puts" among them
break puts
commands 1
backtrace
continue
end如果这不起作用,请说明操作系统版本。
编辑:正如osgx正确指出的那样,另一种选择是添加
set breakpoint pending on在break puts之前
https://stackoverflow.com/questions/2388799
复制相似问题