Convert the run command to use the StackFrame system
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Feb 2009 17:40:47 +0000 (12:40 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Feb 2009 17:40:47 +0000 (12:40 -0500)
* Source/GDBpConnection.m+h:
(run): Now returns a StackFrame object
(processData:): Return nil if the given data is nil
(createStackFrame): If we get an empty NSXMLDocument for the stack, return nil
(updateStatus): If the status is nil, the debugger is stopped
* Source/DebuggerController.m:
(run): Use the stack frame
* Source/SocketWrapper.m:
(receive): If the call to recv() returns -1 (error), return nil string

Source/DebuggerController.m
Source/GDBpConnection.h
Source/GDBpConnection.m
Source/SocketWrapper.m

index 2b46df884b958371c8305f78b24685d2543592b6..3af8421b7f31cba1e3578e6c0dec58eb4789f3ca 100644 (file)
  */
 - (IBAction)run:(id)sender
 {
-       [connection run];
+       StackFrame *frame = [connection run];
+       [stackController pop];
+       
+       if ([connection isConnected] && frame != nil)
+       {
+               [stackController push:frame];
+               [self updateStackViewer];
+       }
 }
 
 /**
index 7b930837df5e8ede0a6b36f9eca86cc3f8ae6e52..8684e9e913f3afd4ba6112907ac4d03449e8442f 100644 (file)
@@ -49,7 +49,7 @@ extern NSString *kErrorOccurredNotif;
 
 // communication
 - (void)reconnect;
-- (void)run;
+- (StackFrame *)run;
 - (StackFrame *)stepIn;
 - (StackFrame *)stepOut;
 - (StackFrame *)stepOver;
index 2f9662e87a527a3f840a3056aeb9b33988d74761..c3805c650cc8c52b9fb08028009501740e6c0dc7 100644 (file)
@@ -151,11 +151,17 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
 /**
  * Tells the debugger to continue running the script
  */
-- (void)run
+- (StackFrame *)run
 {
        [socket send:[self createCommand:@"run"]];
        [socket receive];
+       
        [self updateStatus];
+       
+       if (!connected)
+               return nil;
+       
+       return [self createStackFrame];
 }
 
 /**
@@ -272,6 +278,9 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
  */
 - (NSXMLDocument *)processData:(NSString *)data
 {
+       if (data == nil)
+               return nil;
+       
        NSError *parseError = nil;
        NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString:data options:0 error:&parseError];
        if (parseError)
@@ -301,6 +310,9 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
        // get the stack frame
        [socket send:[self createCommand:@"stack_get -d 0"]];
        NSXMLDocument *doc = [self processData:[socket receive]];
+       if (doc == nil)
+               return nil;
+       
        NSXMLElement *xmlframe = [[[doc rootElement] children] objectAtIndex:0];
        
        // get the names of all the contexts
@@ -346,7 +358,7 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification";
        NSXMLDocument *doc = [self processData:[socket receive]];
        self.status = [[[[doc rootElement] attributeForName:@"status"] stringValue] capitalizedString];
        
-       if ([status isEqualToString:@"Stopped"] || [status isEqualToString:@"Stopping"])
+       if (status == nil || [status isEqualToString:@"Stopped"] || [status isEqualToString:@"Stopping"])
        {
                connected = NO;
                [socket close];
index 3f2321d7455034c70c5f5258fe2beaa75d8bf55f..b37f99d769ef92c32d7879a13b834966e7ee1fde 100644 (file)
        // take the received data and put it into an NSData
        NSMutableString *str = [NSMutableString string];
        
+       if (recvd == -1)
+               return nil;
+       
        // strip the length from the packet, and clear the null byte then add it to the NSData
        char packetLength[8];
        memset(packetLength, '\0', sizeof(packetLength));