@interface DebuggerController (Private)
- (void)updateSourceViewer;
+- (void)updateStackViewer;
@end
@implementation DebuggerController
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];
- (void)resetDisplays
{
[registerController setContent:nil];
- [stackController2 setContent:nil];
[[sourceViewer textView] setString:@""];
}
[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
*/
if ([frame isShiftedFrame:[stackController peek]])
[stackController pop];
[stackController push:frame];
- [stackArrayController rearrangeObjects];
- NSLog(@"stack = %@", stackController.stack);
+ [self updateStackViewer];
}
/**
[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];
}
/**
- (IBAction)stepOver:(id)sender
{
StackFrame *frame = [connection stepOver];
-
[stackController pop];
[stackController push:frame];
- [stackArrayController rearrangeObjects];
- NSLog(@"stack = %@", stackController.stack);
+ [self updateStackViewer];
}
/**
[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:@""])
{
[sourceViewer setFile:filename];
- int line = [[[stack objectAtIndex:selection] valueForKey:@"lineno"] intValue];
+ int line = [[selection valueForKey:@"lineNumber"] intValue];
[sourceViewer setMarkedLine:line];
[sourceViewer scrollToLine:line];
}
/**
- * 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
* 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]]];