DebugServer2
Loading...
Searching...
No Matches
SessionDelegate.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/Types.h"
14
15namespace ds2 {
16namespace GDBRemote {
17
18class Session;
19
21protected:
22 friend class Session;
23
24public:
25 virtual ~SessionDelegate() = default;
26
27protected: // General Information
28 virtual size_t getGPRSize() const = 0;
29
30protected: // Common
31 virtual ErrorCode onEnableExtendedMode(Session &session) = 0;
32 virtual ErrorCode onSetBaudRate(Session &session, uint32_t speed) = 0;
33 virtual ErrorCode onToggleDebugFlag(Session &session) = 0;
34
35 virtual ErrorCode onSetMaxPacketSize(Session &session, size_t size) = 0;
36 virtual ErrorCode onSetMaxPayloadSize(Session &session, size_t size) = 0;
37
38 virtual ErrorCode onSetLogging(Session &session, std::string const &mode,
39 std::string const &filename,
40 StringCollection const &flags) = 0;
41 virtual ErrorCode onSendInput(Session &session, ByteVector const &buf) = 0;
42 virtual ErrorCode
43 onAllowOperations(Session &session,
44 std::map<std::string, bool> const &operations) = 0;
45 virtual ErrorCode
46 onQuerySupported(Session &session, Feature::Collection const &remoteFeatures,
47 Feature::Collection &localFeatures) const = 0;
48
49 virtual ErrorCode onExecuteCommand(Session &session,
50 std::string const &command) = 0;
51
52 virtual ErrorCode onQueryServerVersion(Session &session,
53 ServerVersion &version) const = 0;
54 virtual ErrorCode onQueryHostInfo(Session &session, HostInfo &info) const = 0;
55
56 virtual ErrorCode onQueryFileLoadAddress(Session &session,
57 std::string const &file_path,
58 Address &address) = 0;
59
60protected: // Debugging Session
61 virtual ErrorCode onEnableControlAgent(Session &session, bool enable) = 0;
62 virtual ErrorCode onNonStopMode(Session &session, bool enable) = 0;
63 virtual ErrorCode onEnableBTSTracing(Session &session, bool enable) = 0;
64
65 virtual ErrorCode onPassSignals(Session &session,
66 std::vector<int> const &signals) = 0;
67 virtual ErrorCode onProgramSignals(Session &session,
68 std::vector<int> const &signals) = 0;
69
70 virtual ErrorCode onQuerySymbol(Session &session, std::string const &name,
71 std::string const &value,
72 std::string &next) const = 0;
73
74 virtual ErrorCode onQueryRegisterInfo(Session &session, uint32_t regno,
75 RegisterInfo &info) const = 0;
76
77 virtual ErrorCode onAttach(Session &session, ProcessId pid, AttachMode mode,
78 StopInfo &stop) = 0;
79 virtual ErrorCode onAttach(Session &session, std::string const &name,
80 AttachMode mode, StopInfo &stop) = 0;
81 virtual ErrorCode onRunAttach(Session &session, std::string const &filename,
82 StringCollection const &arguments,
83 StopInfo &stop) = 0;
84 virtual ErrorCode onDetach(Session &session, ProcessId pid, bool stopped) = 0;
85 virtual ErrorCode onQueryAttached(Session &session, ProcessId pid,
86 bool &attachedProcess) const = 0;
87 virtual ErrorCode onQueryProcessInfo(Session &session,
88 ProcessInfo &info) const = 0;
89 virtual ErrorCode onQueryThreadStopInfo(Session &session,
90 ProcessThreadId const &ptid,
91 StopInfo &stop) const = 0;
92
93 virtual ErrorCode onQueryHardwareWatchpointCount(Session &session,
94 size_t &count) const = 0;
95
96 virtual ErrorCode onQuerySectionOffsets(Session &session, Address &text,
97 Address &data,
98 bool &isSegment) const = 0;
99 virtual ErrorCode
100 onQuerySharedLibrariesInfoAddress(Session &session,
101 Address &address) const = 0;
102 virtual ErrorCode onQuerySharedLibraryInfo(Session &session,
103 std::string const &path,
104 std::string const &triple,
105 SharedLibraryInfo &info) const = 0;
106 virtual ErrorCode onQueryModuleInfo(Session &session, std::string &path,
107 std::string &triple,
108 ModuleInfo &info) const = 0;
109
110 virtual ErrorCode onRestart(Session &session, ProcessId pid) = 0;
111 virtual ErrorCode onInterrupt(Session &session) = 0;
112 virtual ErrorCode onTerminate(Session &session, ProcessThreadId const &ptid,
113 StopInfo &stop) = 0;
114 virtual ErrorCode onExitServer(Session &session) = 0;
115
116 virtual ErrorCode onSynchronizeThreadState(Session &session,
117 ProcessId pid) = 0;
118
119 //
120 // If lastTid is kAllThreadId, it's the first request; if it's kAnyThreadId
121 // the next of the previous request, in any other case the thread next to
122 // the one specified.
123 //
124 virtual ErrorCode onQueryThreadList(Session &session, ProcessId pid,
125 ThreadId lastTid,
126 ThreadId &tid) const = 0;
127
128 virtual ErrorCode onQueryCurrentThread(Session &session,
129 ProcessThreadId &ptid) const = 0;
130 virtual ErrorCode onThreadIsAlive(Session &session,
131 ProcessThreadId const &ptid) = 0;
132 virtual ErrorCode onQueryThreadInfo(Session &session,
133 ProcessThreadId const &ptid,
134 uint32_t mode, void *info) const = 0;
135
136 virtual ErrorCode onQueryTLSAddress(Session &session,
137 ProcessThreadId const &ptid,
138 Address const &offset,
139 Address const &linkMap,
140 Address &address) const = 0;
141 virtual ErrorCode onQueryTIBAddress(Session &session,
142 ProcessThreadId const &ptid,
143 Address &address) const = 0;
144
145 virtual ErrorCode onEnableAsynchronousProfiling(Session &session,
146 ProcessThreadId const &ptid,
147 bool enabled,
148 uint32_t interval,
149 uint32_t scanType) = 0;
150 virtual ErrorCode onQueryProfileData(Session &session,
151 ProcessThreadId const &ptid,
152 uint32_t scanType, void *data) const = 0;
153
154 virtual ErrorCode onResume(Session &session,
155 ThreadResumeAction::Collection const &actions,
156 StopInfo &stop) = 0;
157
158 virtual ErrorCode
159 onReadGeneralRegisters(Session &session, ProcessThreadId const &ptid,
160 Architecture::GPRegisterValueVector &regs) = 0;
161 virtual ErrorCode
162 onWriteGeneralRegisters(Session &session, ProcessThreadId const &ptid,
163 std::vector<uint64_t> const &regs) = 0;
164
165 virtual ErrorCode onSaveRegisters(Session &session,
166 ProcessThreadId const &ptid,
167 uint64_t &id) = 0;
168 virtual ErrorCode onRestoreRegisters(Session &session,
169 ProcessThreadId const &ptid,
170 uint64_t id) = 0;
171
172 virtual ErrorCode onReadRegisterValue(Session &session,
173 ProcessThreadId const &ptid,
174 uint32_t regno, std::string &value) = 0;
175 virtual ErrorCode onWriteRegisterValue(Session &session,
176 ProcessThreadId const &ptid,
177 uint32_t regno,
178 std::string const &value) = 0;
179
180 virtual ErrorCode onReadMemory(Session &session, Address const &address,
181 size_t length, ByteVector &data) = 0;
182 virtual ErrorCode onWriteMemory(Session &session, Address const &address,
183 ByteVector const &data, size_t &nwritten) = 0;
184
185 virtual ErrorCode onAllocateMemory(Session &session, size_t size,
186 uint32_t permissions,
187 Address &address) = 0;
188 virtual ErrorCode onDeallocateMemory(Session &session,
189 Address const &address) = 0;
190 virtual ErrorCode onQueryMemoryRegionInfo(Session &session,
191 Address const &address,
192 MemoryRegionInfo &info) const = 0;
193
194 virtual ErrorCode onComputeCRC(Session &session, Address const &address,
195 size_t length, uint32_t &crc) = 0;
196
197 virtual ErrorCode onSearch(Session &session, Address const &address,
198 std::string const &pattern, Address &location) = 0;
199 virtual ErrorCode onSearchBackward(Session &session, Address const &address,
200 uint32_t pattern, uint32_t mask,
201 Address &location) = 0;
202
203 virtual ErrorCode onInsertBreakpoint(Session &session, BreakpointType type,
204 Address const &address, uint32_t kind,
205 StringCollection const &conditions,
206 StringCollection const &commands,
207 bool persistentCommands) = 0;
208 virtual ErrorCode onRemoveBreakpoint(Session &session, BreakpointType type,
209 Address const &address,
210 uint32_t kind) = 0;
211
212 virtual ErrorCode onXferRead(Session &session, std::string const &object,
213 std::string const &annex, uint64_t offset,
214 uint64_t length, std::string &buffer,
215 bool &last) = 0;
216 virtual ErrorCode onXferWrite(Session &session, std::string const &object,
217 std::string const &annex, uint64_t offset,
218 std::string const &buffer,
219 size_t &nwritten) = 0;
220
221protected:
222 virtual ErrorCode fetchStopInfoForAllThreads(Session &session,
223 std::vector<StopInfo> &stops,
224 StopInfo &processStop) = 0;
225 virtual ErrorCode createThreadsStopInfo(Session &session,
226 JSArray &threadsStopInfo) = 0;
227
228protected: // Platform Session
229 virtual ErrorCode onDisableASLR(Session &session, bool disable) = 0;
230
231 virtual ErrorCode onSetEnvironmentVariable(Session &session,
232 std::string const &name,
233 std::string const &value) = 0;
234 virtual ErrorCode onSetWorkingDirectory(Session &session,
235 std::string const &path) = 0;
236 virtual ErrorCode onSetStdFile(Session &session, int fileno,
237 std::string const &path) = 0;
238
239 virtual ErrorCode onSetArchitecture(Session &session,
240 std::string const &architecture) = 0;
241
242 virtual ErrorCode onSetProgramArguments(Session &session,
243 StringCollection const &args) = 0;
244
245 virtual ErrorCode onExecuteProgram(Session &session,
246 std::string const &command,
247 uint32_t timeout,
248 std::string const &workingDirectory,
249 ProgramResult &result) = 0;
250
251 virtual ErrorCode onFileCreateDirectory(Session &session,
252 std::string const &path,
253 uint32_t mode) = 0;
254
255 virtual ErrorCode onFileOpen(Session &session, std::string const &path,
256 OpenFlags flags, uint32_t mode, int &fd) = 0;
257 virtual ErrorCode onFileClose(Session &session, int fd) = 0;
258 virtual ErrorCode onFileRead(Session &session, int fd, uint64_t &count,
259 uint64_t offset, ByteVector &buffer) = 0;
260 virtual ErrorCode onFileWrite(Session &session, int fd, uint64_t offset,
261 ByteVector const &buffer,
262 uint64_t &nwritten) = 0;
263
264 virtual ErrorCode onFileRemove(Session &session, std::string const &path) = 0;
265 virtual ErrorCode onFileReadLink(Session &session, std::string const &path,
266 std::string &resolved) = 0;
267 virtual ErrorCode onFileSetPermissions(Session &session,
268 std::string const &path,
269 uint32_t mode) = 0;
270 virtual ErrorCode onFileExists(Session &session, std::string const &path) = 0;
271 virtual ErrorCode onFileComputeMD5(Session &session, std::string const &path,
272 uint8_t digest[16]) = 0;
273 virtual ErrorCode onFileGetSize(Session &session, std::string const &path,
274 uint64_t &size) = 0;
275 virtual ErrorCode onFileGetMode(Session &session, std::string const &path,
276 uint32_t &mode) const = 0;
277 virtual ErrorCode onFileFstat(Session &session, int fd,
278 ByteVector &buffer) const = 0;
279
280 virtual ErrorCode onQueryProcessList(Session &session,
281 ProcessInfoMatch const &match,
282 bool first, ProcessInfo &info) const = 0;
283 virtual ErrorCode onQueryProcessInfoPID(Session &session, ProcessId pid,
284 ProcessInfo &info) const = 0;
285
286 virtual ErrorCode onLaunchDebugServer(Session &session,
287 std::string const &host, uint16_t &port,
288 ProcessId &pid) = 0;
289
290 virtual ErrorCode onQueryLaunchSuccess(Session &session,
291 ProcessId pid) const = 0;
292
293 virtual ErrorCode onQueryUserName(Session &session, UserId const &uid,
294 std::string &name) const = 0;
295 virtual ErrorCode onQueryGroupName(Session &session, GroupId const &gid,
296 std::string &name) const = 0;
297 virtual ErrorCode onQueryWorkingDirectory(Session &session,
298 std::string &workingDir) const = 0;
299
300protected: // System Session
301 virtual ErrorCode onReset(Session &session) = 0;
302 virtual ErrorCode onFlashErase(Session &session, Address const &address,
303 size_t length) = 0;
304 virtual ErrorCode onFlashWrite(Session &session, Address const &address,
305 ByteVector const &data) = 0;
306 virtual ErrorCode onFlashDone(Session &session) = 0;
307};
308} // namespace GDBRemote
309} // namespace ds2
Definition Types.h:95
Definition SessionDelegate.h:20
Definition Session.h:22
Definition Types.h:171
Definition Types.h:34
Definition Types.h:179
Definition Types.h:185
Definition Types.h:23
Definition Types.h:204
Definition Types.h:123
Definition Types.h:192
Definition Types.h:38
Definition Types.h:397