Breaking into the debugger on iPhone

后端 未结 8 1243
花落未央
花落未央 2020-12-15 07:23

For assert macros in my iPhone project, I\'m looking for a way to programmatically break into the debugger. On Windows (MSVC++), I can use __debugbreak() for this purpose. I

相关标签:
8条回答
  • 2020-12-15 07:55

    While an ancient thread, found this while researching same topic for Xcode 7. What solved this for me was a feature called "Create Exception Breakpoint..."

    Debug > Breakpoints > Create Exception Breakpoint...

    This puts a special breakpoint in the Breakpoint Navigator (under View > Navigators > Show Breakpoint Navigator).

    This breaks on the actual throw of the exception:

    [ exception raise ]
    

    without terminating your code execution. You can just continue if that is how your code is structured.

    Double-clicking the break point marker next to "All Exception" lets you adjust where and how the exception break point stops:

    0 讨论(0)
  • 2020-12-15 08:03

    edit

    Turns out this also works:

    #define Debugger() { raise( SIGINT ) ; }

    I think it's the same principle.


    I use this:

    #define Debugger() { kill( getpid(), SIGINT ) ; }

    I think it works in the simulator and on the device.. no assembly required!

    0 讨论(0)
提交回复
热议问题