@protocol Terminal -(BOOL) terminalRunProgram: (NSString *)path withArguments: (NSArray *)args inDirectory: (NSString *)directory properties: (NSDictionary *)properties; @end @implementation SomeGDBClient - (void)debug { NSString *programPath; NSString *gdbPath; NSArray *args; NSTask *task; NSDistantObject *terminal; int pid; if(!runningTask) { NSLog(@"No task to debug"); return; } pid = [runningTask processIdentifier]; /* Get the Terminal application */ terminal = (NSDistantObject *)[NSConnection rootProxyForConnectionWithRegisteredName:@"Terminal" host:nil]; task = [[NSTask alloc] init]; [task setLaunchPath:@"gdb"]; gdbPath = RETAIN([task validatedLaunchPath]); RELEASE(task); task = [[NSTask alloc] init]; [task setLaunchPath:@"my_task"]; programPath = RETAIN([task validatedLaunchPath]); RELEASE(task); args = [NSArray arrayWithObjects: [NSString stringWithFormat:@"--pid=%i", pid], [NSString stringWithFormat:@"--exec=%@", AUTORELEASE(programPath)], programPath, nil]; /* Launch gdb in the Terminal */ [terminal terminalRunProgram: AUTORELEASE(gdbPath) withArguments: args inDirectory: nil properties: nil]; NSLog(@"Launched gdb in Terminal.app"); } - (oneway void)newInDebugger { NSString *programPath; NSString *gdbPath; NSArray *args; NSTask *task; NSDistantObject *terminal; /* Get the Terminal application */ terminal = (NSDistantObject *)[NSConnection rootProxyForConnectionWithRegisteredName:@"Terminal" host:nil]; /* Prepare tasks */ task = [[NSTask alloc] init]; [task setLaunchPath:@"my_task"]; programPath = [task validatedLaunchPath]; RELEASE(task); task = [[NSTask alloc] init]; [task setLaunchPath:@"gdb"]; gdbPath = [task validatedLaunchPath]; RELEASE(task); args = [NSArray arrayWithObjects: gdbPath, @"--args", AUTORELEASE(programPath), nil]; [terminal terminalRunProgram: AUTORELEASE(gdbPath) withArguments: args inDirectory: nil properties: nil]; NSLog(@"Launched gdb in Terminal.app"); }