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