Im debugging a plugin using XCode 4.5 using the Info > Launch > Wait for ??? to launch and debugging work great.
However everytime I hit the stop button or push back the play button the application that I attach my plugin to get killed (Killed: 9). If I attach to a process isn’t it not logic that the play or stop button would detach me from that process?
Is there a way that I can change this behavior in Xcode instead of typing everytime on the lldb console >> process detach for it to continue?
What Im thinking is to add some code in my main app (the one that I attach XCode to) to add a piece of code to disconnect the debugger is it possible?
[ EDIT ]
Found this code that determine if the debugger is attached:
bool debugger_attached( void )
{
int mib[ 4 ];
struct kinfo_proc info;
size_t size;
info.kp_proc.p_flag = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
size = sizeof( info );
sysctl( mib, sizeof( mib ) / sizeof( *mib ), &info, &size, NULL, 0 );
return ( ( info.kp_proc.p_flag & P_TRACED ) != 0 );
}
Now how to detach the debugger from the current process?
I think it’s already clear from the follow-up comments that this behavior — Xcode not having a simple GUI gesture to detach from a process — is how things work today. There’s at least one use-case where this is the correct behavior — when doing iOS Simulator process debugging on your Mac, the Simulator app is not launched by Xcode/lldb directly – it attaches to an already-launched process. In that case, when you press the Stop button in Xcode, you expect the simulated app to stop running. This is an implementation detail that users don’t know about/shouldn’t need to know about, but there is some logic to the behavior.
For what it’s worth, you can make an alias in your
~/.lldbinitfile likeand now in the debugger console you can type just
detto detach. (or whatever alias you want to set up). It’s not as simple as hitting a button in the GUI but it’s better thanprocess detach.