我想调试一些程序。我需要从一些函数的所有调用中回溯,例如放。
现在我使用这样的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.
如何在脚本中为库调用设置断点?
答案 0 :(得分:19)
请改为尝试:
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