Author: gcasa
Date: Wed May 4 01:41:18 2016
New Revision: 39720
URL: http://svn.gna.org/viewcvs/gnustep?rev=39720&view=rev
Log:
Parser code for MI output
Modified:
apps/projectcenter/trunk/ChangeLog
apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.h
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=39720&r1=39719&r2=39720&view=diff
==============================================================================
--- apps/projectcenter/trunk/ChangeLog (original)
+++ apps/projectcenter/trunk/ChangeLog Wed May 4 01:41:18 2016
@@ -1,3 +1,10 @@
+2016-05-03 19:40-EDT Gregory John Casamento <[email protected]>
+
+ * Modules/Debuggers/ProjectCenter/PipeDelegate.h
+ * Modules/Debuggers/ProjectCenter/PipeDelegate.m: Add parsers
+ to handle output from various types of MI data. Code to handle
+ each individual case is being written.
+
2016-05-03 18:00-EDT Gregory John Casamento <[email protected]>
* Modules/Debuggers/ProjectCenter/PCDebugger.m
Modified:
apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.h
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.h?rev=39720&r1=39719&r2=39720&view=diff
==============================================================================
--- apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.h
(original)
+++ apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.h
Wed May 4 01:41:18 2016
@@ -26,6 +26,21 @@
#import "PCDebuggerViewDelegateProtocol.h"
+typedef enum PCDebuggerOutputType_enum {
+ PCDBNotFoundRecord = 0,
+ PCDBPromptRecord,
+ PCDBResultRecord,
+ PCDBConsoleStreamRecord,
+ PCDBTargetStreamRecord,
+ PCDBDebugStreamRecord,
+ PCDBAsyncStatusRecord,
+ PCDBAsyncInfoRecord,
+ PCDBBreakpointRecord,
+ PCDBFrameRecord,
+ PCDBThreadRecord,
+ PCDBAdaExceptionRecord
+} PCDebuggerOutputTypes;
+
@interface PipeDelegate : NSObject <PCDebuggerViewDelegateProtocol>
{
PCDebugger *debugger;
@@ -39,6 +54,7 @@
NSColor *debuggerColor;
NSColor *messageColor;
NSColor *errorColor;
+ NSColor *promptColor;
}
- (void)logStdOut:(NSNotification *)aNotif;
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=39720&r1=39719&r2=39720&view=diff
==============================================================================
--- apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m
(original)
+++ apps/projectcenter/trunk/Modules/Debuggers/ProjectCenter/PipeDelegate.m
Wed May 4 01:41:18 2016
@@ -42,7 +42,6 @@
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
#endif
-
@implementation PipeDelegate
@@ -54,6 +53,7 @@
debuggerColor = [[NSColor blackColor] retain];
messageColor = [[NSColor brownColor] retain];
errorColor = [[NSColor redColor] retain];
+ promptColor = [[NSColor purpleColor] retain];
}
return self;
}
@@ -118,6 +118,7 @@
NSMutableDictionary *textAttributes;
NSAttributedString *attrStr;
+
if (newLine)
{
str = [str stringByAppendingString:@"\n"];
@@ -142,13 +143,20 @@
[tView setNeedsDisplay:YES];
}
-- (BOOL) parseStringLine: (NSString *)stringInput
+- (PCDebuggerOutputTypes) parseStringLine: (NSString *)stringInput
{
BOOL found = NO;
NSScanner *stringScanner = [NSScanner scannerWithString: stringInput];
- NSString *command = NULL;
- [stringScanner scanString: @"=" intoString: &command];
- if(command != nil)
+ NSString *prefix = NULL;
+
+ [stringScanner scanString: @"(gdb)" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBPromptRecord;
+ }
+
+ [stringScanner scanString: @"=" intoString: &prefix];
+ if(prefix != nil)
{
NSString *dictionaryName = NULL;
found = YES;
@@ -181,9 +189,64 @@
}
}
}
- }
-
- return found;
+ return PCDBAsyncInfoRecord;
+ }
+
+ [stringScanner scanString: @"*" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBAsyncStatusRecord;
+ }
+
+ [stringScanner scanString: @"<-" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBBreakpointRecord;
+ }
+
+ [stringScanner scanString: @"->" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBBreakpointRecord;
+ }
+
+ [stringScanner scanString: @"~" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBConsoleStreamRecord;
+ }
+
+ [stringScanner scanString: @"@" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBTargetStreamRecord;
+ }
+
+ [stringScanner scanString: @"&" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBDebugStreamRecord;
+ }
+
+ [stringScanner scanString: @"^" intoString: &prefix];
+ if(prefix != nil)
+ {
+ return PCDBResultRecord;
+ }
+
+ return PCDBNotFoundRecord;
+}
+
+- (NSString *)unescapeOutputRecord: (NSString *)recordString
+{
+ NSString *unescapedString = [recordString copy];
+
+ unescapedString = [unescapedString stringByReplacingOccurrencesOfString:
@"~\"" withString: @""];
+ unescapedString = [unescapedString substringToIndex: [unescapedString
length] - 1];
+ unescapedString = [unescapedString stringByReplacingOccurrencesOfString:
@"\"" withString: @"\""];
+ unescapedString = [unescapedString stringByReplacingOccurrencesOfString:
@"\\n" withString: @"\n"];
+
+ return unescapedString;
}
- (void) parseString: (NSString *)inputString
@@ -191,15 +254,32 @@
NSArray *components = [inputString componentsSeparatedByString:@"\n"];
NSEnumerator *en = [components objectEnumerator];
NSString *item = nil;
-
+
while((item = [en nextObject]) != nil)
{
- BOOL command = [self parseStringLine: item];
- if(!command)
+ PCDebuggerOutputTypes outtype = [self parseStringLine: item];
+ if(outtype == PCDBConsoleStreamRecord ||
+ outtype == PCDBTargetStreamRecord)
{
- [self logString: item newLine: YES withColor:debuggerColor];
+ NSString *unescapedString = [self unescapeOutputRecord: item];
+ [self logString: unescapedString newLine: NO withColor:debuggerColor];
}
- }
+ else if(outtype == PCDBPromptRecord)
+ {
+ [self logString: item newLine: NO withColor:promptColor];
+ }
+ }
+
+ /*
+ stringRange = [inputString rangeOfString: "(gdb)" options: NULL];
+ if(stringRange.location == NSNotFound)
+ {
+ [self logString: inputString newLine: NO withColor:debuggerColor];
+ }
+ else
+ {
+ }
+ */
}
/**
@@ -366,7 +446,7 @@
NSLog(@"Task Terminated Unexpectedly...");
[self logString: @"\n=== Task Terminated Unexpectedly ===\n"
- newLine:YES
+ newLine:NO
withColor:messageColor];
//Clean up after task is terminated
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs