1//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
11
12#include "GDBRemoteClientBase.h"
13
14#include <chrono>
15#include <map>
16#include <mutex>
17#include <optional>
18#include <string>
19#include <vector>
20
21#include "lldb/Host/File.h"
22#include "lldb/Utility/AddressableBits.h"
23#include "lldb/Utility/ArchSpec.h"
24#include "lldb/Utility/GDBRemote.h"
25#include "lldb/Utility/ProcessInfo.h"
26#include "lldb/Utility/StructuredData.h"
27#include "lldb/Utility/TraceGDBRemotePackets.h"
28#include "lldb/Utility/UUID.h"
29#if defined(_WIN32)
30#include "lldb/Host/windows/PosixApi.h"
31#endif
32
33#include "llvm/Support/VersionTuple.h"
34
35namespace lldb_private {
36namespace process_gdb_remote {
37
38/// The offsets used by the target when relocating the executable. Decoded from
39/// qOffsets packet response.
40struct QOffsets {
41 /// If true, the offsets field describes segments. Otherwise, it describes
42 /// sections.
43 bool segments;
44
45 /// The individual offsets. Section offsets have two or three members.
46 /// Segment offsets have either one of two.
47 std::vector<uint64_t> offsets;
48};
49inline bool operator==(const QOffsets &a, const QOffsets &b) {
50 return a.segments == b.segments && a.offsets == b.offsets;
51}
52llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const QOffsets &offsets);
53
54// A trivial struct used to return a pair of PID and TID.
55struct PidTid {
56 uint64_t pid;
57 uint64_t tid;
58};
59
60class GDBRemoteCommunicationClient : public GDBRemoteClientBase {
61public:
62 GDBRemoteCommunicationClient();
63
64 ~GDBRemoteCommunicationClient() override;
65
66 // After connecting, send the handshake to the server to make sure
67 // we are communicating with it.
68 bool HandshakeWithServer(Status *error_ptr);
69
70 bool GetThreadSuffixSupported();
71
72 // This packet is usually sent first and the boolean return value
73 // indicates if the packet was send and any response was received
74 // even in the response is UNIMPLEMENTED. If the packet failed to
75 // get a response, then false is returned. This quickly tells us
76 // if we were able to connect and communicate with the remote GDB
77 // server
78 bool QueryNoAckModeSupported();
79
80 void GetListThreadsInStopReplySupported();
81
82 lldb::pid_t GetCurrentProcessID(bool allow_lazy = true);
83
84 bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid,
85 uint16_t &port, std::string &socket_name);
86
87 size_t QueryGDBServer(
88 std::vector<std::pair<uint16_t, std::string>> &connection_urls);
89
90 bool KillSpawnedProcess(lldb::pid_t pid);
91
92 /// Launch the process using the provided arguments.
93 ///
94 /// \param[in] args
95 /// A list of program arguments. The first entry is the program being run.
96 llvm::Error LaunchProcess(const Args &args);
97
98 /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
99 /// environment that will get used when launching an application
100 /// in conjunction with the 'A' packet. This function can be called
101 /// multiple times in a row in order to pass on the desired
102 /// environment that the inferior should be launched with.
103 ///
104 /// \param[in] name_equal_value
105 /// A NULL terminated C string that contains a single environment
106 /// in the format "NAME=VALUE".
107 ///
108 /// \return
109 /// Zero if the response was "OK", a positive value if the
110 /// the response was "Exx" where xx are two hex digits, or
111 /// -1 if the call is unsupported or any other unexpected
112 /// response was received.
113 int SendEnvironmentPacket(char const *name_equal_value);
114 int SendEnvironment(const Environment &env);
115
116 int SendLaunchArchPacket(const char *arch);
117
118 int SendLaunchEventDataPacket(const char *data,
119 bool *was_supported = nullptr);
120
121 /// Sends a GDB remote protocol 'I' packet that delivers stdin
122 /// data to the remote process.
123 ///
124 /// \param[in] data
125 /// A pointer to stdin data.
126 ///
127 /// \param[in] data_len
128 /// The number of bytes available at \a data.
129 ///
130 /// \return
131 /// Zero if the attach was successful, or an error indicating
132 /// an error code.
133 int SendStdinNotification(const char *data, size_t data_len);
134
135 /// Sets the path to use for stdin/out/err for a process
136 /// that will be launched with the 'A' packet.
137 ///
138 /// \param[in] file_spec
139 /// The path to use for stdin/out/err
140 ///
141 /// \return
142 /// Zero if the for success, or an error code for failure.
143 int SetSTDIN(const FileSpec &file_spec);
144 int SetSTDOUT(const FileSpec &file_spec);
145 int SetSTDERR(const FileSpec &file_spec);
146
147 /// Sets the disable ASLR flag to \a enable for a process that will
148 /// be launched with the 'A' packet.
149 ///
150 /// \param[in] enable
151 /// A boolean value indicating whether to disable ASLR or not.
152 ///
153 /// \return
154 /// Zero if the for success, or an error code for failure.
155 int SetDisableASLR(bool enable);
156
157 /// Sets the DetachOnError flag to \a enable for the process controlled by the
158 /// stub.
159 ///
160 /// \param[in] enable
161 /// A boolean value indicating whether to detach on error or not.
162 ///
163 /// \return
164 /// Zero if the for success, or an error code for failure.
165 int SetDetachOnError(bool enable);
166
167 /// Sets the working directory to \a path for a process that will
168 /// be launched with the 'A' packet for non platform based
169 /// connections. If this packet is sent to a GDB server that
170 /// implements the platform, it will change the current working
171 /// directory for the platform process.
172 ///
173 /// \param[in] working_dir
174 /// The path to a directory to use when launching our process
175 ///
176 /// \return
177 /// Zero if the for success, or an error code for failure.
178 int SetWorkingDir(const FileSpec &working_dir);
179
180 /// Gets the current working directory of a remote platform GDB
181 /// server.
182 ///
183 /// \param[out] working_dir
184 /// The current working directory on the remote platform.
185 ///
186 /// \return
187 /// Boolean for success
188 bool GetWorkingDir(FileSpec &working_dir);
189
190 lldb::addr_t AllocateMemory(size_t size, uint32_t permissions);
191
192 bool DeallocateMemory(lldb::addr_t addr);
193
194 Status Detach(bool keep_stopped, lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
195
196 Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info);
197
198 std::optional<uint32_t> GetWatchpointSlotCount();
199
200 std::optional<bool> GetWatchpointReportedAfter();
201
202 WatchpointHardwareFeature GetSupportedWatchpointTypes();
203
204 const ArchSpec &GetHostArchitecture();
205
206 std::chrono::seconds GetHostDefaultPacketTimeout();
207
208 const ArchSpec &GetProcessArchitecture();
209
210 bool GetProcessStandaloneBinary(UUID &uuid, lldb::addr_t &value,
211 bool &value_is_offset);
212
213 std::vector<lldb::addr_t> GetProcessStandaloneBinaries();
214
215 void GetRemoteQSupported();
216
217 bool GetVContSupported(char flavor);
218
219 bool GetpPacketSupported(lldb::tid_t tid);
220
221 bool GetxPacketSupported();
222
223 bool GetVAttachOrWaitSupported();
224
225 bool GetSyncThreadStateSupported();
226
227 void ResetDiscoverableSettings(bool did_exec);
228
229 bool GetHostInfo(bool force = false);
230
231 bool GetDefaultThreadId(lldb::tid_t &tid);
232
233 llvm::VersionTuple GetOSVersion();
234
235 llvm::VersionTuple GetMacCatalystVersion();
236
237 std::optional<std::string> GetOSBuildString();
238
239 std::optional<std::string> GetOSKernelDescription();
240
241 ArchSpec GetSystemArchitecture();
242
243 lldb_private::AddressableBits GetAddressableBits();
244
245 bool GetHostname(std::string &s);
246
247 lldb::addr_t GetShlibInfoAddr();
248
249 bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info);
250
251 uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info,
252 ProcessInstanceInfoList &process_infos);
253
254 bool GetUserName(uint32_t uid, std::string &name);
255
256 bool GetGroupName(uint32_t gid, std::string &name);
257
258 bool HasFullVContSupport() { return GetVContSupported(flavor: 'A'); }
259
260 bool HasAnyVContSupport() { return GetVContSupported(flavor: 'a'); }
261
262 bool GetStopReply(StringExtractorGDBRemote &response);
263
264 bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response);
265
266 bool SupportsGDBStoppointPacket(GDBStoppointType type) {
267 switch (type) {
268 case eBreakpointSoftware:
269 return m_supports_z0;
270 case eBreakpointHardware:
271 return m_supports_z1;
272 case eWatchpointWrite:
273 return m_supports_z2;
274 case eWatchpointRead:
275 return m_supports_z3;
276 case eWatchpointReadWrite:
277 return m_supports_z4;
278 default:
279 return false;
280 }
281 }
282
283 uint8_t SendGDBStoppointTypePacket(
284 GDBStoppointType type, // Type of breakpoint or watchpoint
285 bool insert, // Insert or remove?
286 lldb::addr_t addr, // Address of breakpoint or watchpoint
287 uint32_t length, // Byte Size of breakpoint or watchpoint
288 std::chrono::seconds interrupt_timeout); // Time to wait for an interrupt
289
290 void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send,
291 uint32_t max_recv, uint64_t recv_amount, bool json,
292 Stream &strm);
293
294 // This packet is for testing the speed of the interface only. Both
295 // the client and server need to support it, but this allows us to
296 // measure the packet speed without any other work being done on the
297 // other end and avoids any of that work affecting the packet send
298 // and response times.
299 bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size);
300
301 std::optional<PidTid> SendSetCurrentThreadPacket(uint64_t tid, uint64_t pid,
302 char op);
303
304 bool SetCurrentThread(uint64_t tid,
305 lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
306
307 bool SetCurrentThreadForRun(uint64_t tid,
308 lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
309
310 bool GetQXferAuxvReadSupported();
311
312 void EnableErrorStringInPacket();
313
314 bool GetQXferLibrariesReadSupported();
315
316 bool GetQXferLibrariesSVR4ReadSupported();
317
318 uint64_t GetRemoteMaxPacketSize();
319
320 bool GetEchoSupported();
321
322 bool GetQPassSignalsSupported();
323
324 bool GetAugmentedLibrariesSVR4ReadSupported();
325
326 bool GetQXferFeaturesReadSupported();
327
328 bool GetQXferMemoryMapReadSupported();
329
330 bool GetQXferSigInfoReadSupported();
331
332 bool GetMultiprocessSupported();
333
334 LazyBool SupportsAllocDeallocMemory() // const
335 {
336 // Uncomment this to have lldb pretend the debug server doesn't respond to
337 // alloc/dealloc memory packets.
338 // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;
339 return m_supports_alloc_dealloc_memory;
340 }
341
342 std::vector<std::pair<lldb::pid_t, lldb::tid_t>>
343 GetCurrentProcessAndThreadIDs(bool &sequence_mutex_unavailable);
344
345 size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids,
346 bool &sequence_mutex_unavailable);
347
348 lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags,
349 mode_t mode, Status &error);
350
351 bool CloseFile(lldb::user_id_t fd, Status &error);
352
353 std::optional<GDBRemoteFStatData> FStat(lldb::user_id_t fd);
354
355 // NB: this is just a convenience wrapper over open() + fstat(). It does not
356 // work if the file cannot be opened.
357 std::optional<GDBRemoteFStatData> Stat(const FileSpec &file_spec);
358
359 lldb::user_id_t GetFileSize(const FileSpec &file_spec);
360
361 void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,
362 bool only_dir);
363
364 Status GetFilePermissions(const FileSpec &file_spec,
365 uint32_t &file_permissions);
366
367 Status SetFilePermissions(const FileSpec &file_spec,
368 uint32_t file_permissions);
369
370 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
371 uint64_t dst_len, Status &error);
372
373 uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
374 uint64_t src_len, Status &error);
375
376 Status CreateSymlink(const FileSpec &src, const FileSpec &dst);
377
378 Status Unlink(const FileSpec &file_spec);
379
380 Status MakeDirectory(const FileSpec &file_spec, uint32_t mode);
381
382 bool GetFileExists(const FileSpec &file_spec);
383
384 Status RunShellCommand(
385 llvm::StringRef command,
386 const FileSpec &working_dir, // Pass empty FileSpec to use the current
387 // working directory
388 int *status_ptr, // Pass nullptr if you don't want the process exit status
389 int *signo_ptr, // Pass nullptr if you don't want the signal that caused
390 // the process to exit
391 std::string
392 *command_output, // Pass nullptr if you don't want the command output
393 const Timeout<std::micro> &timeout);
394
395 bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
396
397 lldb::DataBufferSP ReadRegister(
398 lldb::tid_t tid,
399 uint32_t
400 reg_num); // Must be the eRegisterKindProcessPlugin register number
401
402 lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid);
403
404 bool
405 WriteRegister(lldb::tid_t tid,
406 uint32_t reg_num, // eRegisterKindProcessPlugin register number
407 llvm::ArrayRef<uint8_t> data);
408
409 bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data);
410
411 bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id);
412
413 bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id);
414
415 bool SyncThreadState(lldb::tid_t tid);
416
417 const char *GetGDBServerProgramName();
418
419 uint32_t GetGDBServerProgramVersion();
420
421 bool AvoidGPackets(ProcessGDBRemote *process);
422
423 StructuredData::ObjectSP GetThreadsInfo();
424
425 bool GetThreadExtendedInfoSupported();
426
427 bool GetLoadedDynamicLibrariesInfosSupported();
428
429 bool GetSharedCacheInfoSupported();
430
431 bool GetDynamicLoaderProcessStateSupported();
432
433 bool GetMemoryTaggingSupported();
434
435 bool UsesNativeSignals();
436
437 lldb::DataBufferSP ReadMemoryTags(lldb::addr_t addr, size_t len,
438 int32_t type);
439
440 Status WriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type,
441 const std::vector<uint8_t> &tags);
442
443 /// Use qOffsets to query the offset used when relocating the target
444 /// executable. If successful, the returned structure will contain at least
445 /// one value in the offsets field.
446 std::optional<QOffsets> GetQOffsets();
447
448 bool GetModuleInfo(const FileSpec &module_file_spec,
449 const ArchSpec &arch_spec, ModuleSpec &module_spec);
450
451 std::optional<std::vector<ModuleSpec>>
452 GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs,
453 const llvm::Triple &triple);
454
455 llvm::Expected<std::string> ReadExtFeature(llvm::StringRef object,
456 llvm::StringRef annex);
457
458 void ServeSymbolLookups(lldb_private::Process *process);
459
460 // Sends QPassSignals packet to the server with given signals to ignore.
461 Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals);
462
463 /// Return the feature set supported by the gdb-remote server.
464 ///
465 /// This method returns the remote side's response to the qSupported
466 /// packet. The response is the complete string payload returned
467 /// to the client.
468 ///
469 /// \return
470 /// The string returned by the server to the qSupported query.
471 const std::string &GetServerSupportedFeatures() const {
472 return m_qSupported_response;
473 }
474
475 /// Return the array of async JSON packet types supported by the remote.
476 ///
477 /// This method returns the remote side's array of supported JSON
478 /// packet types as a list of type names. Each of the results are
479 /// expected to have an Enable{type_name} command to enable and configure
480 /// the related feature. Each type_name for an enabled feature will
481 /// possibly send async-style packets that contain a payload of a
482 /// binhex-encoded JSON dictionary. The dictionary will have a
483 /// string field named 'type', that contains the type_name of the
484 /// supported packet type.
485 ///
486 /// There is a Plugin category called structured-data plugins.
487 /// A plugin indicates whether it knows how to handle a type_name.
488 /// If so, it can be used to process the async JSON packet.
489 ///
490 /// \return
491 /// The string returned by the server to the qSupported query.
492 lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins();
493
494 /// Configure a StructuredData feature on the remote end.
495 ///
496 /// \see \b Process::ConfigureStructuredData(...) for details.
497 Status
498 ConfigureRemoteStructuredData(llvm::StringRef type_name,
499 const StructuredData::ObjectSP &config_sp);
500
501 llvm::Expected<TraceSupportedResponse>
502 SendTraceSupported(std::chrono::seconds interrupt_timeout);
503
504 llvm::Error SendTraceStart(const llvm::json::Value &request,
505 std::chrono::seconds interrupt_timeout);
506
507 llvm::Error SendTraceStop(const TraceStopRequest &request,
508 std::chrono::seconds interrupt_timeout);
509
510 llvm::Expected<std::string>
511 SendTraceGetState(llvm::StringRef type,
512 std::chrono::seconds interrupt_timeout);
513
514 llvm::Expected<std::vector<uint8_t>>
515 SendTraceGetBinaryData(const TraceGetBinaryDataRequest &request,
516 std::chrono::seconds interrupt_timeout);
517
518 bool GetSaveCoreSupported() const;
519
520 llvm::Expected<int> KillProcess(lldb::pid_t pid);
521
522protected:
523 LazyBool m_supports_not_sending_acks = eLazyBoolCalculate;
524 LazyBool m_supports_thread_suffix = eLazyBoolCalculate;
525 LazyBool m_supports_threads_in_stop_reply = eLazyBoolCalculate;
526 LazyBool m_supports_vCont_all = eLazyBoolCalculate;
527 LazyBool m_supports_vCont_any = eLazyBoolCalculate;
528 LazyBool m_supports_vCont_c = eLazyBoolCalculate;
529 LazyBool m_supports_vCont_C = eLazyBoolCalculate;
530 LazyBool m_supports_vCont_s = eLazyBoolCalculate;
531 LazyBool m_supports_vCont_S = eLazyBoolCalculate;
532 LazyBool m_qHostInfo_is_valid = eLazyBoolCalculate;
533 LazyBool m_curr_pid_is_valid = eLazyBoolCalculate;
534 LazyBool m_qProcessInfo_is_valid = eLazyBoolCalculate;
535 LazyBool m_qGDBServerVersion_is_valid = eLazyBoolCalculate;
536 LazyBool m_supports_alloc_dealloc_memory = eLazyBoolCalculate;
537 LazyBool m_supports_memory_region_info = eLazyBoolCalculate;
538 LazyBool m_supports_watchpoint_support_info = eLazyBoolCalculate;
539 LazyBool m_supports_detach_stay_stopped = eLazyBoolCalculate;
540 LazyBool m_watchpoints_trigger_after_instruction = eLazyBoolCalculate;
541 LazyBool m_attach_or_wait_reply = eLazyBoolCalculate;
542 LazyBool m_prepare_for_reg_writing_reply = eLazyBoolCalculate;
543 LazyBool m_supports_p = eLazyBoolCalculate;
544 LazyBool m_supports_x = eLazyBoolCalculate;
545 LazyBool m_avoid_g_packets = eLazyBoolCalculate;
546 LazyBool m_supports_QSaveRegisterState = eLazyBoolCalculate;
547 LazyBool m_supports_qXfer_auxv_read = eLazyBoolCalculate;
548 LazyBool m_supports_qXfer_libraries_read = eLazyBoolCalculate;
549 LazyBool m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate;
550 LazyBool m_supports_qXfer_features_read = eLazyBoolCalculate;
551 LazyBool m_supports_qXfer_memory_map_read = eLazyBoolCalculate;
552 LazyBool m_supports_qXfer_siginfo_read = eLazyBoolCalculate;
553 LazyBool m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate;
554 LazyBool m_supports_jThreadExtendedInfo = eLazyBoolCalculate;
555 LazyBool m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolCalculate;
556 LazyBool m_supports_jGetSharedCacheInfo = eLazyBoolCalculate;
557 LazyBool m_supports_jGetDyldProcessState = eLazyBoolCalculate;
558 LazyBool m_supports_QPassSignals = eLazyBoolCalculate;
559 LazyBool m_supports_error_string_reply = eLazyBoolCalculate;
560 LazyBool m_supports_multiprocess = eLazyBoolCalculate;
561 LazyBool m_supports_memory_tagging = eLazyBoolCalculate;
562 LazyBool m_supports_qSaveCore = eLazyBoolCalculate;
563 LazyBool m_uses_native_signals = eLazyBoolCalculate;
564
565 bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1,
566 m_supports_qUserName : 1, m_supports_qGroupName : 1,
567 m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1,
568 m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1,
569 m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1,
570 m_supports_qSymbol : 1, m_qSymbol_requests_done : 1,
571 m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1,
572 m_supports_jModulesInfo : 1, m_supports_vFileSize : 1,
573 m_supports_vFileMode : 1, m_supports_vFileExists : 1,
574 m_supports_vRun : 1;
575
576 /// Current gdb remote protocol process identifier for all other operations
577 lldb::pid_t m_curr_pid = LLDB_INVALID_PROCESS_ID;
578 /// Current gdb remote protocol process identifier for continue, step, etc
579 lldb::pid_t m_curr_pid_run = LLDB_INVALID_PROCESS_ID;
580 /// Current gdb remote protocol thread identifier for all other operations
581 lldb::tid_t m_curr_tid = LLDB_INVALID_THREAD_ID;
582 /// Current gdb remote protocol thread identifier for continue, step, etc
583 lldb::tid_t m_curr_tid_run = LLDB_INVALID_THREAD_ID;
584
585 uint32_t m_num_supported_hardware_watchpoints = 0;
586 WatchpointHardwareFeature m_watchpoint_types =
587 eWatchpointHardwareFeatureUnknown;
588 uint32_t m_low_mem_addressing_bits = 0;
589 uint32_t m_high_mem_addressing_bits = 0;
590
591 ArchSpec m_host_arch;
592 std::string m_host_distribution_id;
593 ArchSpec m_process_arch;
594 UUID m_process_standalone_uuid;
595 lldb::addr_t m_process_standalone_value = LLDB_INVALID_ADDRESS;
596 bool m_process_standalone_value_is_offset = false;
597 std::vector<lldb::addr_t> m_binary_addresses;
598 llvm::VersionTuple m_os_version;
599 llvm::VersionTuple m_maccatalyst_version;
600 std::string m_os_build;
601 std::string m_os_kernel;
602 std::string m_hostname;
603 std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if
604 // qGDBServerVersion is not supported
605 uint32_t m_gdb_server_version =
606 UINT32_MAX; // from reply to qGDBServerVersion, zero if
607 // qGDBServerVersion is not supported
608 std::chrono::seconds m_default_packet_timeout;
609 int m_target_vm_page_size = 0; // target system VM page size; 0 unspecified
610 uint64_t m_max_packet_size = 0; // as returned by qSupported
611 std::string m_qSupported_response; // the complete response to qSupported
612
613 bool m_supported_async_json_packets_is_valid = false;
614 lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp;
615
616 std::vector<MemoryRegionInfo> m_qXfer_memory_map;
617 bool m_qXfer_memory_map_loaded = false;
618
619 bool GetCurrentProcessInfo(bool allow_lazy_pid = true);
620
621 bool GetGDBServerVersion();
622
623 // Given the list of compression types that the remote debug stub can support,
624 // possibly enable compression if we find an encoding we can handle.
625 void MaybeEnableCompression(
626 llvm::ArrayRef<llvm::StringRef> supported_compressions);
627
628 bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response,
629 ProcessInstanceInfo &process_info);
630
631 void OnRunPacketSent(bool first) override;
632
633 PacketResult SendThreadSpecificPacketAndWaitForResponse(
634 lldb::tid_t tid, StreamString &&payload,
635 StringExtractorGDBRemote &response);
636
637 Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid,
638 lldb::tid_t thread_id,
639 llvm::MutableArrayRef<uint8_t> &buffer,
640 size_t offset);
641
642 Status LoadQXferMemoryMap();
643
644 Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr,
645 MemoryRegionInfo &region);
646
647 LazyBool GetThreadPacketSupported(lldb::tid_t tid, llvm::StringRef packetStr);
648
649private:
650 GDBRemoteCommunicationClient(const GDBRemoteCommunicationClient &) = delete;
651 const GDBRemoteCommunicationClient &
652 operator=(const GDBRemoteCommunicationClient &) = delete;
653};
654
655} // namespace process_gdb_remote
656} // namespace lldb_private
657
658#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
659

source code of lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h