Can gdb be used to backtrace when exceptions are caught?

后端 未结 2 1202
执笔经年
执笔经年 2021-02-05 07:33

I have just started using c++ exceptions and want to get it right. What I have in mind is to generate some sort of backtrace information when exceptions are caught. Initially I

2条回答
  •  借酒劲吻你
    2021-02-05 08:19

    Summary of answers from the comments:

    1st Method (by paulsm4). Set a catchpoint via catch throw for catching on throw or catch catch for catching on catch! Then call backtrace

    2nd Method (by aschepler) Set a breakpoint on __cxa_throw and then backtrace

    3rd Method (in Qt Creator -- if you happen to use) You can easily set a breakpoint on throw or catch!

    Using Qt Creator debugger, it seems that setting a breakpoint on __cxa_begin_catch is also an equivalent to catch catch

提交回复
热议问题