In my homegrown assert macro, I've been using asm("trap") on iOS devices (or asm("int3") on iOS simulators) to break in the debugger. However, in 64-bit builds for devices, I get an "unrecognized instruction mnemonic" for the trap instruction. Is there an equivalent for arm64?
(Alternatives like __builtin_trap() or raise(SIGINT) do work, but have some behavior I don't like; the former won't let you continue past the break, and the latter is a function so you're always one step below where you need to be in the stack when you break.)
I was able to break into the debugger (and continue afterwards) with asm("svc 0");
. I’m not sure this is the correct way but it seems to do the job.
来源:https://stackoverflow.com/questions/20713220/asmtrap-on-64-bit-ios-devices