Xcode等效于'__asm int 3/DebugBreak()/停止吗? [英] Xcode equivalent of ' __asm int 3 / DebugBreak() / Halt?

查看:135
本文介绍了Xcode等效于'__asm int 3/DebugBreak()/停止吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode中导致硬中断的指令是什么?例如,在Visual Studio中,我可以执行'_asm int 3'或'DebugBreak()'.在某些GCC实施中,它是asm("break 0")或asm("trap").

What's the instruction to cause a hard-break in Xcode? For example under Visual Studio I could do '_asm int 3' or 'DebugBreak()'. Under some GCC implementations it's asm("break 0") or asm("trap").

我在Xcode下尝试了各种组合,但没有任何运气. (内联汇编程序工作正常,因此不是语法问题.)

I've tried various combos under Xcode without any luck. (inline assembler works fine so it's not a syntax issue).

供参考,这是一个断言宏.我不想同时使用assert.h中的定义来实现可移植性,并且因为它们似乎在XCode提供的版本中使用了abort().

For reference this is for an assert macro. I don't want to use the definitions in assert.h both for portability, and because they appear to do an abort() in the version XCode provides.

John-超级,欢呼.作为参考,int 3语法是Intel Macs和iPhone所需的语法.

John - Super, cheers. For reference the int 3 syntax is the one required for Intel Macs and iPhone.

Chris-感谢您的评论,但是有很多原因要避免将标准的assert()函数用于移植到不同平台的代码库.如果您遇到了无法确定自己的断言的麻烦,通常是因为您希望保留其他功能(日志记录,堆栈展开,用户交互).

Chris - Thanks for your comment but there are many reasons to avoid the standard assert() function for codebases ported to different platforms. If you've gone to the trouble of rolling your own assert it's usually because you have additional functionality (logging, stack unwinding, user-interaction) that you wish to retain.

您关于尝试通过实现'__assert'或类似方法来替换处理程序的建议将无法移植,标准的'assert'通常是宏,尽管它可能在Mac上映射到__assert却没有在其他平台上.

Your suggestion of attempting to replace the hander via an implementation of '__assert" or similar is not going to be portable. The standard 'assert' is usually a macro and while it may map to __assert on the Mac it doesn't on other platforms.

推荐答案

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆