2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
22 #include "hphp/runtime/base/type-string.h"
25 ///////////////////////////////////////////////////////////////////////////////
27 struct DebuggerThriftBuffer
;
30 ///////////////////////////////////////////////////////////////////////////////
32 struct DebuggerClient
;
35 struct DebuggerCommand
;
36 using DebuggerCommandPtr
= std::shared_ptr
<DebuggerCommand
>;
39 * DebuggerCommand is the base of all commands executed by the debugger. It
40 * also represents the base binary communication format between DebuggerProxy
43 * Each command has serialization logic, plus client- and server-side logic.
44 * Client-side logic is implemented in the onClient* methods, while server-side
45 * is in the onServer* methods.
47 struct DebuggerCommand
{
49 * Warning: Do NOT modify exists values, as they are used in binary network
50 * protocol, and changing them may create incompatibility between different
51 * versions of debugger and server!
55 // Now I sing my A, B, C...
85 KindOfInstrument
= 1004,
87 // DebuggerProxy -> DebuggerClient
88 KindOfInterrupt
= 10000,
92 // Internal testing only
93 KindOfInternalTesting
= 20000, // The real test command
94 KindOfInternalTestingBad
= 20001, // A command type we never recgonize
97 static bool Receive(DebuggerThriftBuffer
&thrift
, DebuggerCommandPtr
&cmd
,
101 explicit DebuggerCommand(Type type
): m_type(type
) {}
102 virtual ~DebuggerCommand() {}
104 bool is(Type type
) const {
105 return m_type
== type
;
108 Type
getType() const {
112 bool send(DebuggerThriftBuffer
&);
113 bool recv(DebuggerThriftBuffer
&);
115 virtual void list(DebuggerClient
&);
116 virtual void help(DebuggerClient
&);
118 virtual void onClient(DebuggerClient
&) = 0;
119 virtual bool onServer(DebuggerProxy
&);
121 // Returns true if DebuggerProxy::processInterrupt() should return
122 // to its caller instead of processing further commands from the client.
123 bool shouldExitInterrupt() const {
124 return m_exitInterrupt
;
127 // Returns a non empty error message if the receipt of this command
128 // did not complete successfully.
129 const std::string
& getWireError() const {
134 bool displayedHelp(DebuggerClient
&);
135 virtual void sendImpl(DebuggerThriftBuffer
&);
136 virtual void recvImpl(DebuggerThriftBuffer
&);
141 std::string m_class
; // for CmdExtended
144 // Used to save temporary error happened on the wire.
145 std::string m_wireError
;
147 // Server side breaking out of message loop.
148 bool m_exitInterrupt
{false};
150 // Another interrupt comes before the command could finish.
151 bool m_incomplete
{false};
154 ///////////////////////////////////////////////////////////////////////////////