diff --git a/ChangeLog b/ChangeLog index b4b23c5..be3157a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-09-29 Riccardo Mottola + + * Modules/Debuggers/ProjectCenter/PCDebugger.h + * Modules/Debuggers/ProjectCenter/PCDebugger.m + * Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h + * Modules/Debuggers/ProjectCenter/PipeDelegate.m + Add skeleton to handle breakpoints, add breakpoint types. + 2016-06-06 11:47-EDT Gregory John Casamento * Modules/Debuggers/ProjectCenter/PCDebuggerView.m: Add code to diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.h b/Modules/Debuggers/ProjectCenter/PCDebugger.h index c809796..f693ccd 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.h +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.h @@ -27,6 +27,14 @@ #import +extern const NSString *PCBreakTypeKey; +extern NSString *PCBreakTypeByLine; +extern NSString *PCBreakTypeMethod; + +extern const NSString *PCBreakMethod; +extern const NSString *PCBreakFilename; +extern const NSString *PCBreakLineNumber; + @interface PCDebugger : NSObject { id debuggerView; @@ -36,6 +44,7 @@ NSString *debuggerPath; int subProcessId; float gdbVersion; + NSMutableArray *breakpoints; } - (void) setStatus: (NSString *) status; diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 1c83460..683e7b5 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -53,6 +53,13 @@ static NSImage *stepOutImage = nil; static NSImage *upImage = nil; static NSImage *downImage = nil; +const NSString *PCBreakTypeKey = @"BreakType"; +NSString *PCBreakTypeByLine = @"BreakTypeLine"; +NSString *PCBreakTypeMethod = @"BreakTypeMethod"; +const NSString *PCBreakMethod = @"BreakMethod"; +const NSString *PCBreakFilename = @"BreakFilename"; +const NSString *PCBreakLineNumber = @"BreakLineNumber"; + @implementation PCDebugger + (void) initialize { @@ -131,6 +138,7 @@ static NSImage *downImage = nil; return font; } + - (id) init { if((self = [super init]) != nil) @@ -151,6 +159,8 @@ static NSImage *downImage = nil; subProcessId = 0; gdbVersion = 0.0; + + breakpoints = nil; } return self; } @@ -176,7 +186,29 @@ static NSImage *downImage = nil; inCurrentDirectory: [executablePath stringByDeletingLastPathComponent] withArguments: [[NSArray alloc] initWithObjects: @"--interpreter=mi", @"-f", executablePath, nil] logStandardError: YES]; -} + + // is this really the best place? + [self initBreakpoints]; +} + +- (void) initBreakpoints +{ + id viewDelegate; + + breakpoints = [[NSMutableArray alloc] init]; + NSDictionary *dP; + NSLog(@"initing breakpoints"); + + /* CRUDE EXAMPLES * TODO FIXME * + dP = [NSDictionary dictionaryWithObjectsAndKeys: PCBreakTypeMethod, PCBreakTypeKey, @"[NSException raise]", PCBreakMethod, nil]; + // [breakpoints addObject:dP]; + dP = [NSDictionary dictionaryWithObjectsAndKeys: PCBreakTypeByLine, PCBreakTypeKey, @"AppController.m", PCBreakFilename, [NSNumber numberWithInt:100], PCBreakLineNumber, nil]; + [breakpoints addObject:dP]; + */ + + viewDelegate = [debuggerView delegate]; + [viewDelegate setBreakpoints:breakpoints]; +} - (void) awakeFromNib { @@ -345,7 +377,7 @@ static NSImage *downImage = nil; - (void) dealloc { - [debuggerWindow close]; + [breakpoints release]; [super dealloc]; } @end diff --git a/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h b/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h index 3cefdab..f2fe08e 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h +++ b/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h @@ -49,6 +49,8 @@ newLine:(BOOL)newLine withColor:(NSColor *)color; +- (void) setBreakpoints:(NSArray *)breakpoints; + - (void) terminate; - (void) interrupt; diff --git a/Modules/Debuggers/ProjectCenter/PipeDelegate.m b/Modules/Debuggers/ProjectCenter/PipeDelegate.m index 639703f..11dae9c 100644 --- a/Modules/Debuggers/ProjectCenter/PipeDelegate.m +++ b/Modules/Debuggers/ProjectCenter/PipeDelegate.m @@ -641,4 +641,51 @@ else NSLog(@"characters: |%@|", chars); } + +- (void) setBreakpoints:(NSArray *)breakpoints +{ + NSDictionary *bp; + NSEnumerator *e; + + // TODO + e = [breakpoints objectEnumerator]; + while ((bp = [e nextObject])) + { + NSString *bpType; + NSString *bpString; + + bpType = [bp objectForKey:PCBreakTypeKey]; + bpString = nil; + if ([bpType isEqualToString:PCBreakTypeByLine]) + { + NSString *fileName; + NSNumber *lineNumber; + + fileName = [bp objectForKey:PCBreakFilename]; + lineNumber = [bp objectForKey:PCBreakLineNumber]; + bpString = [NSString stringWithFormat:@"%@:%@", fileName, lineNumber]; + } + else if ([bpType isEqualToString:PCBreakTypeMethod]) + { + NSString *methodName; + + methodName = [bp objectForKey:PCBreakMethod]; + bpString = methodName; + } + else + { + NSLog(@"Unknown breakpoint type: %@", bpType); + } + if (bpString) + { + NSString *command; + + /* TODO: split into a separate insert function */ + command = [NSString stringWithFormat:@"-break-insert -f %@", bpString]; + NSLog(@"gdb mi command is: %@", command); + [self putString: command]; + } + } +} + @end