Xcode:无效的汇编指令

时间:2013-09-11 21:07:40

标签: ios xcode

我可以在iOS模拟器上正常编译,但是当我将设备切换到我的iPhone并构建时,我看到以下错误。当我点击此错误时,它不会指向任何代码。

enter image description here

问题可能来自这一点的__asm__指令,但是当我在模拟器上运行时,我已经能够使用DebugBreak

#ifdef DEBUG
    // this code found in http://www.cocoawithlove.com/2008/03/break-into-debugger.html
    static bool AmIBeingDebugged(void)
    // Returns true if the current process is being debugged (either
    // running under the debugger or has a debugger attached post facto).
    {
        int                 junk;
        int                 mib[4];
        struct kinfo_proc   info;
        size_t              size;

        // Initialize the flags so that, if sysctl fails for some bizarre
        // reason, we get a predictable result.

        info.kp_proc.p_flag = 0;

        // Initialize mib, which tells sysctl the info we want, in this case
        // we're looking for information about a specific process ID.

        mib[0] = CTL_KERN;
        mib[1] = KERN_PROC;
        mib[2] = KERN_PROC_PID;
        mib[3] = getpid();

        // Call sysctl.

        size = sizeof(info);
        junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
        assert(junk == 0);

        // We're being debugged if the P_TRACED flag is set.

        return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
    }

    #if __ppc64__ || __ppc__
        #define DebugBreak() \
        if(AmIBeingDebugged()) \
            { \
            __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
            : : : "memory","r0","r3","r4" ); \
            }
        #else
        #define DebugBreak() if(AmIBeingDebugged()) {__asm__("int $3\n" : : );}
    #endif

    bool AmIBeingDebugged(void);
#else
    #define DebugBreak()
#endif

1 个答案:

答案 0 :(得分:1)

int $3是x86指令。您无法在像iPhone这样的ARM设备上运行它。