Add a new DebuggerConnection that separates out the socket logic from the handling...
[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 "StackFrame.h"
21
22 @protocol DebuggerProcessorDelegate;
23
24 // The DebuggerConnection is the communication layer between the application
25 // and the Xdebug engine. Clients can issue debugger commands using this class,
26 // which are sent in an asynchronous manner. Reads are also asynchronous and
27 // the primary client of this class should set itself as the delegate. The
28 // primary unit that this class deals with is the StackFrame; clients should
29 // maintain a stack structure and the Connection will inform the delegate when
30 // a new frame is created or the stack should be destroyed.
31 @interface DebuggerProcessor : NSObject
32 {
33 // The port to connect on.
34 NSUInteger port;
35
36 // If the connection to the debugger engine is currently active.
37 BOOL connected;
38
39 // Human-readable status of the connection.
40 NSString* status;
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 // This stores additional context information for the callback selector.
53 // This dictionary is keyed by the same transaction IDs in |callTable_|, but
54 // also stores some other object that can be accessed in the callback.
55 NSMutableDictionary* callbackContext_;
56 }
57
58 @property (readonly, copy) NSString* status;
59 @property (assign) id <DebuggerProcessorDelegate> delegate;
60
61 // initializer
62 - (id)initWithPort:(NSUInteger)aPort;
63
64 // getter
65 - (NSUInteger)port;
66 - (NSString*)remoteHost;
67 - (BOOL)isConnected;
68
69 // communication
70 - (void)reconnect;
71 - (void)run;
72 - (void)stepIn;
73 - (void)stepOut;
74 - (void)stepOver;
75 - (void)addBreakpoint:(Breakpoint*)bp;
76 - (void)removeBreakpoint:(Breakpoint*)bp;
77
78 // Gets a property by name from the debugger engine. Returns a transaction ID
79 // which used in the delegate callback.
80 - (NSInteger)getProperty:(NSString*)property;
81
82 @end
83
84 // Delegate ////////////////////////////////////////////////////////////////////
85
86 @protocol DebuggerProcessorDelegate <NSObject>
87
88 // Passes up errors from SocketWrapper and any other errors generated by the
89 // GDBpConnection.
90 - (void)errorEncountered:(NSString*)error;
91
92 // Called when the socket connects. Passed up from SocketWrapper.
93 - (void)debuggerConnected;
94
95 // Called when we disconnect.
96 - (void)debuggerDisconnected;
97
98 // Tells the debugger to destroy the current stack display.
99 - (void)clobberStack;
100
101 // Tells the debugger that a new stack frame is avaliable.
102 - (void)newStackFrame:(StackFrame*)frame;
103
104 // Tells the debugger that new source is available for the given frame.
105 - (void)sourceUpdated:(StackFrame*)frame;
106
107 // Callback from |-getProperty:|.
108 - (void)receivedProperties:(NSArray*)properties forTransaction:(NSInteger)transaction;
109
110 @end
111