简体   繁体   English

64 位 iOS 设备上的 asm("trap")

[英]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.在我自己开发的断言宏中,我一直在 iOS 设备上使用 asm("trap")(或在 iOS 模拟器上使用 asm("int3"))来中断调试器。 However, in 64-bit builds for devices, I get an "unrecognized instruction mnemonic" for the trap instruction.但是,在设备的 64 位构建中,我得到了陷阱指令的“无法识别的指令助记符”。 Is there an equivalent for arm64?是否有 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.) (替代方案如 __builtin_trap() 或 raise(SIGINT) 确实有效,但有一些我不喜欢的行为;前者不会让你继续休息,后者是 function 所以你总是低于一步当你打破时你需要在堆栈中的位置。)

I was able to break into the debugger (and continue afterwards) with asm("svc 0"); 我能够使用asm("svc 0");进入调试器(并在之后继续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.没有尝试过 iOS,但在 Linux 上, brk指令导致SIGTRAP被引发,如果一个正在运行,它会陷入调试器。

asm("brk #0");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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