diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index 59ae3f2..0384c45 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -50,7 +50,7 @@ - (void)setStatus:(NSString *)aStatus; - (void)setError:(NSString *)anError; - (void)setStack:(NSArray *)node; -- (void)setRegister:(NSXMLDocument *)reg; +- (void)setRegister:(NSArray *)reg; - (IBAction)run:(id)sender; - (IBAction)stepIn:(id)sender; diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 417291c..fb1e520 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -160,7 +160,7 @@ /** * Sets the stack root element so that the NSOutlineView can display it */ -- (void)setRegister:(NSXMLDocument *)elm +- (void)setRegister:(NSArray *)elm { // XXX: Doing anything short of this will cause bindings to crash spectacularly for no reason whatsoever, and // in seemingly arbitrary places. The class that crashes is _NSKeyValueObservationInfoCreateByRemoving. @@ -170,7 +170,7 @@ // was the inspiration for this fix (below) but the author says that inserting does not work too well, but // that's okay for us as we just need to replace the entire thing. [registerController setContent:nil]; - [registerController setContent:[[elm rootElement] children]]; + [registerController setContent:elm]; for (int i = 0; i < [registerView numberOfRows]; i++) { diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m index 10fa28a..4fda93d 100644 --- a/Source/GDBpConnection.m +++ b/Source/GDBpConnection.m @@ -20,6 +20,7 @@ @interface GDBpConnection (Private) - (NSString *)createCommand:(NSString *)cmd; - (NSXMLDocument *)processData:(NSString *)data; +- (NSMutableArray *)fromDocToArrayOfDict:(NSXMLDocument *)doc; @end @implementation GDBpConnection @@ -206,25 +207,22 @@ { // do the stack [socket send:[self createCommand:@"stack_get"]]; - NSXMLDocument *doc = [self processData:[socket receive]]; - NSArray *children = [[doc rootElement] children]; - NSMutableArray *stack = [NSMutableArray array]; - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - for (int i = 0; i < [children count]; i++) - { - NSArray *attrs = [[children objectAtIndex:i] attributes]; - for (int j = 0; j < [attrs count]; j++) - { - [dict setValue:[[attrs objectAtIndex:j] stringValue] forKey:[[attrs objectAtIndex:j] name]]; - } - [stack addObject:dict]; - dict = [NSMutableDictionary dictionary]; - } + NSMutableArray *stack = [self fromDocToArrayOfDict: [self processData:[socket receive]]]; [windowController setStack:stack]; - // do the registers - [socket send:[self createCommand:@"context_get"]]; - [windowController setRegister:[self processData:[socket receive]]]; + // get the contexts + [socket send:[self createCommand:@"context_names"]]; + NSMutableArray *contexts = [self fromDocToArrayOfDict: [self processData:[socket receive]]]; + + // get and merge the registers from the contexts + NSMutableArray *content = [NSMutableArray array]; + for (int i = 0; i < [contexts count]; ++i) + { + NSMutableDictionary *context = [contexts objectAtIndex:i]; + [socket send:[self createCommand:[NSString stringWithFormat:@"context_get -c %@", [context valueForKey:@"id"]]]]; + [content addObjectsFromArray: [[[self processData:[socket receive]] rootElement] children]]; + } + [windowController setRegister:content]; } /** @@ -320,4 +318,27 @@ return [doc autorelease]; } +/** + * Helper function to split the NSXMLDocument into an NSMutableArray of NSMutableDictionary + */ +- (NSMutableArray *)fromDocToArrayOfDict:(NSXMLDocument *)doc +{ + NSArray *children = [[doc rootElement] children]; + NSMutableArray *array = [NSMutableArray array]; + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + for (int i = 0; i < [children count]; i++) + { + NSArray *attrs = [[children objectAtIndex:i] attributes]; + for (int j = 0; j < [attrs count]; j++) + { + [dict setValue:[[attrs objectAtIndex:j] stringValue] forKey:[[attrs objectAtIndex:j] name]]; + } + [array addObject:dict]; + dict = [NSMutableDictionary dictionary]; + } + + return array; +} + + @end