Lazily load the complete stack frame for anything but the current one.
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 19 Jun 2010 16:26:58 +0000 (12:26 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 19 Jun 2010 16:26:58 +0000 (12:26 -0400)
Source/DebuggerController.m
Source/DebuggerProcessor.h
Source/DebuggerProcessor.m
Source/StackFrame.h
Source/StackFrame.m

index 365401e5d7e5ddfba7a572897d674ef1684faccf..3fa729dd7e91d9c242db1c282de323728b04a47d 100644 (file)
        if ([selection count] > 1)
                NSLog(@"INVALID SELECTION");
        StackFrame* frame = [selection objectAtIndex:0];
-       
+
+       if (!frame.loaded) {
+               [connection loadStackFrame:frame];
+               return;
+       }
+
        // Get the filename.
        NSString* filename = [[NSURL URLWithString:frame.filename] path];
        if ([filename isEqualToString:@""])
index f567af39c8cd0b88ab754a97aa3033cfc19ee0f0..bc0acf55b61b0a85fde85fcb3195ca337a842663 100644 (file)
@@ -82,6 +82,9 @@
 // which used in the delegate callback.
 - (NSInteger)getProperty:(NSString*)property;
 
+// Takes a partially loaded stack frame and fetches the rest of the information.
+- (void)loadStackFrame:(StackFrame*)frame;
+
 @end
 
 // Delegate ////////////////////////////////////////////////////////////////////
 - (void)newStackFrame:(StackFrame*)frame;
 
 // Tells the debugger that new source is available for the given frame.
+// TODO: rename to |-frameUpdated:|.
 - (void)sourceUpdated:(StackFrame*)frame;
 
 // Callback from |-getProperty:|.
index d51b6e631ecb349632224f72c9169b74a615b307..42af132843b03415138c87592b3c6e5a472d8dd7 100644 (file)
        [self recordCallback:@selector(propertiesReceived:) forTransaction:tx];
 }
 
+- (void)loadStackFrame:(StackFrame*)frame
+{
+       if (frame.loaded)
+               return;
+
+       NSNumber* routingNumber = [NSNumber numberWithInt:frame.routingID];
+
+       // Get the source code of the file. Escape % in URL chars.
+       NSString* escapedFilename = [frame.filename stringByReplacingOccurrencesOfString:@"%" withString:@"%%"];
+       NSNumber* transaction = [connection_ sendCommandWithFormat:@"source -f %@", escapedFilename];
+       [self recordCallback:@selector(setSource:) forTransaction:transaction];
+       [callbackContext_ setObject:routingNumber forKey:transaction];
+       
+       // Get the names of all the contexts.
+       transaction = [connection_ sendCommandWithFormat:@"context_names -d %d", frame.index];
+       [self recordCallback:@selector(contextsReceived:) forTransaction:transaction];
+       [callbackContext_ setObject:routingNumber forKey:transaction];
+       
+       // This frame will be fully loaded.
+       frame.loaded = YES;
+}
+
 // Breakpoint Management ///////////////////////////////////////////////////////
 #pragma mark Breakpoints
 
                                  atLine:[[[xmlframe attributeForName:@"lineno"] stringValue] intValue]
                          inFunction:[[xmlframe attributeForName:@"where"] stringValue]
                   withVariables:nil];
+       frame.routingID = routingID;
 
        // Only get the complete frame for the first level. The other frames will get
        // information loaded lazily when the user clicks on one.
        if (frame.index == 0) {
-               // Get the source code of the file. Escape % in URL chars.
-               NSString* escapedFilename = [frame.filename stringByReplacingOccurrencesOfString:@"%" withString:@"%%"];
-               NSNumber* transaction = [connection_ sendCommandWithFormat:@"source -f %@", escapedFilename];
-               [self recordCallback:@selector(setSource:) forTransaction:transaction];
-               [callbackContext_ setObject:routingNumber forKey:transaction];
-               
-               // Get the names of all the contexts.
-               transaction = [connection_ sendCommandWithFormat:@"context_names -d %d", frame.index];
-               [self recordCallback:@selector(contextsReceived:) forTransaction:transaction];
-               [callbackContext_ setObject:routingNumber forKey:transaction];
+               [self loadStackFrame:frame];
        }
        
        if ([delegate respondsToSelector:@selector(newStackFrame:)])
index ac31ad0165111228d5b69c5d3370d116256bc97a..591d8e000344dcc334b1add7105386ccdc5aaea4 100644 (file)
 
 @interface StackFrame : NSObject
 {
+       /**
+        * Whether or not the stack frame has been fully loaded.
+        */
+       BOOL loaded_;
+
        /**
         * The routing ID used to receive response information from the engine.
         */
@@ -54,6 +59,7 @@
        NSArray* variables;
 }
 
+@property BOOL loaded;
 @property NSUInteger routingID;
 @property (readwrite) int index;
 @property (readonly, copy) NSString* filename;
index f00dab3d609a2bd9df3dd8717a3c0d23e56e2eae..bdb9193a6da29772ad28bb458e29944385620093 100644 (file)
@@ -26,6 +26,7 @@
 
 @implementation StackFrame
 
+@synthesize loaded = loaded_;
 @synthesize routingID = routingID_;
 @synthesize index, filename, source, lineNumber, function, variables;