]> src.bluestatic.org Git - macgdbp.git/blob - Source/DebuggerBackEnd.h
Fix a silly memory bug where MessageQueue._message was autoreleased.
[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 "NetworkConnection.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 <NetworkConnectionDelegate>
34 {
35 // The connection to the debugger engine.
36 NetworkConnection* connection_;
37
38 // Human-readable status of the connection.
39 NSString* status;
40 BOOL active_;
41
42 // Whether the debugger should detach immediately after being contacted by the
43 // backend. YES means all debugger connections will be dropped.
44 BOOL attached_;
45
46 // The connection's delegate.
47 id <DebuggerBackEndDelegate> delegate;
48
49 // A dictionary that maps routingIDs to StackFrame objects.
50 NSMutableDictionary* stackFrames_;
51 // The stack depth for the current build of |stackFrames_|.
52 NSInteger stackDepth_;
53 // The earliest transaction ID for the current build of |stackFrames_|.
54 NSInteger stackFirstTransactionID_;
55
56 // Callback table. This maps transaction IDs to selectors. When the engine
57 // returns a response to the debugger, we will dispatch the response XML to
58 // the selector, based on transaction_id.
59 NSMutableDictionary* callTable_;
60
61 // This stores additional context information for the callback selector.
62 // This dictionary is keyed by the same transaction IDs in |callTable_|, but
63 // also stores some other object that can be accessed in the callback.
64 NSMutableDictionary* callbackContext_;
65 }
66
67 @property (readonly, copy) NSString* status;
68 @property (nonatomic, assign) BOOL attached;
69 @property (assign) id <DebuggerBackEndDelegate> delegate;
70
71 // initializer
72 - (id)initWithPort:(NSUInteger)aPort;
73
74 // getter
75 - (NSUInteger)port;
76 - (BOOL)isConnected;
77
78 // communication
79 - (void)run;
80 - (void)stepIn;
81 - (void)stepOut;
82 - (void)stepOver;
83 - (void)stop;
84 - (void)detach;
85
86 // Breakpoint management.
87 - (void)addBreakpoint:(Breakpoint*)bp;
88 - (void)removeBreakpoint:(Breakpoint*)bp;
89
90 // Evaluates a given string in the current execution context.
91 - (void)evalScript:(NSString*)str;
92
93 // Gets a property by name from the debugger engine. Returns a transaction ID
94 // which used in the delegate callback. Properties must be retrieved at a
95 // certain stack depth.
96 - (NSInteger)getChildrenOfProperty:(VariableNode*)property atDepth:(NSInteger)depth;
97
98 // Takes a partially loaded stack frame and fetches the rest of the information.
99 - (void)loadStackFrame:(StackFrame*)frame;
100
101 @end
102
103 // Delegate ////////////////////////////////////////////////////////////////////
104
105 @protocol DebuggerBackEndDelegate <NSObject>
106
107 // Passes up errors from SocketWrapper and any other errors generated by the
108 // GDBpConnection.
109 - (void)errorEncountered:(NSString*)error;
110
111 // Called when the socket connects. Passed up from SocketWrapper.
112 - (void)debuggerConnected;
113
114 // Called when we disconnect.
115 - (void)debuggerDisconnected;
116
117 // Tells the debugger to destroy the current stack display.
118 - (void)clobberStack;
119
120 // Tells the debugger that a new stack frame is avaliable.
121 - (void)newStackFrame:(StackFrame*)frame;
122
123 // Tells the debugger that new source is available for the given frame.
124 // TODO: rename to |-frameUpdated:|.
125 - (void)sourceUpdated:(StackFrame*)frame;
126
127 // Callback from |-getProperty:|.
128 - (void)receivedProperties:(NSArray*)properties forTransaction:(NSInteger)transaction;
129
130 // Callback for the result of |-evalScript:|.
131 - (void)scriptWasEvaluatedWithResult:(NSString*)result;
132
133 @end
134