Repository navigation
Expand file tree
/
Copy pathdebugger_command.h
More file actions
160 lines (131 loc) · 5.13 KB
/
Copy pathdebugger_command.h
File metadata and controls
160 lines (131 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_EVAL_DEBUGGER_COMMAND_H_
#define incl_HPHP_EVAL_DEBUGGER_COMMAND_H_
#include <memory>
#include <string>
#include "hphp/runtime/base/type-string.h"
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
struct DebuggerThriftBuffer;
namespace Eval {
///////////////////////////////////////////////////////////////////////////////
struct DebuggerClient;
struct DebuggerProxy;
struct DebuggerCommand;
using DebuggerCommandPtr = std::shared_ptr<DebuggerCommand>;
/*
* DebuggerCommand is the base of all commands executed by the debugger. It
* also represents the base binary communication format between DebuggerProxy
* and DebuggerClient.
*
* Each command has serialization logic, plus client- and server-side logic.
* Client-side logic is implemented in the onClient* methods, while server-side
* is in the onServer* methods.
*/
struct DebuggerCommand {
/*
* Warning: Do NOT modify exists values, as they are used in binary network
* protocol, and changing them may create incompatibility between different
* versions of debugger and server!
*/
enum Type {
KindOfNone = 0,
// Now I sing my A, B, C...
KindOfAbort = 1,
KindOfBreak = 2,
KindOfContinue = 3,
KindOfDown = 4,
KindOfException = 5,
KindOfFrame = 6,
KindOfGlobal = 7,
KindOfHelp = 8,
KindOfInfo = 9,
KindOfConstant = 11,
KindOfList = 12,
KindOfMachine = 13,
KindOfNext = 14,
KindOfOut = 15,
KindOfPrint = 16,
KindOfQuit = 17,
KindOfRun = 18,
KindOfStep = 19,
KindOfThread = 20,
KindOfUp = 21,
KindOfVariable = 22,
KindOfVariableAsync = 222,
KindOfWhere = 23,
KindOfWhereAsync = 223,
KindOfExtended = 24,
KindOfComplete = 27,
KindOfEval = 1000,
KindOfShell = 1001,
KindOfMacro = 1002,
KindOfConfig = 1003,
KindOfInstrument = 1004,
// DebuggerProxy -> DebuggerClient
KindOfInterrupt = 10000,
KindOfSignal = 10001,
KindOfAuth = 10002,
// Internal testing only
KindOfInternalTesting = 20000, // The real test command
KindOfInternalTestingBad = 20001, // A command type we never recgonize
};
static bool Receive(DebuggerThriftBuffer &thrift, DebuggerCommandPtr &cmd,
const char *caller);
public:
explicit DebuggerCommand(Type type): m_type(type) {}
virtual ~DebuggerCommand() {}
bool is(Type type) const {
return m_type == type;
}
Type getType() const {
return m_type;
}
bool send(DebuggerThriftBuffer&);
bool recv(DebuggerThriftBuffer&);
virtual void list(DebuggerClient&);
virtual void help(DebuggerClient&);
virtual void onClient(DebuggerClient&) = 0;
virtual bool onServer(DebuggerProxy&);
// Returns true if DebuggerProxy::processInterrupt() should return
// to its caller instead of processing further commands from the client.
bool shouldExitInterrupt() const {
return m_exitInterrupt;
}
// Returns a non empty error message if the receipt of this command
// did not complete successfully.
const std::string& getWireError() const {
return m_wireError;
}
protected:
bool displayedHelp(DebuggerClient&);
virtual void sendImpl(DebuggerThriftBuffer&);
virtual void recvImpl(DebuggerThriftBuffer&);
Type m_type;
int m_version{0};
std::string m_class; // for CmdExtended
std::string m_body;
// Used to save temporary error happened on the wire.
std::string m_wireError;
// Server side breaking out of message loop.
bool m_exitInterrupt{false};
// Another interrupt comes before the command could finish.
bool m_incomplete{false};
};
///////////////////////////////////////////////////////////////////////////////
}}
#endif // incl_HPHP_EVAL_DEBUGGER_COMMAND_H_