How to break when a specific exception type is thrown in GDB?

后端 未结 9 1172
迷失自我
迷失自我 2020-12-02 07:40

According to the documentation I can break on specific exception type by using conditional breakpoints. However the syntax for the condition isn\'t very clear to me:

9条回答
  •  一整个雨季
    2020-12-02 08:10

    Another approach is to rely on the tinfo argument available when the catch point is triggered, which is a pointer to the object returned by typeid(type).

    So say if I want to catch exception std::bad_alloc being thrown, I could just do:

    > p &typeid(std::bad_alloc)
    > $1 = (__cxxabiv1::__si_class_type_info *) 0x8c6db60 
    > catch throw if tinfo == 0x8c6db60
    

提交回复
热议问题