开发者

Automate gdb: show backtrace at every call to function puts

I want to debug some program. I need backtraces from all calls to some function, e.g. puts.

Now I use such gdb script:

set width 0
set height 0
set verbose off
break puts
commands 1
backtrace
continue
end

But starting it with

gdb --batch --command=script --args ./some_program arguments

Gives a error:

Function "puts" not defined.
Make breakpoint pending on futur开发者_Go百科e shared library load? (y or [n]) [answered N; input not from terminal]
/root/script:5: Error in sourced command file:
No breakpoint number 1.

How can I set breakpoint in script for library call?


Try this instead:

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

If this doesn't work, please state operating system version.

EDIT: as osgx correctly points out, the other alternative is to add

set breakpoint pending on

before break puts

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜