2

I can compile fine on the iOS Simulator, but when I switch the device to my iPhone and build , I see the following error. When I click on this error, it doesn't direct to any code.

enter image description here

The problem might be coming from the __asm__ instruction in this bit of come, but I have been able to use DebugBreak when I'm running on the simulator:

#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
4

1 回答 1

1

int $3是 x86 指令。你不能在像 iPhone 这样的 ARM 设备上运行它。

于 2013-09-11T21:35:27.163 回答