Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: x86 inline assembler to stop in debugger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: x86 inline assembler to stop in debugger



Sorry; I ignored the PPC side of your code earlier. :) On PPC, you'll want this:

#define DebugBreak() if (AmIBeingDebugged()) { __asm__ volatile ("trap"); }

Hope this helps,
Eric

On Jan 30, 2006, at 6:50 AM, Dave McCaldon wrote:

Thanks, however on PPC, it seems that the inline assembler I found doesn't actually do what I want.  When running under Xcode, it seems to cause an EXC_SOFTWARE, which Xcode seems to treat as fatal.

Is there any way to make my DebugBreak() macro cause Xcode to stop in the debugger as if a breakpoint was set?

Thanks.


On Jan 29, 2006, at 5:23 PM, Eric Albert wrote:

On Jan 29, 2006, at 10:19 AM, Dave McCaldon wrote:

Technical Q&A QA1361 shows how to detect if you are running under the debugger, somewhere I found a snippet of inline assembler that uses this to trap into the debugger (useful for ASSERTs etc).

#define DebugBreak() __asm__ volatile ("twnei %0,0" : : "r" (AmIBeingDebugged()))

Can anyone confirm what the x86 version of this is? I'm guessing something along the lines of:

#define DebugBreak() if (AmIBeingDebugged()) { __asm__ volatile ("int 3"); }

It's more common to use "int3" as the instruction rather than "int $3", but either will work.

Hope this helps,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

--
Eric Albert email@hidden
http://outofcheese.org/

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >x86 inline assembler to stop in debugger (From: Dave McCaldon <email@hidden>)
 >Re: x86 inline assembler to stop in debugger (From: Eric Albert <email@hidden>)
 >Re: x86 inline assembler to stop in debugger (From: Dave McCaldon <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.