3 * Copyright (c) 2007 - 2010, Blue Static <http://www.bluestatic.org>
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.
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.
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
17 #import <Cocoa/Cocoa.h>
19 #import "Breakpoint.h"
20 #import "DebuggerConnection.h"
21 #import "StackFrame.h"
23 @protocol DebuggerProcessorDelegate
;
25 // The DebuggerConnection is the communication layer between the application
26 // and the Xdebug engine. Clients can issue debugger commands using this class,
27 // which are sent in an asynchronous manner. Reads are also asynchronous and
28 // the primary client of this class should set itself as the delegate. The
29 // primary unit that this class deals with is the StackFrame; clients should
30 // maintain a stack structure and the Connection will inform the delegate when
31 // a new frame is created or the stack should be destroyed.
32 @interface DebuggerProcessor
: NSObject
<DebuggerConnectionDelegate
>
34 // The connection to the debugger engine.
35 DebuggerConnection
* connection_
;
37 // Human-readable status of the connection.
40 // The connection's delegate.
41 id
<DebuggerProcessorDelegate
> delegate
;
43 // A dictionary that maps routingIDs to StackFrame objects.
44 NSMutableDictionary
* stackFrames_
;
45 // The stack depth for the current build of |stackFrames_|.
46 NSInteger stackDepth_
;
47 // The earliest transaction ID for the current build of |stackFrames_|.
48 NSInteger stackFirstTransactionID_
;
50 // This stores additional context information for the callback selector.
51 // This dictionary is keyed by the same transaction IDs in |callTable_|, but
52 // also stores some other object that can be accessed in the callback.
53 NSMutableDictionary
* callbackContext_
;
56 @
property (readonly
, copy
) NSString
* status
;
57 @
property (assign
) id
<DebuggerProcessorDelegate
> delegate
;
60 - (id
)initWithPort
:(NSUInteger
)aPort
;
64 - (NSString
*)remoteHost
;
73 - (void)addBreakpoint
:(Breakpoint
*)bp
;
74 - (void)removeBreakpoint
:(Breakpoint
*)bp
;
76 // Gets a property by name from the debugger engine. Returns a transaction ID
77 // which used in the delegate callback.
78 - (NSInteger
)getProperty
:(NSString
*)property
;
82 // Delegate ////////////////////////////////////////////////////////////////////
84 @protocol DebuggerProcessorDelegate
<NSObject
>
86 // Passes up errors from SocketWrapper and any other errors generated by the
88 - (void)errorEncountered
:(NSString
*)error
;
90 // Called when the socket connects. Passed up from SocketWrapper.
91 - (void)debuggerConnected
;
93 // Called when we disconnect.
94 - (void)debuggerDisconnected
;
96 // Tells the debugger to destroy the current stack display.
99 // Tells the debugger that a new stack frame is avaliable.
100 - (void)newStackFrame
:(StackFrame
*)frame
;
102 // Tells the debugger that new source is available for the given frame.
103 - (void)sourceUpdated
:(StackFrame
*)frame
;
105 // Callback from |-getProperty:|.
106 - (void)receivedProperties
:(NSArray
*)properties forTransaction
:(NSInteger
)transaction
;