]> src.bluestatic.org Git - macgdbp.git/blob - Source/DebuggerModel.m
Specify CODE_SIGN_STYLE=Manual .
[macgdbp.git] / Source / DebuggerModel.m
1 /*
2 * MacGDBp
3 * Copyright (c) 2015, Blue Static <https://www.bluestatic.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17 #import "DebuggerModel.h"
18
19 #import "BreakpointManager.h"
20 #import "StackFrame.h"
21
22 @interface DebuggerModel ()
23 @property(assign, nonatomic) BOOL connected;
24 @end
25
26 @implementation DebuggerModel {
27 NSMutableArray* _stack;
28 }
29
30 - (instancetype)init {
31 if (self = [super init]) {
32 _breakpointManager = [[BreakpointManager alloc] init];
33 _stack = [NSMutableArray new];
34
35 [self onDisconnect];
36 }
37 return self;
38 }
39
40 - (NSUInteger)stackDepth {
41 return self.stack.count;
42 }
43
44 - (void)onListeningOnPort:(uint16_t)port {
45 self.status = [NSString stringWithFormat:@"Listening on Port %d", port];
46 }
47
48 - (void)onNewConnection {
49 self.status = nil;
50 self.connected = YES;
51 [_stack removeAllObjects];
52 }
53
54 - (void)onDisconnect {
55 self.connected = NO;
56 self.status = @"Disconnected";
57 }
58
59 - (void)updateStack:(NSArray<StackFrame*>*)newStack {
60 [self willChangeValueForKey:@"stack"];
61
62 [_stack removeAllObjects];
63 [_stack addObjectsFromArray:newStack];
64
65 // Renumber the stack.
66 for (NSUInteger i = 0; i < self.stack.count; ++i)
67 self.stack[i].index = i;
68
69 [self didChangeValueForKey:@"stack"];
70 }
71
72 @end