Breaking into the debugger on iPhone

后端 未结 8 1241
花落未央
花落未央 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:47

    A helpful person on Apple's developer forum gave me the tip to use asm("trap") when running on the device and asm("int3") when running on the simulator. This makes the program break into the debugger if you started your programm in debug mode (Option-Command-Y).

    (__builtin_trap() also breaks into the debugger, but you can't continue afterwards. assert(false) terminates the program with a message, but doesn't break into the debugger.)

提交回复
热议问题