Parse pid from MI output.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@39719 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2016-05-03 22:01:00 +00:00
parent 21ddb6e18a
commit 13412a4318
4 changed files with 80 additions and 90 deletions

View file

@ -1,3 +1,11 @@
2016-05-03 18:00-EDT Gregory John Casamento <greg.casamento@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 <rm@gnu.org>
* Modules/Debuggers/ProjectCenter/PCDebugger.h

View file

@ -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];
}

View file

@ -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];

View file

@ -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);
}