From e9690abb50d9d517b274b29bc9221bb5f9043e9b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 22 Nov 2010 07:54:30 -0500 Subject: [PATCH] Update the API for loading properties to just pass around VariableNode pointers, rather than string names. --- Source/DebuggerController.h | 2 +- Source/DebuggerController.m | 7 +++++-- Source/DebuggerProcessor.h | 6 ++++-- Source/DebuggerProcessor.m | 4 ++-- Source/VariableNode.h | 2 ++ Source/VariableNode.m | 6 +++++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index aaaf7d7..b1aaab6 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -66,6 +66,6 @@ - (IBAction)stepOver:(id)sender; - (IBAction)reconnect:(id)sender; -- (void)fetchProperty:(NSString*)property forNode:(VariableNode*)node; +- (void)fetchChildProperties:(VariableNode*)node; @end diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 6ee880e..923ce0f 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -215,9 +215,12 @@ [connection stepOver]; } -- (void)fetchProperty:(NSString*)property forNode:(VariableNode*)node +- (void)fetchChildProperties:(VariableNode*)node { - NSInteger txn = [connection getProperty:property]; + NSArray* selection = [stackArrayController selectedObjects]; + assert([selection count] == 1); + NSInteger depth = [[selection objectAtIndex:0] index]; + NSInteger txn = [connection getChildrenOfProperty:node atDepth:depth]; [pendingProperties_ setObject:node forKey:[NSNumber numberWithInt:txn]]; } diff --git a/Source/DebuggerProcessor.h b/Source/DebuggerProcessor.h index 1059a33..7f6299b 100644 --- a/Source/DebuggerProcessor.h +++ b/Source/DebuggerProcessor.h @@ -21,6 +21,7 @@ #import "StackFrame.h" @protocol DebuggerProcessorDelegate; +@class VariableNode; // The DebuggerProcessor is the communication layer between the application // and the back-end debugger. Clients issue debugger commands via this class, @@ -80,8 +81,9 @@ - (void)removeBreakpoint:(Breakpoint*)bp; // Gets a property by name from the debugger engine. Returns a transaction ID -// which used in the delegate callback. -- (NSInteger)getProperty:(NSString*)property; +// which used in the delegate callback. Properties must be retrieved at a +// certain stack depth. +- (NSInteger)getChildrenOfProperty:(VariableNode*)property atDepth:(NSInteger)depth; // Takes a partially loaded stack frame and fetches the rest of the information. - (void)loadStackFrame:(StackFrame*)frame; diff --git a/Source/DebuggerProcessor.m b/Source/DebuggerProcessor.m index 8af726b..9fc6f7d 100644 --- a/Source/DebuggerProcessor.m +++ b/Source/DebuggerProcessor.m @@ -162,9 +162,9 @@ * Tells the debugger engine to get a specifc property. This also takes in the NSXMLElement * that requested it so that the child can be attached. */ -- (NSInteger)getProperty:(NSString*)property +- (NSInteger)getChildrenOfProperty:(VariableNode*)property atDepth:(NSInteger)depth; { - NSNumber* tx = [connection_ sendCommandWithFormat:@"property_get -n \"%@\"", property]; + NSNumber* tx = [connection_ sendCommandWithFormat:@"property_get -d %d -n %@", depth, [property fullName]]; [self recordCallback:@selector(propertiesReceived:) forTransaction:tx]; return [tx intValue]; } diff --git a/Source/VariableNode.h b/Source/VariableNode.h index 0c97dd2..da5adfb 100644 --- a/Source/VariableNode.h +++ b/Source/VariableNode.h @@ -29,6 +29,7 @@ NSString* value_; NSMutableArray* children_; NSInteger childCount_; + NSString* address_; } @property (readonly, copy) NSString* name; @@ -38,6 +39,7 @@ @property (readonly, copy) NSString* value; @property (readonly, retain) NSArray* children; @property (readonly) NSInteger childCount; +@property (readonly, copy) NSString* address; // Creates and initializes a new VariableNode from the XML response from the // debugger backend. diff --git a/Source/VariableNode.m b/Source/VariableNode.m index 1fdcb58..db3236f 100644 --- a/Source/VariableNode.m +++ b/Source/VariableNode.m @@ -29,6 +29,7 @@ @property (copy) NSString* type; @property (copy) NSString* value; @property (retain) NSMutableArray* children; +@property (copy) NSString* address; @end @@ -43,6 +44,7 @@ @synthesize value = value_; @synthesize children = children_; @synthesize childCount = childCount_; +@synthesize address = address_; - (id)initWithXMLNode:(NSXMLElement*)node { @@ -57,6 +59,7 @@ [self setChildrenFromXMLChildren:[node children]]; } childCount_ = [[[node attributeForName:@"numchildren"] stringValue] integerValue]; + self.address = [[node attributeForName:@"address"] stringValue]; } return self; } @@ -69,6 +72,7 @@ self.type = nil; self.value = nil; self.children = nil; + self.address = nil; [super dealloc]; } @@ -89,7 +93,7 @@ if (![self isLeaf] && [children count] < 1) { // If this node has children but they haven't been loaded from the backend, // request them asynchronously. - [[AppDelegate instance].debugger fetchProperty:self.fullName forNode:self]; + [[AppDelegate instance].debugger fetchChildProperties:self]; } return children; } -- 2.22.5