Also makes sure the header order matches implementation order.
// 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
@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) {
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];