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

后端 未结 9 1196
迷失自我
迷失自我 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:08

    EDIT

    The documentation suggests that catch throw can be used to break whenever an exception of type is thrown; however, that doesn't seem to work in practice.

    (gdb) help catch
    Set catchpoints to catch events.
    Raised signals may be caught:
            catch signal              - all signals
            catch signal     - a particular signal
    Raised exceptions may be caught:
            catch throw               - all exceptions, when thrown
            catch throw   - a particular exception, when thrown
            catch catch               - all exceptions, when caught
            catch catch   - a particular exception, when caught
    Thread or process events may be caught:
            catch thread_start        - any threads, just after creation
            catch thread_exit         - any threads, just before expiration
            catch thread_join         - any threads, just after joins
    Process events may be caught:
            catch start               - any processes, just after creation
            catch exit                - any processes, just before expiration
            catch fork                - calls to fork()
            catch vfork               - calls to vfork()
            catch exec                - calls to exec()
    Dynamically-linked library events may be caught:
            catch load                - loads of any library
            catch load       - loads of a particular library
            catch unload              - unloads of any library
            catch unload     - unloads of a particular library
    The act of your program's execution stopping may also be caught:
            catch stop
    
    C++ exceptions may be caught:
            catch throw               - all exceptions, when thrown
            catch catch               - all exceptions, when caught
    Ada exceptions may be caught:
            catch exception           - all exceptions, when raised
            catch exception     - a particular exception, when raised
            catch exception unhandled - all unhandled exceptions, when raised
            catch assert              - all failed assertions, when raised
    
    Do "help set follow-fork-mode" for info on debugging your program
    after a fork or vfork is caught.
    
    Do "help breakpoints" for info on other commands dealing with breakpoints.
    

提交回复
热议问题