Can I create a breakpoint in code in iOS, like `__asm{int 3}` on VC++, and continue execution after it's been hit?

前端 未结 9 2096
终归单人心
终归单人心 2020-12-30 04:24

I\'m trying to put the equivalent of asm{int 3} (or similar) into my iPhone program. My goal is to have Xcode stop exactly on the offending line, without having

相关标签:
9条回答
  • 2020-12-30 05:12

    Try:

    __builtin_trap();
    

    works on Mac as well as iOS, and you can drag the little green cursor to the next line to continue running.

    0 讨论(0)
  • 2020-12-30 05:16

    I've tried all of these solutions and although @RichardGroves answer preserved the stack, the best solution is to:

    1. create your own assert method, such as Debug::assert(...)
    2. set a breakpoint within XCode on that implementation
    3. use the Step Out command to get back to the caller

    This is because it's the only reliable way to both

    • view the stack trace
    • step / continue
    0 讨论(0)
  • raise(SIGTRAP) is a relatively portable way to have an "in code" breakpoint.

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