Clean up DebuggerBackEnd and move all the ivars into the .m file.
[macgdbp.git] / Source / DebuggerBackEnd.h
1 /*
2 * MacGDBp
3 * Copyright (c) 2007 - 2011, Blue Static <http://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 <Cocoa/Cocoa.h>
18
19 #import "Breakpoint.h"
20 #import "ProtocolClient.h"
21 #import "StackFrame.h"
22
23 @protocol DebuggerBackEndDelegate;
24 @class VariableNode;
25
26 // The DebuggerBackEnd is the communication layer between the application
27 // and the back-end debugger. Clients issue debugger commands via this class,
28 // which are sent in an asynchronous manner. Reads are also asynchronous and
29 // the primary client of this class should set itself as the delegate. The
30 // primary unit that this class deals with is the StackFrame; clients should
31 // maintain a stack structure and the BackEnd will inform the delegate when
32 // a new frame is created or the stack should be destroyed.
33 @interface DebuggerBackEnd : NSObject<ProtocolClientDelegate>
34
35 // Human-readable status of the connection.
36 @property(readonly, copy, nonatomic) NSString* status;
37
38 // Whether the debugger should detach immediately after being contacted by the
39 // backend. YES means all debugger connections will be dropped.
40 @property(assign, nonatomic) BOOL autoAttach;
41
42 @property(assign, nonatomic) id<DebuggerBackEndDelegate> delegate;
43
44 // initializer
45 - (id)initWithPort:(NSUInteger)aPort;
46
47 // getter
48 - (NSUInteger)port;
49 - (BOOL)isConnected;
50
51 // communication
52 - (void)run;
53 - (void)stepIn;
54 - (void)stepOut;
55 - (void)stepOver;
56 - (void)stop;
57 - (void)detach;
58
59 // Breakpoint management.
60 - (void)addBreakpoint:(Breakpoint*)bp;
61 - (void)removeBreakpoint:(Breakpoint*)bp;
62
63 // Evaluates a given string in the current execution context.
64 - (void)evalScript:(NSString*)str;
65
66 // Gets a property by name from the debugger engine. Properties must be
67 // retrieved at a certain stack depth.
68 - (void)getChildrenOfProperty:(VariableNode*)property
69 atDepth:(NSInteger)depth
70 callback:(void (^)(NSArray*))callback;
71
72 // Takes a partially loaded stack frame and fetches the rest of the information.
73 - (void)loadStackFrame:(StackFrame*)frame;
74
75 @end
76
77 // Delegate ////////////////////////////////////////////////////////////////////
78
79 @protocol DebuggerBackEndDelegate <NSObject>
80
81 // Passes up errors from SocketWrapper and any other errors generated by the
82 // GDBpConnection.
83 - (void)errorEncountered:(NSString*)error;
84
85 // Called when the socket connects. Passed up from SocketWrapper.
86 - (void)debuggerConnected;
87
88 // Called when we disconnect.
89 - (void)debuggerDisconnected;
90
91 // Tells the debugger to destroy the current stack display.
92 - (void)clobberStack;
93
94 // Tells the debugger that a new stack frame is avaliable.
95 - (void)newStackFrame:(StackFrame*)frame;
96
97 // Tells the debugger that new source is available for the given frame.
98 // TODO: rename to |-frameUpdated:|.
99 - (void)sourceUpdated:(StackFrame*)frame;
100
101 // Callback for the result of |-evalScript:|.
102 - (void)scriptWasEvaluatedWithResult:(NSString*)result;
103
104 @end
105