From b51d08420b460b7cc09a11036beddd08fe4cbe3f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Nov 2008 22:18:37 -0500 Subject: [PATCH] Remove all of the old stack system * Source/DebuggerController.h: Remove stackController2 and stack ivars * Source/DebuggerController.m: (validateUserInterfaceItem:): Update to use stackController.stack for -[count] (resetDisplays): Remove the call to stackController2 (setStack): Removed (stepIn:): Call -[updateStackViewer] (stepOut:): ditto (stepOver:): ditto (updateSourceViewer): Use our new stackController (updateStackViewer): New method * Source/GDBpConnection.m: (updateStackTraceAndRegisters): Remove the block of code that used to update the stack --- Source/DebuggerController.h | 4 -- Source/DebuggerController.m | 86 ++++++++++++++++--------------------- Source/GDBpConnection.m | 20 +-------- 3 files changed, 37 insertions(+), 73 deletions(-) diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index eef4367..7cdd097 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -27,9 +27,6 @@ StackController *stackController; IBOutlet NSArrayController *stackArrayController; - IBOutlet NSArrayController *stackController2; - NSArray *stack; - IBOutlet NSTreeController *registerController; IBOutlet NSOutlineView *registerView; NSMutableSet *expandedRegisters; @@ -53,7 +50,6 @@ - (void)setStatus:(NSString *)aStatus; - (void)setError:(NSString *)anError; -- (void)setStack:(NSArray *)node; - (void)setRegister:(NSXMLDocument *)reg; - (IBAction)run:(id)sender; diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index df1d27a..60c695f 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -22,6 +22,7 @@ @interface DebuggerController (Private) - (void)updateSourceViewer; +- (void)updateStackViewer; @end @implementation DebuggerController @@ -87,7 +88,7 @@ SEL action = [anItem action]; if (action == @selector(stepOut:)) - return ([connection isConnected] && [stack count] > 1); + return ([connection isConnected] && [stackController.stack count] > 1); else if (action == @selector(stepIn:) || action == @selector(stepOver:) || action == @selector(run:)) return [connection isConnected]; @@ -100,7 +101,6 @@ - (void)resetDisplays { [registerController setContent:nil]; - [stackController2 setContent:nil]; [[sourceViewer textView] setString:@""]; } @@ -143,24 +143,6 @@ [errormsg setHidden:NO]; } -/** - * Sets the root node element of the stacktrace - */ -- (void)setStack:(NSArray *)node -{ - stack = node; - - if ([stack count] > 1) - { - [stepOutButton setEnabled:YES]; - } - [stepInButton setEnabled:YES]; - [stepOverButton setEnabled:YES]; - [runButton setEnabled:YES]; - - [self updateSourceViewer]; -} - /** * Sets the stack root element so that the NSOutlineView can display it */ @@ -211,8 +193,7 @@ if ([frame isShiftedFrame:[stackController peek]]) [stackController pop]; [stackController push:frame]; - [stackArrayController rearrangeObjects]; - NSLog(@"stack = %@", stackController.stack); + [self updateStackViewer]; } /** @@ -224,8 +205,7 @@ [stackController pop]; // frame we were out of [stackController pop]; // frame we are returning to [stackController push:frame]; - [stackArrayController rearrangeObjects]; - NSLog(@"stack = %@", stackController.stack); + [self updateStackViewer]; } /** @@ -234,11 +214,9 @@ - (IBAction)stepOver:(id)sender { StackFrame *frame = [connection stepOver]; - [stackController pop]; [stackController push:frame]; - [stackArrayController rearrangeObjects]; - NSLog(@"stack = %@", stackController.stack); + [self updateStackViewer]; } /** @@ -250,27 +228,39 @@ [self updateSourceViewer]; } +/** + * Called whenver an item is expanded. This allows us to determine if we need to fetch deeper + */ +- (void)outlineViewItemDidExpand:(NSNotification *)notif +{ + NSTreeNode *node = [[notif userInfo] objectForKey:@"NSObject"]; + [expandedRegisters addObject:[[node representedObject] fullname]]; +} + +/** + * Called when an item was collapsed. This allows us to remove it from the list of expanded items + */ +- (void)outlineViewItemDidCollapse:(NSNotification *)notif +{ + [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] representedObject] fullname]]; +} + +#pragma mark Private + /** * Does the actual updating of the source viewer by reading in the file */ - (void)updateSourceViewer { - id selectedLevel = [[stackController2 selection] valueForKey:@"level"]; - if (selectedLevel == NSNoSelectionMarker) + id selection = [stackArrayController selection]; + if ([selection valueForKey:@"filename"] == NSNoSelectionMarker) { [[sourceViewer textView] setString:@""]; return; } - int selection = [selectedLevel intValue]; - - if ([stack count] < 1) - { - NSLog(@"huh... we don't have a stack"); - return; - } // get the filename and then set the text - NSString *filename = [[stack objectAtIndex:selection] valueForKey:@"filename"]; + NSString *filename = [selection valueForKey:@"filename"]; filename = [[NSURL URLWithString:filename] path]; if ([filename isEqualToString:@""]) { @@ -279,7 +269,7 @@ [sourceViewer setFile:filename]; - int line = [[[stack objectAtIndex:selection] valueForKey:@"lineno"] intValue]; + int line = [[selection valueForKey:@"lineNumber"] intValue]; [sourceViewer setMarkedLine:line]; [sourceViewer scrollToLine:line]; @@ -288,20 +278,16 @@ } /** - * Called whenver an item is expanded. This allows us to determine if we need to fetch deeper - */ -- (void)outlineViewItemDidExpand:(NSNotification *)notif -{ - NSTreeNode *node = [[notif userInfo] objectForKey:@"NSObject"]; - [expandedRegisters addObject:[[node representedObject] fullname]]; -} - -/** - * Called when an item was collapsed. This allows us to remove it from the list of expanded items + * Does some house keeping to the stack viewer */ -- (void)outlineViewItemDidCollapse:(NSNotification *)notif +- (void)updateStackViewer { - [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] representedObject] fullname]]; + [stackArrayController rearrangeObjects]; + [stackArrayController setSelectionIndex:0]; + + [stepInButton setEnabled:YES]; + [stepOverButton setEnabled:YES]; + [runButton setEnabled:YES]; } #pragma mark BSSourceView Delegate diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m index ea78ee4..c68baca 100644 --- a/Source/GDBpConnection.m +++ b/Source/GDBpConnection.m @@ -216,25 +216,7 @@ * level one. If a user then tries to expand past level one... TOOD: HOLY CRAP WHAT DO WE DO PAST LEVEL 1? */ - (void)updateStackTraceAndRegisters -{ - // 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]; - } - [windowController setStack:stack]; - +{ // do the registers [socket send:[self createCommand:@"context_get"]]; [windowController setRegister:[self processData:[socket receive]]]; -- 2.43.5