简体   繁体   中英

asm("trap") on 64-bit iOS devices

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.

Haven't tried iOS, but on Linux, the brk instruction causes SIGTRAP to be raised, which traps to the debugger if one is running.

asm("brk #0");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM