Inject autoAttach into DebuggerBackEnd's designated initializer.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 7 Dec 2015 06:20:02 +0000 (01:20 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 7 Dec 2015 06:20:02 +0000 (01:20 -0500)
Also makes sure the header order matches implementation order.

Source/DebuggerBackEnd.h
Source/DebuggerBackEnd.m
Source/DebuggerController.m

index 4fc834c20efb4990787ab42024e710fe29b7ce4d..cf6bfc45672d9fb4f8c51e278ef378f54a53e071 100644 (file)
@@ -40,8 +40,9 @@
 // The model object to update in response to changes in the debugger.
 @property(assign, nonatomic) DebuggerModel* model;
 
-// initializer
-- (id)initWithPort:(NSUInteger)aPort;
+// Designated initializer. Sets up a connection on |aPort| and will
+// initialize it if |autoAttach| is YES.
+- (instancetype)initWithPort:(NSUInteger)aPort autoAttach:(BOOL)doAttach;
 
 // getter
 - (NSUInteger)port;
 - (void)stop;
 - (void)detach;
 
-// Breakpoint management.
-- (void)addBreakpoint:(Breakpoint*)bp;
-- (void)removeBreakpoint:(Breakpoint*)bp;
-
-// Evaluates a given string in the current execution context.
-- (void)evalScript:(NSString*)str callback:(void (^)(NSString*))callback;
-
 // Takes a partially loaded stack frame and fetches the rest of the information.
 - (void)loadStackFrame:(StackFrame*)frame;
 
 - (void)loadVariableNode:(VariableNode*)variable
            forStackFrame:(StackFrame*)frame;
 
+// Breakpoint management.
+- (void)addBreakpoint:(Breakpoint*)bp;
+- (void)removeBreakpoint:(Breakpoint*)bp;
+
+// Evaluates a given string in the current execution context.
+- (void)evalScript:(NSString*)str callback:(void (^)(NSString*))callback;
+
 @end
index 717f8b9e805b182bcde0d949894c26b0add69588..b01fb89c47f2fcccaf91c0f2fda5c09467e4710c 100644 (file)
 @synthesize autoAttach = _autoAttach;
 @synthesize model = _model;
 
-- (id)initWithPort:(NSUInteger)aPort
+- (instancetype)initWithPort:(NSUInteger)aPort autoAttach:(BOOL)doAttach
 {
   if (self = [super init]) {
     [[BreakpointManager sharedManager] setConnection:self];
     _port = aPort;
     _client = [[ProtocolClient alloc] initWithDelegate:self];
 
-    _autoAttach = [[NSUserDefaults standardUserDefaults] boolForKey:@"DebuggerAttached"];
-
-    if (self.autoAttach)
+    _autoAttach = doAttach;
+    if (doAttach)
       [_client connectOnPort:_port];
   }
   return self;
 - (void)rebuildStack:(NSXMLDocument*)response {
   NSUInteger depth = [[[[response rootElement] attributeForName:@"depth"] stringValue] intValue];
 
-  // Start with frame 0. If this is a shifted frame, then only it needs to be
-  // re-loaded. If it is not shifted, see if another frame on the stack is equal
-  // to it; if so, then the frames up to that must be discarded. If not, this is
-  // a new stack frame that should be inserted at the top of the stack. Finally,
-  // the sice of the stack is trimmed to |depth| from the bottom.
-
+  // Send a request to get each frame of the stack, which will be added to this
+  // array. When the final frame arrives, the |tempStack| is released.
   __block NSMutableArray* tempStack = [[NSMutableArray alloc] init];
 
   for (NSUInteger i = 0; i < depth; ++i) {
index 2f3b32916d12e9c153836e7a7f51535444158e01..153ecbf630598b79f1c7bd89ec9ad61682069691 100644 (file)
@@ -49,7 +49,8 @@
                 options:NSKeyValueObservingOptionNew
                 context:nil];
 
-    connection = [[DebuggerBackEnd alloc] initWithPort:[defaults integerForKey:@"Port"]];
+    connection = [[DebuggerBackEnd alloc] initWithPort:[defaults integerForKey:@"Port"]
+                                            autoAttach:[defaults boolForKey:@"DebuggerAttached"]];
     connection.model = _model;
     expandedVariables = [[NSMutableSet alloc] init];
     [[self window] makeKeyAndOrderFront:nil];