Re: How test whether Mac app is running in Xcode?
Re: How test whether Mac app is running in Xcode?
- Subject: Re: How test whether Mac app is running in Xcode?
- From: Daniel Höpfl <email@hidden>
- Date: Tue, 15 Oct 2013 13:54:58 +0200
On 2013-10-15 13:12, Bill Cheeseman wrote:
Is there any way to test whether an application is running in Xcode or
some other compiler/debugger, and not as a free-standing application?
And then to get the name of the compiler/debugger?
I'm currently testing #ifdef DEBUG and simply assuming that Xcode is
the only compiler/debugger available on the Mac. But I understand that
isn't true.
#ifdef DEBUG is a compile time switch. You can run apps compiled with
DEBUG defined outside the debugger, too.
If you really need to know if you are running with a debugger attached,
the following might work (I did not test it!):
- fork into a new process, IPC to parent in place.
- regularly try:
int err = ptrace(PT_ATTACH, <pid>, (caddr_t)0, 0);
if (!err) ptrace(PT_CONTINUE, <pid>, (caddr_t)1, 0)
if (err == EBUSY) {
// Use IPC to inform parent: A debugger is attached.
}
I don't think there is a way to get the name of the process that is
attached as debugger.
HTH,
Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden