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