Re: Attaching to the debugger programatically
Re: Attaching to the debugger programatically
- Subject: Re: Attaching to the debugger programatically
- From: Jonas Maebe <email@hidden>
- Date: Sat, 1 Apr 2006 19:10:15 +0300
On 30 Mar 2006, at 18:31, Matt Gough wrote:
Sorry, I should have explained better. I want to be able to do this
from within the running app itself. E.g:
if (somethingUnexpected)
AttachAndDropIntoDebugger();
The following code works at least on linux/x86:
int pid;
{
pid = fork();
if(pid == -1)
{
fprintf(stderr, "failed to fork\n");
fflush(stderr);
}
if(pid == 0)
{
/* child */
char cmd[256];
char *argv[4] = {"sh", "-c", cmd, 0};
sprintf(cmd, "gdb %s %d", argv[0], getppid());
execve("/bin/sh", argv, NULL);
fprintf(stderr, "sorry, failed to start gdb!\n");
exit(127);
}
// may need to be increased, shouldn't continue until gdb attached
// other possible solution is a while loop whereby you manually
// change the loop control variable from within gdb after it
started
sleep(3);
}
Jonas
_______________________________________________
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