Fix the run command by having it obliterate the current stack and set a new one
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 4 Apr 2009 20:25:57 +0000 (16:25 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 10 May 2009 05:48:41 +0000 (01:48 -0400)
* Source/GDBpConnection.h+m:
(run): Now returns an NSArray of the new stack frames
(createStackFrame): Sets the StackFrame's index to be the depth
* Source/DebuggerController.m:
(run:): Set the new stack and refresh the source viewer

CHANGES
Source/DebuggerController.m
Source/GDBpConnection.h
Source/GDBpConnection.m

diff --git a/CHANGES b/CHANGES
index 300ff900518f90a069f35e507c3f8d0d84b41547..065e88e12ba3da096073dd92a8195191ab5ecc49 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,7 @@ MacGDBp                                                               CHANGE LOG
 retained
 - Fix: #160  The code pane could be unpopulated after the debugging the same
 script a subsequent time
+- Fix: After using the run command, the stack will now be properly updated
 
 
 1.2.1
index e79837e2b1871231fdb1ac2539aefe3c0f539de9..ae4d434eb649711d673b307a9b9db0602b21dc91 100644 (file)
  */
 - (IBAction)run:(id)sender
 {
-       StackFrame *frame = [connection run];
-       [stackController pop];
+       NSArray *frames = [connection run];
        
-       if ([connection isConnected] && frame != nil)
+       if ([connection isConnected] && frames != nil)
        {
-               [stackController push:frame];
+               [stackController.stack removeAllObjects];
+               [stackController.stack addObjectsFromArray:frames];
                [self updateStackViewer];
+               [self updateSourceViewer];
        }
 }
 
index 8684e9e913f3afd4ba6112907ac4d03449e8442f..f334900b9fd866c296aaa27c822f4a558a70faa2 100644 (file)
@@ -49,7 +49,7 @@ extern NSString *kErrorOccurredNotif;
 
 // communication
 - (void)reconnect;
-- (StackFrame *)run;
+- (NSArray *)run;
 - (StackFrame *)stepIn;
 - (StackFrame *)stepOut;
 - (StackFrame *)stepOver;
index 47295047a02c29582ced8d06be5c8dc12cc5a00c..3a8425a0ea7967fadd5c730bd0eb29b2ece15bca 100644 (file)
@@ -150,9 +150,9 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
 }
 
 /**
- * Tells the debugger to continue running the script
+ * Tells the debugger to continue running the script. Returns an NSArray of the new stack
  */
-- (StackFrame *)run
+- (NSArray *)run
 {
        [socket send:[self createCommand:@"run"]];
        [socket receive];
@@ -162,7 +162,20 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
        if (!connected)
                return nil;
        
-       return [self createCurrentStackFrame];
+       // get the total stack depth
+       [socket send:[self createCommand:@"stack_depth"]];
+       NSXMLDocument *doc = [self processData:[socket receive]];
+       int depth = [[[[doc rootElement] attributeForName:@"depth"] stringValue] intValue];
+       
+       // get all stack frames
+       NSMutableArray *stack = [NSMutableArray arrayWithCapacity:depth];
+       for (int i = 0; i < depth; i++)
+       {
+               StackFrame *frame = [self createStackFrame:i];
+               [stack insertObject:frame atIndex:i];
+       }
+       
+       return stack;
 }
 
 /**
@@ -353,7 +366,7 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
        
        // create stack frame
        StackFrame *frame = [[StackFrame alloc]
-               initWithIndex:0
+               initWithIndex:stackDepth
                withFilename:filename
                withSource:source
                atLine:[[[xmlframe attributeForName:@"lineno"] stringValue] intValue]