Make GDB print control flow of functions as they are called

前端 未结 5 683
广开言路
广开言路 2020-12-14 03:09

How do I make gdb print functions of interest as they are called, indented according to how deep in the stack they are?

I want to be able to say something like (made

5条回答
  •  执笔经年
    2020-12-14 03:20

    You may call gdb in batch mode (using -x option), break where you need and ask for backtrace (bt), then you filter the result using grep or egrep.

    Indents are more difficult, however bt output is ordered so you have current function at the top of the trace and main at very bottom.

    So you create file with commands:

    br 
    run
    bt
    kill
    quit
    

    then run gdb -x

    Filter strings that starts with # - you get stack trace.

提交回复
热议问题