Update the API for loading properties to just pass around VariableNode pointers,...
[macgdbp.git] / Source / DebuggerProcessor.h
1 /*
2 * MacGDBp
3 * Copyright (c) 2007 - 2010, 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 "DebuggerConnection.h"
21 #import "StackFrame.h"
22
23 @protocol DebuggerProcessorDelegate;
24 @class VariableNode;
25
26 // The DebuggerProcessor 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 Connection will inform the delegate when
32 // a new frame is created or the stack should be destroyed.
33 @interface DebuggerProcessor : NSObject <DebuggerConnectionDelegate>
34 {
35 // The connection to the debugger engine.
36 DebuggerConnection* connection_;
37
38 // Human-readable status of the connection.
39 NSString* status;
40 BOOL active_;
41
42 // The connection's delegate.
43 id <DebuggerProcessorDelegate> delegate;
44
45 // A dictionary that maps routingIDs to StackFrame objects.
46 NSMutableDictionary* stackFrames_;
47 // The stack depth for the current build of |stackFrames_|.
48 NSInteger stackDepth_;
49 // The earliest transaction ID for the current build of |stackFrames_|.
50 NSInteger stackFirstTransactionID_;
51
52 // Callback table. This maps transaction IDs to selectors. When the engine
53 // returns a response to the debugger, we will dispatch the response XML to
54 // the selector, based on transaction_id.
55 NSMutableDictionary* callTable_;
56
57 // This stores additional context information for the callback selector.
58 // This dictionary is keyed by the same transaction IDs in |callTable_|, but
59 // also stores some other object that can be accessed in the callback.
60 NSMutableDictionary* callbackContext_;
61 }
62
63 @property (readonly, copy) NSString* status;
64 @property (assign) id <DebuggerProcessorDelegate> delegate;
65
66 // initializer
67 - (id)initWithPort:(NSUInteger)aPort;
68
69 // getter
70 - (NSUInteger)port;
71 - (NSString*)remoteHost;
72 - (BOOL)isConnected;
73
74 // communication
75 - (void)reconnect;
76 - (void)run;
77 - (void)stepIn;
78 - (void)stepOut;
79 - (void)stepOver;
80 - (void)addBreakpoint:(Breakpoint*)bp;
81 - (void)removeBreakpoint:(Breakpoint*)bp;
82
83 // Gets a property by name from the debugger engine. Returns a transaction ID
84 // which used in the delegate callback. Properties must be retrieved at a
85 // certain stack depth.
86 - (NSInteger)getChildrenOfProperty:(VariableNode*)property atDepth:(NSInteger)depth;
87
88 // Takes a partially loaded stack frame and fetches the rest of the information.
89 - (void)loadStackFrame:(StackFrame*)frame;
90
91 @end
92
93 // Delegate ////////////////////////////////////////////////////////////////////
94
95 @protocol DebuggerProcessorDelegate <NSObject>
96
97 // Passes up errors from SocketWrapper and any other errors generated by the
98 // GDBpConnection.
99 - (void)errorEncountered:(NSString*)error;
100
101 // Called when the socket connects. Passed up from SocketWrapper.
102 - (void)debuggerConnected;
103
104 // Called when we disconnect.
105 - (void)debuggerDisconnected;
106
107 // Tells the debugger to destroy the current stack display.
108 - (void)clobberStack;
109
110 // Tells the debugger that a new stack frame is avaliable.
111 - (void)newStackFrame:(StackFrame*)frame;
112
113 // Tells the debugger that new source is available for the given frame.
114 // TODO: rename to |-frameUpdated:|.
115 - (void)sourceUpdated:(StackFrame*)frame;
116
117 // Callback from |-getProperty:|.
118 - (void)receivedProperties:(NSArray*)properties forTransaction:(NSInteger)transaction;
119
120 @end
121