diff --git a/ChangeLog b/ChangeLog index 04e32f7..6099032 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-05-03 18:00-EDT Gregory John Casamento + + * 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 * Modules/Debuggers/ProjectCenter/PCDebugger.h diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 8d1f8a7..e82bf1e 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -163,7 +163,7 @@ static NSImage *downImage = nil; { [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]; } diff --git a/Modules/Debuggers/ProjectCenter/PCDebuggerView.m b/Modules/Debuggers/ProjectCenter/PCDebuggerView.m index 6cdea58..2e2000c 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebuggerView.m +++ b/Modules/Debuggers/ProjectCenter/PCDebuggerView.m @@ -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 @@ -156,7 +71,6 @@ return currentFile; } - - (void) terminate { [viewDelegate terminate]; diff --git a/Modules/Debuggers/ProjectCenter/PipeDelegate.m b/Modules/Debuggers/ProjectCenter/PipeDelegate.m index 622add7..eb0d272 100644 --- a/Modules/Debuggers/ProjectCenter/PipeDelegate.m +++ b/Modules/Debuggers/ProjectCenter/PipeDelegate.m @@ -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); }