New flag and error message for class to memo key conversion
[hiphop-php.git] / hphp / runtime / debugger / debugger_command.h
blob85f40cf1d87db34f7e15c4bf8e939a7d6c3460a8
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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 +----------------------------------------------------------------------+
17 #pragma once
19 #include <memory>
20 #include <string>
22 #include "hphp/runtime/base/type-string.h"
24 namespace HPHP {
25 ///////////////////////////////////////////////////////////////////////////////
27 struct DebuggerThriftBuffer;
29 namespace Eval {
30 ///////////////////////////////////////////////////////////////////////////////
32 struct DebuggerClient;
33 struct DebuggerProxy;
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
41 * and DebuggerClient.
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!
53 enum Type {
54 KindOfNone = 0,
55 // Now I sing my A, B, C...
56 KindOfAbort = 1,
57 KindOfBreak = 2,
58 KindOfContinue = 3,
59 KindOfDown = 4,
60 KindOfException = 5,
61 KindOfFrame = 6,
62 KindOfGlobal = 7,
63 KindOfHelp = 8,
64 KindOfInfo = 9,
65 KindOfConstant = 11,
66 KindOfList = 12,
67 KindOfMachine = 13,
68 KindOfNext = 14,
69 KindOfOut = 15,
70 KindOfPrint = 16,
71 KindOfQuit = 17,
72 KindOfRun = 18,
73 KindOfStep = 19,
74 KindOfThread = 20,
75 KindOfUp = 21,
76 KindOfVariable = 22,
77 KindOfWhere = 23,
78 KindOfExtended = 24,
79 KindOfComplete = 27,
81 KindOfEval = 1000,
82 KindOfShell = 1001,
83 KindOfMacro = 1002,
84 KindOfConfig = 1003,
85 KindOfInstrument = 1004,
87 // DebuggerProxy -> DebuggerClient
88 KindOfInterrupt = 10000,
89 KindOfSignal = 10001,
90 KindOfAuth = 10002,
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,
98 const char *caller);
100 public:
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 {
109 return m_type;
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 {
130 return m_wireError;
133 protected:
134 bool displayedHelp(DebuggerClient&);
135 virtual void sendImpl(DebuggerThriftBuffer&);
136 virtual void recvImpl(DebuggerThriftBuffer&);
138 Type m_type;
139 int m_version{0};
141 std::string m_class; // for CmdExtended
142 std::string m_body;
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 ///////////////////////////////////////////////////////////////////////////////