Author: gcasa Date: Wed May 4 00:01:00 2016 New Revision: 39719 URL: http://svn.gna.org/viewcvs/gnustep?rev=39719&view=rev Log: Parse pid from MI output.
Modified: apps/projectcenter/trunk/ChangeLog apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebugger.m apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebuggerView.m apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m Modified: apps/projectcenter/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/trunk/ChangeLog?rev=39719&r1=39718&r2=39719&view=diff ============================================================================== --- apps/projectcenter/trunk/ChangeLog (original) +++ apps/projectcenter/trunk/ChangeLog Wed May 4 00:01:00 2016 @@ -1,3 +1,11 @@ +2016-05-03 18:00-EDT Gregory John Casamento <greg.casame...@gmail.com> + + * Modules/Debuggers/ProjectCenter/PCDebugger.m + * Modules/Debuggers/ProjectCenter/PCDebuggerView.m + * Modules/Debuggers/ProjectCenter/PipeDelegate.m: Changes + to allow pid to be passed back to PCDebugger by calling + setSubProcessId once the pid is parsed from the mi output. + 2016-05-03 Riccardo Mottola <r...@gnu.org> * Modules/Debuggers/ProjectCenter/PCDebugger.h Modified: apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebugger.m URL: http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebugger.m?rev=39719&r1=39718&r2=39719&view=diff ============================================================================== --- apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebugger.m (original) +++ apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebugger.m Wed May 4 00:01:00 2016 @@ -163,7 +163,7 @@ { [debuggerView runProgram: debuggerPath inCurrentDirectory: [executablePath stringByDeletingLastPathComponent] - withArguments: [[NSArray alloc] initWithObjects: @"-f", executablePath, nil] + withArguments: [[NSArray alloc] initWithObjects: @"-q", @"--interpreter=mi", @"-f", executablePath, nil] logStandardError: YES]; } Modified: apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebuggerView.m URL: http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebuggerView.m?rev=39719&r1=39718&r2=39719&view=diff ============================================================================== --- apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebuggerView.m (original) +++ apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PCDebuggerView.m Wed May 4 00:01:00 2016 @@ -58,92 +58,7 @@ - (void) logString:(NSString *)str newLine:(BOOL)newLine { - NSRange range; - BOOL printLine = YES; - - range = [str rangeOfString: @"\032\032"]; // Breakpoint"]; - if (range.location != NSNotFound) - { - NSScanner *scanner = [NSScanner scannerWithString: str]; - NSCharacterSet *empty = [NSCharacterSet characterSetWithCharactersInString: @""]; - NSString *file = nil; - NSString *line = nil; - NSString *bytes = nil; - int l = 0, b = 0; - - [scanner setCharactersToBeSkipped: empty]; - [scanner scanUpToString: @"\032\032" intoString: NULL]; - [scanner scanString: @"\032\032" intoString: NULL]; - [scanner scanUpToString: @":" intoString: &file]; - [scanner scanString: @":" intoString: NULL]; - [scanner scanUpToString: @":" intoString: &line]; - if (line != nil) - { - l = [line intValue]; - [scanner scanString: @":" intoString: NULL]; - [scanner scanUpToString: @":" intoString: &bytes]; - - if (bytes != nil) - { - b = [bytes intValue]; - if (l != 0 && b != 0) // if the line & bytes are parsable, then send the notification. - { - NSDictionary *dict = [NSDictionary - dictionaryWithObjectsAndKeys: - file, @"file", line, @"line", nil]; - NSString *statusString = [NSString stringWithFormat: @"Stopped, %@:%@",file,line]; - - [debugger setStatus: statusString]; - [NOTIFICATION_CENTER - postNotificationName: PCProjectBreakpointNotification - object: dict]; - [[self window] makeKeyAndOrderFront: self]; - printLine = NO; - } - } - } - } - - // Check certain status messages from GDB and set the state correctly. - range = [str rangeOfString: @"Starting program:"]; - if (range.location != NSNotFound) - { - [debugger setStatus: @"Running..."]; - } - - // Check certain status messages from GDB and set the state correctly. - range = [str rangeOfString: @"Program received signal"]; - if (range.location != NSNotFound) - { - [debugger setStatus: @"Stopped"]; - } - - // Check certain status messages from GDB and set the state correctly. - range = [str rangeOfString: @"Terminated"]; - if (range.location != NSNotFound) - { - [debugger setStatus: @"Terminated"]; - } - - // Check certain status messages from GDB and set the state correctly. - range = [str rangeOfString: @"Program exited"]; - if (range.location != NSNotFound) - { - [debugger setStatus: @"Terminated"]; - } - - // FIXME: Filter this error, until we find a better way to deal with it. - range = [str rangeOfString: @"[tcsetpgrp failed in terminal_inferior:"]; - if (range.location != NSNotFound) - { - printLine = NO; - } - - // if the line is not filtered, print it... - if(printLine) - { - [viewDelegate logString: str newLine: newLine withColor:[viewDelegate debuggerColor]]; - } + [viewDelegate logString: str newLine: newLine withColor:[viewDelegate debuggerColor]]; } - (void) setCurrentFile: (NSString *)fileName @@ -155,7 +70,6 @@ { return currentFile; } - - (void) terminate { Modified: apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m URL: http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m?rev=39719&r1=39718&r2=39719&view=diff ============================================================================== --- apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m (original) +++ apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m Wed May 4 00:01:00 2016 @@ -142,6 +142,65 @@ [tView setNeedsDisplay:YES]; } +- (BOOL) parseStringLine: (NSString *)stringInput +{ + BOOL found = NO; + NSScanner *stringScanner = [NSScanner scannerWithString: stringInput]; + NSString *command = NULL; + [stringScanner scanString: @"=" intoString: &command]; + if(command != nil) + { + NSString *dictionaryName = NULL; + found = YES; + + [stringScanner scanUpToString: @"," intoString: &dictionaryName]; + + if([dictionaryName isEqualToString: @"thread-group-started"]) + { + NSLog(@"%@",dictionaryName); + } + + if(dictionaryName != nil) + { + NSString *key = NULL; + NSString *value = NULL; + + while([stringScanner isAtEnd] == NO) + { + [stringScanner scanString: @"," intoString: NULL]; + [stringScanner scanUpToString: @"=" intoString: &key]; + [stringScanner scanString: @"=" intoString: NULL]; + [stringScanner scanString: @"\"" intoString: NULL]; + [stringScanner scanUpToString: @"\"" intoString: &value]; + [stringScanner scanString: @"\"" intoString: NULL]; + + if([key isEqualToString:@"pid"] && + [dictionaryName isEqualToString: @"thread-group-started"]) + { + [debugger setSubProcessId: [value intValue]]; + } + } + } + } + + return found; +} + +- (void) parseString: (NSString *)inputString +{ + NSArray *components = [inputString componentsSeparatedByString:@"\n"]; + NSEnumerator *en = [components objectEnumerator]; + NSString *item = nil; + + while((item = [en nextObject]) != nil) + { + BOOL command = [self parseStringLine: item]; + if(!command) + { + [self logString: item newLine: YES withColor:debuggerColor]; + } + } +} /** * Log standard out. @@ -157,7 +216,12 @@ dataString = [[NSString alloc] initWithData:data encoding:[NSString defaultCStringEncoding]]; - [self logString: dataString newLine: NO withColor:debuggerColor]; + + // if( ! + [self parseString: dataString]; // ) + // { + // [self logString: dataString newLine: NO withColor:debuggerColor]; + // } RELEASE(dataString); } @@ -188,7 +252,11 @@ dataString = [[NSString alloc] initWithData:data encoding:[NSString defaultCStringEncoding]]; - [self logString: dataString newLine: NO withColor:errorColor]; + + // if(![self parseString: dataString]) + { + [self logString: dataString newLine: NO withColor:errorColor]; + } RELEASE(dataString); } _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs