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