brintos

brintos / llvm-project-archived public Read only

0
0
Text · 24.3 KiB · ad590a2 Raw
675 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H10#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H11 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#endif32 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 from39/// qOffsets packet response.40struct QOffsets {41  /// If true, the offsets field describes segments. Otherwise, it describes42  /// 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 sure67  // 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 value73  // indicates if the packet was send and any response was received74  // even in the response is UNIMPLEMENTED. If the packet failed to75  // get a response, then false is returned. This quickly tells us76  // if we were able to connect and communicate with the remote GDB77  // server78  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] args95  ///     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 the99  /// environment that will get used when launching an application100  /// in conjunction with the 'A' packet. This function can be called101  /// multiple times in a row in order to pass on the desired102  /// environment that the inferior should be launched with.103  ///104  /// \param[in] name_equal_value105  ///     A NULL terminated C string that contains a single environment106  ///     in the format "NAME=VALUE".107  ///108  /// \return109  ///     Zero if the response was "OK", a positive value if the110  ///     the response was "Exx" where xx are two hex digits, or111  ///     -1 if the call is unsupported or any other unexpected112  ///     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 stdin122  /// data to the remote process.123  ///124  /// \param[in] data125  ///     A pointer to stdin data.126  ///127  /// \param[in] data_len128  ///     The number of bytes available at \a data.129  ///130  /// \return131  ///     Zero if the attach was successful, or an error indicating132  ///     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 process136  /// that will be launched with the 'A' packet.137  ///138  /// \param[in] file_spec139  ///     The path to use for stdin/out/err140  ///141  /// \return142  ///     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 will148  /// be launched with the 'A' packet.149  ///150  /// \param[in] enable151  ///     A boolean value indicating whether to disable ASLR or not.152  ///153  /// \return154  ///     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 the158  /// stub.159  ///160  /// \param[in] enable161  ///     A boolean value indicating whether to detach on error or not.162  ///163  /// \return164  ///     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 will168  /// be launched with the 'A' packet for non platform based169  /// connections. If this packet is sent to a GDB server that170  /// implements the platform, it will change the current working171  /// directory for the platform process.172  ///173  /// \param[in] working_dir174  ///     The path to a directory to use when launching our process175  ///176  /// \return177  ///     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 GDB181  /// server.182  ///183  /// \param[out] working_dir184  ///     The current working directory on the remote platform.185  ///186  /// \return187  ///     Boolean for success188  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  enum class xPacketState {222    Unimplemented,223    Prefixed, // Successful responses start with a 'b' character. This is the224              // style used by GDB.225    Bare,     // No prefix, packets starts with the memory being read. This is226              // LLDB's original style.227  };228  xPacketState GetxPacketState();229 230  bool GetVAttachOrWaitSupported();231 232  bool GetSyncThreadStateSupported();233 234  void ResetDiscoverableSettings(bool did_exec);235 236  bool GetHostInfo(bool force = false);237 238  bool GetDefaultThreadId(lldb::tid_t &tid);239 240  llvm::VersionTuple GetOSVersion();241 242  llvm::VersionTuple GetMacCatalystVersion();243 244  std::optional<std::string> GetOSBuildString();245 246  std::optional<std::string> GetOSKernelDescription();247 248  ArchSpec GetSystemArchitecture();249 250  lldb_private::AddressableBits GetAddressableBits();251 252  bool GetHostname(std::string &s);253 254  lldb::addr_t GetShlibInfoAddr();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 watchpoint292      bool insert,           // Insert or remove?293      lldb::addr_t addr,     // Address of breakpoint or watchpoint294      uint32_t length,       // Byte Size of breakpoint or watchpoint295      std::chrono::seconds interrupt_timeout); // Time to wait for an interrupt296 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. Both302  // the client and server need to support it, but this allows us to303  // measure the packet speed without any other work being done on the304  // other end and avoids any of that work affecting the packet send305  // and response times.306  bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size);307 308  std::optional<PidTid> SendSetCurrentThreadPacket(uint64_t tid, uint64_t pid,309                                                   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  bool GetQXferSigInfoReadSupported();338 339  bool GetMultiprocessSupported();340 341  bool GetReverseContinueSupported();342 343  bool GetReverseStepSupported();344 345  bool GetMultiMemReadSupported();346 347  LazyBool SupportsAllocDeallocMemory() // const348  {349    // Uncomment this to have lldb pretend the debug server doesn't respond to350    // alloc/dealloc memory packets.351    // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;352    return m_supports_alloc_dealloc_memory;353  }354 355  std::vector<std::pair<lldb::pid_t, lldb::tid_t>>356  GetCurrentProcessAndThreadIDs(bool &sequence_mutex_unavailable);357 358  size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids,359                             bool &sequence_mutex_unavailable);360 361  lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags,362                           mode_t mode, Status &error);363 364  bool CloseFile(lldb::user_id_t fd, Status &error);365 366  std::optional<GDBRemoteFStatData> FStat(lldb::user_id_t fd);367 368  // NB: this is just a convenience wrapper over open() + fstat().  It does not369  // work if the file cannot be opened.370  std::optional<GDBRemoteFStatData> Stat(const FileSpec &file_spec);371 372  lldb::user_id_t GetFileSize(const FileSpec &file_spec);373 374  void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,375                                       bool only_dir);376 377  Status GetFilePermissions(const FileSpec &file_spec,378                            uint32_t &file_permissions);379 380  Status SetFilePermissions(const FileSpec &file_spec,381                            uint32_t file_permissions);382 383  uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,384                    uint64_t dst_len, Status &error);385 386  uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,387                     uint64_t src_len, Status &error);388 389  Status CreateSymlink(const FileSpec &src, const FileSpec &dst);390 391  Status Unlink(const FileSpec &file_spec);392 393  Status MakeDirectory(const FileSpec &file_spec, uint32_t mode);394 395  bool GetFileExists(const FileSpec &file_spec);396 397  Status RunShellCommand(398      llvm::StringRef command,399      const FileSpec &working_dir, // Pass empty FileSpec to use the current400                                   // working directory401      int *status_ptr, // Pass nullptr if you don't want the process exit status402      int *signo_ptr,  // Pass nullptr if you don't want the signal that caused403                       // the process to exit404      std::string405          *command_output, // Pass nullptr if you don't want the command output406      const Timeout<std::micro> &timeout);407 408  llvm::ErrorOr<llvm::MD5::MD5Result> CalculateMD5(const FileSpec &file_spec);409 410  lldb::DataBufferSP ReadRegister(411      lldb::tid_t tid,412      uint32_t413          reg_num); // Must be the eRegisterKindProcessPlugin register number414 415  lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid);416 417  bool418  WriteRegister(lldb::tid_t tid,419                uint32_t reg_num, // eRegisterKindProcessPlugin register number420                llvm::ArrayRef<uint8_t> data);421 422  bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data);423 424  bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id);425 426  bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id);427 428  bool SyncThreadState(lldb::tid_t tid);429 430  const char *GetGDBServerProgramName();431 432  uint32_t GetGDBServerProgramVersion();433 434  bool AvoidGPackets(ProcessGDBRemote *process);435 436  StructuredData::ObjectSP GetThreadsInfo();437 438  bool GetThreadExtendedInfoSupported();439 440  bool GetLoadedDynamicLibrariesInfosSupported();441 442  bool GetSharedCacheInfoSupported();443 444  bool GetDynamicLoaderProcessStateSupported();445 446  bool GetMemoryTaggingSupported();447 448  bool UsesNativeSignals();449 450  lldb::DataBufferSP ReadMemoryTags(lldb::addr_t addr, size_t len,451                                    int32_t type);452 453  Status WriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type,454                         const std::vector<uint8_t> &tags);455 456  /// Use qOffsets to query the offset used when relocating the target457  /// executable. If successful, the returned structure will contain at least458  /// one value in the offsets field.459  std::optional<QOffsets> GetQOffsets();460 461  bool GetModuleInfo(const FileSpec &module_file_spec,462                     const ArchSpec &arch_spec, ModuleSpec &module_spec);463 464  std::optional<std::vector<ModuleSpec>>465  GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs,466                 const llvm::Triple &triple);467 468  llvm::Expected<std::string> ReadExtFeature(llvm::StringRef object,469                                             llvm::StringRef annex);470 471  void ServeSymbolLookups(lldb_private::Process *process);472 473  // Sends QPassSignals packet to the server with given signals to ignore.474  Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals);475 476  /// Return the feature set supported by the gdb-remote server.477  ///478  /// This method returns the remote side's response to the qSupported479  /// packet.  The response is the complete string payload returned480  /// to the client.481  ///482  /// \return483  ///     The string returned by the server to the qSupported query.484  const std::string &GetServerSupportedFeatures() const {485    return m_qSupported_response;486  }487 488  /// Return the array of async JSON packet types supported by the remote.489  ///490  /// This method returns the remote side's array of supported JSON491  /// packet types as a list of type names.  Each of the results are492  /// expected to have an Enable{type_name} command to enable and configure493  /// the related feature.  Each type_name for an enabled feature will494  /// possibly send async-style packets that contain a payload of a495  /// binhex-encoded JSON dictionary.  The dictionary will have a496  /// string field named 'type', that contains the type_name of the497  /// supported packet type.498  ///499  /// There is a Plugin category called structured-data plugins.500  /// A plugin indicates whether it knows how to handle a type_name.501  /// If so, it can be used to process the async JSON packet.502  ///503  /// \return504  ///     The string returned by the server to the qSupported query.505  lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins();506 507  /// Configure a StructuredData feature on the remote end.508  ///509  /// \see \b Process::ConfigureStructuredData(...) for details.510  Status511  ConfigureRemoteStructuredData(llvm::StringRef type_name,512                                const StructuredData::ObjectSP &config_sp);513 514  llvm::Expected<TraceSupportedResponse>515  SendTraceSupported(std::chrono::seconds interrupt_timeout);516 517  llvm::Error SendTraceStart(const llvm::json::Value &request,518                             std::chrono::seconds interrupt_timeout);519 520  llvm::Error SendTraceStop(const TraceStopRequest &request,521                            std::chrono::seconds interrupt_timeout);522 523  llvm::Expected<std::string>524  SendTraceGetState(llvm::StringRef type,525                    std::chrono::seconds interrupt_timeout);526 527  llvm::Expected<std::vector<uint8_t>>528  SendTraceGetBinaryData(const TraceGetBinaryDataRequest &request,529                         std::chrono::seconds interrupt_timeout);530 531  bool GetSaveCoreSupported() const;532 533  llvm::Expected<int> KillProcess(lldb::pid_t pid);534 535protected:536  LazyBool m_supports_not_sending_acks = eLazyBoolCalculate;537  LazyBool m_supports_thread_suffix = eLazyBoolCalculate;538  LazyBool m_supports_threads_in_stop_reply = eLazyBoolCalculate;539  LazyBool m_supports_vCont_all = eLazyBoolCalculate;540  LazyBool m_supports_vCont_any = eLazyBoolCalculate;541  LazyBool m_supports_vCont_c = eLazyBoolCalculate;542  LazyBool m_supports_vCont_C = eLazyBoolCalculate;543  LazyBool m_supports_vCont_s = eLazyBoolCalculate;544  LazyBool m_supports_vCont_S = eLazyBoolCalculate;545  LazyBool m_qHostInfo_is_valid = eLazyBoolCalculate;546  LazyBool m_curr_pid_is_valid = eLazyBoolCalculate;547  LazyBool m_qProcessInfo_is_valid = eLazyBoolCalculate;548  LazyBool m_qGDBServerVersion_is_valid = eLazyBoolCalculate;549  LazyBool m_supports_alloc_dealloc_memory = eLazyBoolCalculate;550  LazyBool m_supports_memory_region_info = eLazyBoolCalculate;551  LazyBool m_supports_watchpoint_support_info = eLazyBoolCalculate;552  LazyBool m_supports_detach_stay_stopped = eLazyBoolCalculate;553  LazyBool m_watchpoints_trigger_after_instruction = eLazyBoolCalculate;554  LazyBool m_attach_or_wait_reply = eLazyBoolCalculate;555  LazyBool m_prepare_for_reg_writing_reply = eLazyBoolCalculate;556  LazyBool m_supports_p = eLazyBoolCalculate;557  LazyBool m_avoid_g_packets = eLazyBoolCalculate;558  LazyBool m_supports_QSaveRegisterState = eLazyBoolCalculate;559  LazyBool m_supports_qXfer_auxv_read = eLazyBoolCalculate;560  LazyBool m_supports_qXfer_libraries_read = eLazyBoolCalculate;561  LazyBool m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate;562  LazyBool m_supports_qXfer_features_read = eLazyBoolCalculate;563  LazyBool m_supports_qXfer_memory_map_read = eLazyBoolCalculate;564  LazyBool m_supports_qXfer_siginfo_read = eLazyBoolCalculate;565  LazyBool m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate;566  LazyBool m_supports_jThreadExtendedInfo = eLazyBoolCalculate;567  LazyBool m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolCalculate;568  LazyBool m_supports_jGetSharedCacheInfo = eLazyBoolCalculate;569  LazyBool m_supports_jGetDyldProcessState = eLazyBoolCalculate;570  LazyBool m_supports_QPassSignals = eLazyBoolCalculate;571  LazyBool m_supports_error_string_reply = eLazyBoolCalculate;572  LazyBool m_supports_multiprocess = eLazyBoolCalculate;573  LazyBool m_supports_memory_tagging = eLazyBoolCalculate;574  LazyBool m_supports_qSaveCore = eLazyBoolCalculate;575  LazyBool m_uses_native_signals = eLazyBoolCalculate;576  std::optional<xPacketState> m_x_packet_state;577  LazyBool m_supports_reverse_continue = eLazyBoolCalculate;578  LazyBool m_supports_reverse_step = eLazyBoolCalculate;579  LazyBool m_supports_multi_mem_read = eLazyBoolCalculate;580 581  bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1,582      m_supports_qUserName : 1, m_supports_qGroupName : 1,583      m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1,584      m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1,585      m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1,586      m_supports_qSymbol : 1, m_qSymbol_requests_done : 1,587      m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1,588      m_supports_jModulesInfo : 1, m_supports_vFileSize : 1,589      m_supports_vFileMode : 1, m_supports_vFileExists : 1,590      m_supports_vRun : 1;591 592  /// Current gdb remote protocol process identifier for all other operations593  lldb::pid_t m_curr_pid = LLDB_INVALID_PROCESS_ID;594  /// Current gdb remote protocol process identifier for continue, step, etc595  lldb::pid_t m_curr_pid_run = LLDB_INVALID_PROCESS_ID;596  /// Current gdb remote protocol thread identifier for all other operations597  lldb::tid_t m_curr_tid = LLDB_INVALID_THREAD_ID;598  /// Current gdb remote protocol thread identifier for continue, step, etc599  lldb::tid_t m_curr_tid_run = LLDB_INVALID_THREAD_ID;600 601  uint32_t m_num_supported_hardware_watchpoints = 0;602  WatchpointHardwareFeature m_watchpoint_types =603      eWatchpointHardwareFeatureUnknown;604  uint32_t m_low_mem_addressing_bits = 0;605  uint32_t m_high_mem_addressing_bits = 0;606 607  ArchSpec m_host_arch;608  std::string m_host_distribution_id;609  ArchSpec m_process_arch;610  UUID m_process_standalone_uuid;611  lldb::addr_t m_process_standalone_value = LLDB_INVALID_ADDRESS;612  bool m_process_standalone_value_is_offset = false;613  std::vector<lldb::addr_t> m_binary_addresses;614  llvm::VersionTuple m_os_version;615  llvm::VersionTuple m_maccatalyst_version;616  std::string m_os_build;617  std::string m_os_kernel;618  std::string m_hostname;619  std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if620                                 // qGDBServerVersion is not supported621  uint32_t m_gdb_server_version =622      UINT32_MAX; // from reply to qGDBServerVersion, zero if623                  // qGDBServerVersion is not supported624  std::chrono::seconds m_default_packet_timeout;625  int m_target_vm_page_size = 0; // target system VM page size; 0 unspecified626  uint64_t m_max_packet_size = 0;    // as returned by qSupported627  std::string m_qSupported_response; // the complete response to qSupported628 629  bool m_supported_async_json_packets_is_valid = false;630  lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp;631 632  std::vector<MemoryRegionInfo> m_qXfer_memory_map;633  bool m_qXfer_memory_map_loaded = false;634 635  bool GetCurrentProcessInfo(bool allow_lazy_pid = true);636 637  bool GetGDBServerVersion();638 639  // Given the list of compression types that the remote debug stub can support,640  // possibly enable compression if we find an encoding we can handle.641  void MaybeEnableCompression(642      llvm::ArrayRef<llvm::StringRef> supported_compressions);643 644  bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response,645                                 ProcessInstanceInfo &process_info);646 647  void OnRunPacketSent(bool first) override;648 649  PacketResult SendThreadSpecificPacketAndWaitForResponse(650      lldb::tid_t tid, StreamString &&payload,651      StringExtractorGDBRemote &response);652 653  Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid,654                                lldb::tid_t thread_id,655                                llvm::MutableArrayRef<uint8_t> &buffer,656                                size_t offset);657 658  Status LoadQXferMemoryMap();659 660  Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr,661                                     MemoryRegionInfo &region);662 663  LazyBool GetThreadPacketSupported(lldb::tid_t tid, llvm::StringRef packetStr);664 665private:666  GDBRemoteCommunicationClient(const GDBRemoteCommunicationClient &) = delete;667  const GDBRemoteCommunicationClient &668  operator=(const GDBRemoteCommunicationClient &) = delete;669};670 671} // namespace process_gdb_remote672} // namespace lldb_private673 674#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H675