From 25b6587ba875e3b7976f68af379762bf1df4411d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 12 Jun 2008 09:51:57 -0400 Subject: [PATCH] Fixing a bug where if the register depth was too deep, more properties would not be fetched/inserted correctly * Source/AppDelegate.m+h: Add and synthesize props for debugger and breakpoint ivars * Source/DebuggerConnection.m+h: (getProperty:forNode:): Renamed [getProperty:] and now return an NSArray rather than attaching to a node * Source/DebuggerWindowController.m+h: (addChildren:toNode:): Removed (outlineViewItemDidExpand:): Don't have to do extra fetch work here because it will now be done in the model * Source/NSXMLElementAdditions.m+h: (subnodes): New method that does the same thing as [children] but intelligently fetches more depth * English.lproj/Debugger.xib: Tell the regiser NSTreeController to use [subnodes] instead of [children] --- English.lproj/Debugger.xib | 10 +++++----- Source/AppDelegate.h | 3 +++ Source/AppDelegate.m | 2 ++ Source/DebuggerConnection.h | 2 +- Source/DebuggerConnection.m | 4 ++-- Source/DebuggerWindowController.h | 2 -- Source/DebuggerWindowController.m | 27 --------------------------- Source/NSXMLElementAdditions.h | 1 + Source/NSXMLElementAdditions.m | 14 ++++++++++++++ 9 files changed, 28 insertions(+), 37 deletions(-) diff --git a/English.lproj/Debugger.xib b/English.lproj/Debugger.xib index b998d6e..75d9ab6 100644 --- a/English.lproj/Debugger.xib +++ b/English.lproj/Debugger.xib @@ -700,7 +700,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ YES - 3.000000e+01 + 1.000000e+01 1.000000e+01 3.000000e+01 @@ -728,7 +728,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - 1.060000e+02 + 1.120000e+02 8.000000e+00 1.000000e+03 @@ -753,7 +753,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - 2.600000e+01 + 3.300000e+01 2.600000e+01 1.000000e+03 @@ -778,7 +778,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - 2.080000e+02 + 2.150000e+02 5.006250e+01 1.000000e+03 @@ -922,7 +922,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ YES YES YES - children + subnodes isLeaf diff --git a/Source/AppDelegate.h b/Source/AppDelegate.h index 7b39d47..5cb7b4d 100644 --- a/Source/AppDelegate.h +++ b/Source/AppDelegate.h @@ -24,6 +24,9 @@ BreakpointWindowController *breakpoint; } +@property(readonly) DebuggerWindowController *debugger; +@property(readonly) BreakpointWindowController *breakpoint; + - (IBAction)showDebuggerWindow:(id)sender; - (IBAction)showBreakpointWindow:(id)sender; diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index c882418..f870804 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -18,6 +18,8 @@ @implementation AppDelegate +@synthesize debugger, breakpoint; + /** * Initializes */ diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index d28d8fb..61b1a95 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -54,6 +54,6 @@ - (void)updateStackTraceAndRegisters; // helpers -- (void)getProperty:(NSString *)property forNode:(NSTreeNode *)elm; +- (NSArray *)getProperty:(NSString *)property; @end diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 8ac041b..f2e3499 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -214,7 +214,7 @@ * 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. */ -- (void)getProperty:(NSString *)property forNode:(NSTreeNode *)node +- (NSArray *)getProperty:(NSString *)property { [socket send:[self createCommand:[NSString stringWithFormat:@"property_get -n \"%@\"", property]]]; @@ -232,7 +232,7 @@ NSXMLElement *parent = (NSXMLElement *)[[doc rootElement] childAtIndex:0]; NSArray *children = [parent children]; [parent setChildren:nil]; - [windowController addChildren:children toNode:node]; + return children; } #pragma mark Breakpoints diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 50709f9..29f1f84 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -53,8 +53,6 @@ - (void)setStack:(NSArray *)node; - (void)setRegister:(NSXMLDocument *)reg; -- (void)addChildren:(NSArray *)children toNode:(NSTreeNode *)node; - - (IBAction)run:(id)sender; - (IBAction)stepIn:(id)sender; - (IBAction)stepOut:(id)sender; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index ce1dcac..c2e1533 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -21,9 +21,7 @@ #import "BreakpointManager.h" @interface DebuggerWindowController (Private) - - (void)updateSourceViewer; - @end @implementation DebuggerWindowController @@ -246,13 +244,6 @@ - (void)outlineViewItemDidExpand:(NSNotification *)notif { NSTreeNode *node = [[notif userInfo] objectForKey:@"NSObject"]; - - // we're not a leaf but have no children. this must be beyond our depth, so go make us deeper - if (![node isLeaf] && [[node childNodes] count] < 1) - { - [connection getProperty:[[node representedObject] fullname] forNode:node]; - } - [expandedRegisters addObject:[[node representedObject] fullname]]; } @@ -264,24 +255,6 @@ [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] representedObject] fullname]]; } -/** - * Updates the register view by reinserting a given node back into the outline view - */ -- (void)addChildren:(NSArray *)children toNode:(NSTreeNode *)node -{ - NSMutableArray *childNodes = [node mutableChildNodes]; - [childNodes removeAllObjects]; - - for (NSXMLNode *child in children) - { - NSTreeNode *newChild = [[NSTreeNode alloc] initWithRepresentedObject:child]; - [childNodes addObject:newChild]; - [newChild release]; - } - - [registerController rearrangeObjects]; -} - #pragma mark BSSourceView Delegate /** diff --git a/Source/NSXMLElementAdditions.h b/Source/NSXMLElementAdditions.h index 8db1695..a8639c7 100644 --- a/Source/NSXMLElementAdditions.h +++ b/Source/NSXMLElementAdditions.h @@ -23,5 +23,6 @@ - (BOOL)isLeaf; - (NSString *)value; - (NSString *)type; +- (NSArray *)subnodes; @end diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index 9820326..1bd5f37 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -16,6 +16,7 @@ #import #include "base64.h" +#import "AppDelegate.h" @implementation NSXMLElement (NSXMLElementAdditions) @@ -43,6 +44,19 @@ return ([[[self attributeForName:@"children"] stringValue] intValue] == 0); } +/** + * Override children so we can fetch more depth as needed + */ +- (NSArray *)subnodes +{ + NSArray *children = [self children]; + if (![self isLeaf] && [children count] < 1) + { + return [[[(AppDelegate *)[NSApp delegate] debugger] connection] getProperty:[self fullname]]; + } + return children; +} + /** * Returns the value of the property */ -- 2.22.5