Add skeleton to handle breakpoints, add breakpoint types

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@40114 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Riccardo Mottola 2016-09-29 08:58:57 +00:00
parent 4e2edf5d4f
commit 98d05ffe44
5 changed files with 100 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2016-09-29 Riccardo Mottola <rm@gnu.org>
* 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 <greg.casamento@gmail.com>
* Modules/Debuggers/ProjectCenter/PCDebuggerView.m: Add code to

View file

@ -27,6 +27,14 @@
#import <Protocols/CodeDebugger.h>
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 <CodeDebugger>
{
id debuggerView;
@ -36,6 +44,7 @@
NSString *debuggerPath;
int subProcessId;
float gdbVersion;
NSMutableArray *breakpoints;
}
- (void) setStatus: (NSString *) status;

View file

@ -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 <PCDebuggerViewDelegateProtocol> 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

View file

@ -49,6 +49,8 @@
newLine:(BOOL)newLine
withColor:(NSColor *)color;
- (void) setBreakpoints:(NSArray *)breakpoints;
- (void) terminate;
- (void) interrupt;

View file

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