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 bool GetProcessStandaloneBinary(UUID &uuid, lldb::addr_t &value, 221 bool &value_is_offset); 222 223 void GetRemoteQSupported(); 224 225 bool GetVContSupported(char flavor); 226 227 bool GetpPacketSupported(lldb::tid_t tid); 228 229 bool GetxPacketSupported(); 230 231 bool GetVAttachOrWaitSupported(); 232 233 bool GetSyncThreadStateSupported(); 234 235 void ResetDiscoverableSettings(bool did_exec); 236 237 bool GetHostInfo(bool force = false); 238 239 bool GetDefaultThreadId(lldb::tid_t &tid); 240 241 llvm::VersionTuple GetOSVersion(); 242 243 llvm::VersionTuple GetMacCatalystVersion(); 244 245 llvm::Optional<std::string> GetOSBuildString(); 246 247 llvm::Optional<std::string> GetOSKernelDescription(); 248 249 ArchSpec GetSystemArchitecture(); 250 251 uint32_t GetAddressingBits(); 252 253 bool GetHostname(std::string &s); 254 255 lldb::addr_t GetShlibInfoAddr(); 256 257 bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info); 258 259 uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, 260 ProcessInstanceInfoList &process_infos); 261 262 bool GetUserName(uint32_t uid, std::string &name); 263 264 bool GetGroupName(uint32_t gid, std::string &name); 265 266 bool HasFullVContSupport() { return GetVContSupported('A'); } 267 268 bool HasAnyVContSupport() { return GetVContSupported('a'); } 269 270 bool GetStopReply(StringExtractorGDBRemote &response); 271 272 bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response); 273 274 bool SupportsGDBStoppointPacket(GDBStoppointType type) { 275 switch (type) { 276 case eBreakpointSoftware: 277 return m_supports_z0; 278 case eBreakpointHardware: 279 return m_supports_z1; 280 case eWatchpointWrite: 281 return m_supports_z2; 282 case eWatchpointRead: 283 return m_supports_z3; 284 case eWatchpointReadWrite: 285 return m_supports_z4; 286 default: 287 return false; 288 } 289 } 290 291 uint8_t SendGDBStoppointTypePacket( 292 GDBStoppointType type, // Type of breakpoint or watchpoint 293 bool insert, // Insert or remove? 294 lldb::addr_t addr, // Address of breakpoint or watchpoint 295 uint32_t length, // Byte Size of breakpoint or watchpoint 296 std::chrono::seconds interrupt_timeout); // Time to wait for an interrupt 297 298 void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, 299 uint32_t max_recv, uint64_t recv_amount, bool json, 300 Stream &strm); 301 302 // This packet is for testing the speed of the interface only. Both 303 // the client and server need to support it, but this allows us to 304 // measure the packet speed without any other work being done on the 305 // other end and avoids any of that work affecting the packet send 306 // and response times. 307 bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); 308 309 llvm::Optional<PidTid> 310 SendSetCurrentThreadPacket(uint64_t tid, uint64_t pid, char op); 311 312 bool SetCurrentThread(uint64_t tid, 313 lldb::pid_t pid = LLDB_INVALID_PROCESS_ID); 314 315 bool SetCurrentThreadForRun(uint64_t tid, 316 lldb::pid_t pid = LLDB_INVALID_PROCESS_ID); 317 318 bool GetQXferAuxvReadSupported(); 319 320 void EnableErrorStringInPacket(); 321 322 bool GetQXferLibrariesReadSupported(); 323 324 bool GetQXferLibrariesSVR4ReadSupported(); 325 326 uint64_t GetRemoteMaxPacketSize(); 327 328 bool GetEchoSupported(); 329 330 bool GetQPassSignalsSupported(); 331 332 bool GetAugmentedLibrariesSVR4ReadSupported(); 333 334 bool GetQXferFeaturesReadSupported(); 335 336 bool GetQXferMemoryMapReadSupported(); 337 338 bool GetQXferSigInfoReadSupported(); 339 340 LazyBool SupportsAllocDeallocMemory() // const 341 { 342 // Uncomment this to have lldb pretend the debug server doesn't respond to 343 // alloc/dealloc memory packets. 344 // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; 345 return m_supports_alloc_dealloc_memory; 346 } 347 348 std::vector<std::pair<lldb::pid_t, lldb::tid_t>> 349 GetCurrentProcessAndThreadIDs(bool &sequence_mutex_unavailable); 350 351 size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids, 352 bool &sequence_mutex_unavailable); 353 354 lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, 355 mode_t mode, Status &error); 356 357 bool CloseFile(lldb::user_id_t fd, Status &error); 358 359 llvm::Optional<GDBRemoteFStatData> FStat(lldb::user_id_t fd); 360 361 // NB: this is just a convenience wrapper over open() + fstat(). It does not 362 // work if the file cannot be opened. 363 llvm::Optional<GDBRemoteFStatData> Stat(const FileSpec &file_spec); 364 365 lldb::user_id_t GetFileSize(const FileSpec &file_spec); 366 367 void AutoCompleteDiskFileOrDirectory(CompletionRequest &request, 368 bool only_dir); 369 370 Status GetFilePermissions(const FileSpec &file_spec, 371 uint32_t &file_permissions); 372 373 Status SetFilePermissions(const FileSpec &file_spec, 374 uint32_t file_permissions); 375 376 uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, 377 uint64_t dst_len, Status &error); 378 379 uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, 380 uint64_t src_len, Status &error); 381 382 Status CreateSymlink(const FileSpec &src, const FileSpec &dst); 383 384 Status Unlink(const FileSpec &file_spec); 385 386 Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); 387 388 bool GetFileExists(const FileSpec &file_spec); 389 390 Status RunShellCommand( 391 llvm::StringRef command, 392 const FileSpec &working_dir, // Pass empty FileSpec to use the current 393 // working directory 394 int *status_ptr, // Pass nullptr if you don't want the process exit status 395 int *signo_ptr, // Pass nullptr if you don't want the signal that caused 396 // the process to exit 397 std::string 398 *command_output, // Pass nullptr if you don't want the command output 399 const Timeout<std::micro> &timeout); 400 401 bool CalculateMD5(const FileSpec &file_spec, uint64_t &high, uint64_t &low); 402 403 lldb::DataBufferSP ReadRegister( 404 lldb::tid_t tid, 405 uint32_t 406 reg_num); // Must be the eRegisterKindProcessPlugin register number 407 408 lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid); 409 410 bool 411 WriteRegister(lldb::tid_t tid, 412 uint32_t reg_num, // eRegisterKindProcessPlugin register number 413 llvm::ArrayRef<uint8_t> data); 414 415 bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data); 416 417 bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id); 418 419 bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id); 420 421 bool SyncThreadState(lldb::tid_t tid); 422 423 const char *GetGDBServerProgramName(); 424 425 uint32_t GetGDBServerProgramVersion(); 426 427 bool AvoidGPackets(ProcessGDBRemote *process); 428 429 StructuredData::ObjectSP GetThreadsInfo(); 430 431 bool GetThreadExtendedInfoSupported(); 432 433 bool GetLoadedDynamicLibrariesInfosSupported(); 434 435 bool GetSharedCacheInfoSupported(); 436 437 bool GetMemoryTaggingSupported(); 438 439 bool UsesNativeSignals(); 440 441 lldb::DataBufferSP ReadMemoryTags(lldb::addr_t addr, size_t len, 442 int32_t type); 443 444 Status WriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, 445 const std::vector<uint8_t> &tags); 446 447 /// Use qOffsets to query the offset used when relocating the target 448 /// executable. If successful, the returned structure will contain at least 449 /// one value in the offsets field. 450 llvm::Optional<QOffsets> GetQOffsets(); 451 452 bool GetModuleInfo(const FileSpec &module_file_spec, 453 const ArchSpec &arch_spec, ModuleSpec &module_spec); 454 455 llvm::Optional<std::vector<ModuleSpec>> 456 GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs, 457 const llvm::Triple &triple); 458 459 llvm::Expected<std::string> ReadExtFeature(llvm::StringRef object, 460 llvm::StringRef annex); 461 462 void ServeSymbolLookups(lldb_private::Process *process); 463 464 // Sends QPassSignals packet to the server with given signals to ignore. 465 Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); 466 467 /// Return the feature set supported by the gdb-remote server. 468 /// 469 /// This method returns the remote side's response to the qSupported 470 /// packet. The response is the complete string payload returned 471 /// to the client. 472 /// 473 /// \return 474 /// The string returned by the server to the qSupported query. 475 const std::string &GetServerSupportedFeatures() const { 476 return m_qSupported_response; 477 } 478 479 /// Return the array of async JSON packet types supported by the remote. 480 /// 481 /// This method returns the remote side's array of supported JSON 482 /// packet types as a list of type names. Each of the results are 483 /// expected to have an Enable{type_name} command to enable and configure 484 /// the related feature. Each type_name for an enabled feature will 485 /// possibly send async-style packets that contain a payload of a 486 /// binhex-encoded JSON dictionary. The dictionary will have a 487 /// string field named 'type', that contains the type_name of the 488 /// supported packet type. 489 /// 490 /// There is a Plugin category called structured-data plugins. 491 /// A plugin indicates whether it knows how to handle a type_name. 492 /// If so, it can be used to process the async JSON packet. 493 /// 494 /// \return 495 /// The string returned by the server to the qSupported query. 496 lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins(); 497 498 /// Configure a StructuredData feature on the remote end. 499 /// 500 /// \see \b Process::ConfigureStructuredData(...) for details. 501 Status 502 ConfigureRemoteStructuredData(ConstString type_name, 503 const StructuredData::ObjectSP &config_sp); 504 505 llvm::Expected<TraceSupportedResponse> 506 SendTraceSupported(std::chrono::seconds interrupt_timeout); 507 508 llvm::Error SendTraceStart(const llvm::json::Value &request, 509 std::chrono::seconds interrupt_timeout); 510 511 llvm::Error SendTraceStop(const TraceStopRequest &request, 512 std::chrono::seconds interrupt_timeout); 513 514 llvm::Expected<std::string> 515 SendTraceGetState(llvm::StringRef type, 516 std::chrono::seconds interrupt_timeout); 517 518 llvm::Expected<std::vector<uint8_t>> 519 SendTraceGetBinaryData(const TraceGetBinaryDataRequest &request, 520 std::chrono::seconds interrupt_timeout); 521 522 bool GetSaveCoreSupported() const; 523 524 llvm::Expected<int> KillProcess(lldb::pid_t pid); 525 526 protected: 527 LazyBool m_supports_not_sending_acks = eLazyBoolCalculate; 528 LazyBool m_supports_thread_suffix = eLazyBoolCalculate; 529 LazyBool m_supports_threads_in_stop_reply = eLazyBoolCalculate; 530 LazyBool m_supports_vCont_all = eLazyBoolCalculate; 531 LazyBool m_supports_vCont_any = eLazyBoolCalculate; 532 LazyBool m_supports_vCont_c = eLazyBoolCalculate; 533 LazyBool m_supports_vCont_C = eLazyBoolCalculate; 534 LazyBool m_supports_vCont_s = eLazyBoolCalculate; 535 LazyBool m_supports_vCont_S = eLazyBoolCalculate; 536 LazyBool m_qHostInfo_is_valid = eLazyBoolCalculate; 537 LazyBool m_curr_pid_is_valid = eLazyBoolCalculate; 538 LazyBool m_qProcessInfo_is_valid = eLazyBoolCalculate; 539 LazyBool m_qGDBServerVersion_is_valid = eLazyBoolCalculate; 540 LazyBool m_supports_alloc_dealloc_memory = eLazyBoolCalculate; 541 LazyBool m_supports_memory_region_info = eLazyBoolCalculate; 542 LazyBool m_supports_watchpoint_support_info = eLazyBoolCalculate; 543 LazyBool m_supports_detach_stay_stopped = eLazyBoolCalculate; 544 LazyBool m_watchpoints_trigger_after_instruction = eLazyBoolCalculate; 545 LazyBool m_attach_or_wait_reply = eLazyBoolCalculate; 546 LazyBool m_prepare_for_reg_writing_reply = eLazyBoolCalculate; 547 LazyBool m_supports_p = eLazyBoolCalculate; 548 LazyBool m_supports_x = eLazyBoolCalculate; 549 LazyBool m_avoid_g_packets = eLazyBoolCalculate; 550 LazyBool m_supports_QSaveRegisterState = eLazyBoolCalculate; 551 LazyBool m_supports_qXfer_auxv_read = eLazyBoolCalculate; 552 LazyBool m_supports_qXfer_libraries_read = eLazyBoolCalculate; 553 LazyBool m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate; 554 LazyBool m_supports_qXfer_features_read = eLazyBoolCalculate; 555 LazyBool m_supports_qXfer_memory_map_read = eLazyBoolCalculate; 556 LazyBool m_supports_qXfer_siginfo_read = eLazyBoolCalculate; 557 LazyBool m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; 558 LazyBool m_supports_jThreadExtendedInfo = eLazyBoolCalculate; 559 LazyBool m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolCalculate; 560 LazyBool m_supports_jGetSharedCacheInfo = eLazyBoolCalculate; 561 LazyBool m_supports_QPassSignals = eLazyBoolCalculate; 562 LazyBool m_supports_error_string_reply = eLazyBoolCalculate; 563 LazyBool m_supports_multiprocess = eLazyBoolCalculate; 564 LazyBool m_supports_memory_tagging = eLazyBoolCalculate; 565 LazyBool m_supports_qSaveCore = eLazyBoolCalculate; 566 LazyBool m_uses_native_signals = 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, m_supports_vFileSize : 1, 576 m_supports_vFileMode : 1, m_supports_vFileExists : 1, 577 m_supports_vRun : 1; 578 579 /// Current gdb remote protocol process identifier for all other operations 580 lldb::pid_t m_curr_pid = LLDB_INVALID_PROCESS_ID; 581 /// Current gdb remote protocol process identifier for continue, step, etc 582 lldb::pid_t m_curr_pid_run = LLDB_INVALID_PROCESS_ID; 583 /// Current gdb remote protocol thread identifier for all other operations 584 lldb::tid_t m_curr_tid = LLDB_INVALID_THREAD_ID; 585 /// Current gdb remote protocol thread identifier for continue, step, etc 586 lldb::tid_t m_curr_tid_run = LLDB_INVALID_THREAD_ID; 587 588 uint32_t m_num_supported_hardware_watchpoints = 0; 589 uint32_t m_addressing_bits = 0; 590 591 ArchSpec m_host_arch; 592 ArchSpec m_process_arch; 593 UUID m_process_standalone_uuid; 594 lldb::addr_t m_process_standalone_value = LLDB_INVALID_ADDRESS; 595 bool m_process_standalone_value_is_offset = false; 596 llvm::VersionTuple m_os_version; 597 llvm::VersionTuple m_maccatalyst_version; 598 std::string m_os_build; 599 std::string m_os_kernel; 600 std::string m_hostname; 601 std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if 602 // qGDBServerVersion is not supported 603 uint32_t m_gdb_server_version = 604 UINT32_MAX; // from reply to qGDBServerVersion, zero if 605 // qGDBServerVersion is not supported 606 std::chrono::seconds m_default_packet_timeout; 607 int m_target_vm_page_size = 0; // target system VM page size; 0 unspecified 608 uint64_t m_max_packet_size = 0; // as returned by qSupported 609 std::string m_qSupported_response; // the complete response to qSupported 610 611 bool m_supported_async_json_packets_is_valid = false; 612 lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp; 613 614 std::vector<MemoryRegionInfo> m_qXfer_memory_map; 615 bool m_qXfer_memory_map_loaded = false; 616 617 bool GetCurrentProcessInfo(bool allow_lazy_pid = true); 618 619 bool GetGDBServerVersion(); 620 621 // Given the list of compression types that the remote debug stub can support, 622 // possibly enable compression if we find an encoding we can handle. 623 void MaybeEnableCompression( 624 llvm::ArrayRef<llvm::StringRef> supported_compressions); 625 626 bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response, 627 ProcessInstanceInfo &process_info); 628 629 void OnRunPacketSent(bool first) override; 630 631 PacketResult SendThreadSpecificPacketAndWaitForResponse( 632 lldb::tid_t tid, StreamString &&payload, 633 StringExtractorGDBRemote &response); 634 635 Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid, 636 lldb::tid_t thread_id, 637 llvm::MutableArrayRef<uint8_t> &buffer, 638 size_t offset); 639 640 Status LoadQXferMemoryMap(); 641 642 Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr, 643 MemoryRegionInfo ®ion); 644 645 LazyBool GetThreadPacketSupported(lldb::tid_t tid, llvm::StringRef packetStr); 646 647 private: 648 GDBRemoteCommunicationClient(const GDBRemoteCommunicationClient &) = delete; 649 const GDBRemoteCommunicationClient & 650 operator=(const GDBRemoteCommunicationClient &) = delete; 651 }; 652 653 } // namespace process_gdb_remote 654 } // namespace lldb_private 655 656 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H 657