DebugServer2
Loading...
Searching...
No Matches
Session.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/GDBRemote/ProtocolInterpreter.h"
14#include "DebugServer2/GDBRemote/SessionBase.h"
15
16#include <functional>
17#include <map>
18
19namespace ds2 {
20namespace GDBRemote {
21
22class Session : public SessionBase {
23protected:
24 std::map<char, ProcessThreadId> _ptids;
25 bool _threadsInStopReply;
26
27public:
28 Session(CompatibilityMode mode);
29
30private:
31 void Handle_ControlC(ProtocolInterpreter::Handler const &,
32 std::string const &);
33 void Handle_QuestionMark(ProtocolInterpreter::Handler const &,
34 std::string const &);
35 void Handle_ExclamationMark(ProtocolInterpreter::Handler const &,
36 std::string const &);
37
38private:
39 void Handle_A(ProtocolInterpreter::Handler const &, std::string const &);
40 void Handle_B(ProtocolInterpreter::Handler const &, std::string const &);
41 void Handle_b(ProtocolInterpreter::Handler const &, std::string const &);
42 void Handle_bc(ProtocolInterpreter::Handler const &, std::string const &);
43 void Handle_bs(ProtocolInterpreter::Handler const &, std::string const &);
44 void Handle_C(ProtocolInterpreter::Handler const &, std::string const &);
45 void Handle_c(ProtocolInterpreter::Handler const &, std::string const &);
46 void Handle_D(ProtocolInterpreter::Handler const &, std::string const &);
47 void Handle_d(ProtocolInterpreter::Handler const &, std::string const &);
48 void Handle_G(ProtocolInterpreter::Handler const &, std::string const &);
49 void Handle_g(ProtocolInterpreter::Handler const &, std::string const &);
50 void Handle_H(ProtocolInterpreter::Handler const &, std::string const &);
51 void Handle_I(ProtocolInterpreter::Handler const &, std::string const &);
52 void Handle_i(ProtocolInterpreter::Handler const &, std::string const &);
53 void Handle_k(ProtocolInterpreter::Handler const &, std::string const &);
54 void Handle_jThreadsInfo(ProtocolInterpreter::Handler const &,
55 std::string const &);
56 void Handle__M(ProtocolInterpreter::Handler const &, std::string const &);
57 void Handle__m(ProtocolInterpreter::Handler const &, std::string const &);
58 void Handle_M(ProtocolInterpreter::Handler const &, std::string const &);
59 void Handle_m(ProtocolInterpreter::Handler const &, std::string const &);
60 void Handle_P(ProtocolInterpreter::Handler const &, std::string const &);
61 void Handle_p(ProtocolInterpreter::Handler const &, std::string const &);
62 void Handle_QAgent(ProtocolInterpreter::Handler const &, std::string const &);
63 void Handle_QAllow(ProtocolInterpreter::Handler const &, std::string const &);
64 void Handle_Qbtrace(ProtocolInterpreter::Handler const &,
65 std::string const &);
66 void Handle_QDisableRandomization(ProtocolInterpreter::Handler const &,
67 std::string const &);
68 void Handle_QEnvironment(ProtocolInterpreter::Handler const &,
69 std::string const &);
70 void Handle_QEnvironmentHexEncoded(ProtocolInterpreter::Handler const &,
71 std::string const &);
72 void Handle_QLaunchArch(ProtocolInterpreter::Handler const &,
73 std::string const &);
74 void Handle_QListThreadsInStopReply(ProtocolInterpreter::Handler const &,
75 std::string const &);
76 void Handle_QNonStop(ProtocolInterpreter::Handler const &,
77 std::string const &);
78 void Handle_QPassSignals(ProtocolInterpreter::Handler const &,
79 std::string const &);
80 void Handle_QProgramSignals(ProtocolInterpreter::Handler const &,
81 std::string const &);
82 void Handle_QSetDisableASLR(ProtocolInterpreter::Handler const &,
83 std::string const &);
84 void Handle_QSetEnableAsyncProfiling(ProtocolInterpreter::Handler const &,
85 std::string const &);
86 void Handle_QSetLogging(ProtocolInterpreter::Handler const &,
87 std::string const &);
88 void Handle_QSetSTDERR(ProtocolInterpreter::Handler const &,
89 std::string const &);
90 void Handle_QSetSTDIN(ProtocolInterpreter::Handler const &,
91 std::string const &);
92 void Handle_QSetSTDOUT(ProtocolInterpreter::Handler const &,
93 std::string const &);
94 void Handle_QSetMaxPacketSize(ProtocolInterpreter::Handler const &,
95 std::string const &);
96 void Handle_QSetMaxPayloadSize(ProtocolInterpreter::Handler const &,
97 std::string const &);
98 void Handle_QSetWorkingDir(ProtocolInterpreter::Handler const &,
99 std::string const &);
100 void Handle_QRestoreRegisterState(ProtocolInterpreter::Handler const &,
101 std::string const &args);
102 void Handle_QSaveRegisterState(ProtocolInterpreter::Handler const &,
103 std::string const &args);
104 void Handle_QStartNoAckMode(ProtocolInterpreter::Handler const &,
105 std::string const &);
106 void Handle_QSyncThreadState(ProtocolInterpreter::Handler const &,
107 std::string const &);
108 void Handle_QThreadSuffixSupported(ProtocolInterpreter::Handler const &,
109 std::string const &);
110 void Handle_qAttached(ProtocolInterpreter::Handler const &,
111 std::string const &);
112 void Handle_qC(ProtocolInterpreter::Handler const &, std::string const &);
113 void Handle_qCRC(ProtocolInterpreter::Handler const &, std::string const &);
114 void Handle_qEcho(ProtocolInterpreter::Handler const &, std::string const &);
115 void Handle_qFileLoadAddress(ProtocolInterpreter::Handler const &,
116 std::string const &);
117 void Handle_qGDBServerVersion(ProtocolInterpreter::Handler const &,
118 std::string const &);
119 void Handle_qGetPid(ProtocolInterpreter::Handler const &,
120 std::string const &);
121 void Handle_qGetProfileData(ProtocolInterpreter::Handler const &,
122 std::string const &);
123 void Handle_qGetTLSAddr(ProtocolInterpreter::Handler const &,
124 std::string const &);
125 void Handle_qGetTIBAddr(ProtocolInterpreter::Handler const &,
126 std::string const &);
127 void Handle_qGetWorkingDir(ProtocolInterpreter::Handler const &,
128 std::string const &);
129 void Handle_qGroupName(ProtocolInterpreter::Handler const &,
130 std::string const &);
131 void Handle_qHostInfo(ProtocolInterpreter::Handler const &,
132 std::string const &);
133 void Handle_qKillSpawnedProcess(ProtocolInterpreter::Handler const &,
134 std::string const &);
135 void Handle_qL(ProtocolInterpreter::Handler const &, std::string const &);
136 void Handle_qLaunchGDBServer(ProtocolInterpreter::Handler const &,
137 std::string const &);
138 void Handle_qLaunchSuccess(ProtocolInterpreter::Handler const &,
139 std::string const &);
140 void Handle_qMemoryRegionInfo(ProtocolInterpreter::Handler const &,
141 std::string const &);
142 void Handle_qModuleInfo(ProtocolInterpreter::Handler const &,
143 std::string const &);
144 void Handle_qOffsets(ProtocolInterpreter::Handler const &,
145 std::string const &);
146 void Handle_qP(ProtocolInterpreter::Handler const &, std::string const &);
147 void Handle_qPlatform_chmod(ProtocolInterpreter::Handler const &,
148 std::string const &);
149 void Handle_qPlatform_mkdir(ProtocolInterpreter::Handler const &,
150 std::string const &);
151 void Handle_qPlatform_shell(ProtocolInterpreter::Handler const &,
152 std::string const &);
153 void Handle_qProcessInfo(ProtocolInterpreter::Handler const &,
154 std::string const &);
155 void Handle_qProcessInfoPID(ProtocolInterpreter::Handler const &,
156 std::string const &);
157 void Handle_qRcmd(ProtocolInterpreter::Handler const &, std::string const &);
158 void Handle_qRegisterInfo(ProtocolInterpreter::Handler const &,
159 std::string const &);
160 void Handle_qSearch(ProtocolInterpreter::Handler const &,
161 std::string const &);
162 void Handle_qShlibInfoAddr(ProtocolInterpreter::Handler const &,
163 std::string const &);
164 void Handle_qSpeedTest(ProtocolInterpreter::Handler const &,
165 std::string const &);
166 void Handle_qStepPacketSupported(ProtocolInterpreter::Handler const &,
167 std::string const &);
168 void Handle_qSupported(ProtocolInterpreter::Handler const &,
169 std::string const &);
170 void
171 Handle_qSupportsDetachAndStayStopped(ProtocolInterpreter::Handler const &,
172 std::string const &);
173 void Handle_qSymbol(ProtocolInterpreter::Handler const &,
174 std::string const &);
175 void Handle_qThreadStopInfo(ProtocolInterpreter::Handler const &,
176 std::string const &);
177 void Handle_qThreadExtraInfo(ProtocolInterpreter::Handler const &,
178 std::string const &);
179 void Handle_qTStatus(ProtocolInterpreter::Handler const &,
180 std::string const &);
181 void Handle_qUserName(ProtocolInterpreter::Handler const &,
182 std::string const &);
183 void Handle_qVAttachOrWaitSupported(ProtocolInterpreter::Handler const &,
184 std::string const &);
185 void Handle_qWatchpointSupportInfo(ProtocolInterpreter::Handler const &,
186 std::string const &);
187 void Handle_qXfer(ProtocolInterpreter::Handler const &, std::string const &);
188 void Handle_qfProcessInfo(ProtocolInterpreter::Handler const &,
189 std::string const &);
190 void Handle_qsProcessInfo(ProtocolInterpreter::Handler const &,
191 std::string const &);
192 void Handle_qfThreadInfo(ProtocolInterpreter::Handler const &,
193 std::string const &);
194 void Handle_qsThreadInfo(ProtocolInterpreter::Handler const &,
195 std::string const &);
196 void Handle_R(ProtocolInterpreter::Handler const &, std::string const &);
197 void Handle_r(ProtocolInterpreter::Handler const &, std::string const &);
198 void Handle_S(ProtocolInterpreter::Handler const &, std::string const &);
199 void Handle_s(ProtocolInterpreter::Handler const &, std::string const &);
200 void Handle_T(ProtocolInterpreter::Handler const &, std::string const &);
201 void Handle_t(ProtocolInterpreter::Handler const &, std::string const &);
202 void Handle_vAttach(ProtocolInterpreter::Handler const &,
203 std::string const &);
204 void Handle_vAttachName(ProtocolInterpreter::Handler const &,
205 std::string const &);
206 void Handle_vAttachWait(ProtocolInterpreter::Handler const &,
207 std::string const &);
208 void Handle_vAttachOrWait(ProtocolInterpreter::Handler const &,
209 std::string const &);
210 void Handle_vContQuestionMark(ProtocolInterpreter::Handler const &,
211 std::string const &);
212 void Handle_vCont(ProtocolInterpreter::Handler const &, std::string const &);
213 void Handle_vFile(ProtocolInterpreter::Handler const &, std::string const &);
214 void Handle_vFlashDone(ProtocolInterpreter::Handler const &,
215 std::string const &);
216 void Handle_vFlashErase(ProtocolInterpreter::Handler const &,
217 std::string const &);
218 void Handle_vFlashWrite(ProtocolInterpreter::Handler const &,
219 std::string const &);
220 void Handle_vKill(ProtocolInterpreter::Handler const &, std::string const &);
221 void Handle_vRun(ProtocolInterpreter::Handler const &, std::string const &);
222 void Handle_vStopped(ProtocolInterpreter::Handler const &,
223 std::string const &);
224 void Handle_X(ProtocolInterpreter::Handler const &, std::string const &);
225 void Handle_x(ProtocolInterpreter::Handler const &, std::string const &);
226 void Handle_Z(ProtocolInterpreter::Handler const &, std::string const &);
227 void Handle_z(ProtocolInterpreter::Handler const &, std::string const &);
228
229private:
230 static bool ParseList(std::string const &string, char separator,
231 std::function<void(std::string const &)> const &cb);
232
233private:
234 OpenFlags ConvertOpenFlags(uint32_t protocolFlags);
235
236private:
237 bool parseAddress(Address &address, const char *ptr, char **eptr,
238 Endian endianness) const;
239 std::string formatAddress(Address const &address, Endian endianness) const;
240};
241} // namespace GDBRemote
242} // namespace ds2
Definition Types.h:95
Definition SessionBase.h:30
Definition Session.h:22
Definition ProtocolInterpreter.h:23