Automate gdb: show backtrace at every call to function puts

前端 未结 1 1808
逝去的感伤
逝去的感伤 2020-12-28 18:59

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 h         


        
相关标签:
1条回答
  • 2020-12-28 19:23

    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 讨论(0)
提交回复
热议问题