1254721Semaste//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9254721Semaste#ifndef liblldb_GDBRemoteCommunicationClient_h_ 10254721Semaste#define liblldb_GDBRemoteCommunicationClient_h_ 11254721Semaste 12314564Sdim#include "GDBRemoteClientBase.h" 13314564Sdim 14314564Sdim#include <chrono> 15296417Sdim#include <map> 16309124Sdim#include <mutex> 17296417Sdim#include <string> 18254721Semaste#include <vector> 19254721Semaste 20360784Sdim#include "lldb/Host/File.h" 21327952Sdim#include "lldb/Utility/ArchSpec.h" 22360784Sdim#include "lldb/Utility/GDBRemote.h" 23321369Sdim#include "lldb/Utility/StructuredData.h" 24353358Sdim#if defined(_WIN32) 25353358Sdim#include "lldb/Host/windows/PosixApi.h" 26353358Sdim#endif 27254721Semaste 28314564Sdim#include "llvm/ADT/Optional.h" 29353358Sdim#include "llvm/Support/VersionTuple.h" 30254721Semaste 31288943Sdimnamespace lldb_private { 32288943Sdimnamespace process_gdb_remote { 33254721Semaste 34314564Sdimclass GDBRemoteCommunicationClient : public GDBRemoteClientBase { 35254721Semastepublic: 36314564Sdim GDBRemoteCommunicationClient(); 37254721Semaste 38314564Sdim ~GDBRemoteCommunicationClient() override; 39254721Semaste 40314564Sdim // After connecting, send the handshake to the server to make sure 41314564Sdim // we are communicating with it. 42321369Sdim bool HandshakeWithServer(Status *error_ptr); 43254721Semaste 44314564Sdim // For packets which specify a range of output to be returned, 45314564Sdim // return all of the output via a series of request packets of the form 46314564Sdim // <prefix>0,<size> 47314564Sdim // <prefix><size>,<size> 48314564Sdim // <prefix><size>*2,<size> 49314564Sdim // <prefix><size>*3,<size> 50314564Sdim // ... 51314564Sdim // until a "$l..." packet is received, indicating the end. 52314564Sdim // (size is in hex; this format is used by a standard gdbserver to 53314564Sdim // return the given portion of the output specified by <prefix>; 54314564Sdim // for example, "qXfer:libraries-svr4:read::fff,1000" means 55314564Sdim // "return a chunk of the xml description file for shared 56314564Sdim // library load addresses, where the chunk starts at offset 0xfff 57314564Sdim // and continues for 0x1000 bytes"). 58314564Sdim // Concatenate the resulting server response packets together and 59314564Sdim // return in response_string. If any packet fails, the return value 60314564Sdim // indicates that failure and the returned string value is undefined. 61314564Sdim PacketResult 62314564Sdim SendPacketsAndConcatenateResponses(const char *send_payload_prefix, 63314564Sdim std::string &response_string); 64254721Semaste 65314564Sdim bool GetThreadSuffixSupported(); 66254721Semaste 67314564Sdim // This packet is usually sent first and the boolean return value 68314564Sdim // indicates if the packet was send and any response was received 69314564Sdim // even in the response is UNIMPLEMENTED. If the packet failed to 70314564Sdim // get a response, then false is returned. This quickly tells us 71314564Sdim // if we were able to connect and communicate with the remote GDB 72314564Sdim // server 73314564Sdim bool QueryNoAckModeSupported(); 74262528Semaste 75314564Sdim void GetListThreadsInStopReplySupported(); 76296417Sdim 77314564Sdim lldb::pid_t GetCurrentProcessID(bool allow_lazy = true); 78254721Semaste 79314564Sdim bool GetLaunchSuccess(std::string &error_str); 80254721Semaste 81314564Sdim bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid, 82314564Sdim uint16_t &port, std::string &socket_name); 83254721Semaste 84314564Sdim size_t QueryGDBServer( 85314564Sdim std::vector<std::pair<uint16_t, std::string>> &connection_urls); 86254721Semaste 87314564Sdim bool KillSpawnedProcess(lldb::pid_t pid); 88254721Semaste 89314564Sdim /// Sends a GDB remote protocol 'A' packet that delivers program 90314564Sdim /// arguments to the remote server. 91314564Sdim /// 92360784Sdim /// \param[in] launch_info 93314564Sdim /// A NULL terminated array of const C strings to use as the 94314564Sdim /// arguments. 95314564Sdim /// 96353358Sdim /// \return 97314564Sdim /// Zero if the response was "OK", a positive value if the 98314564Sdim /// the response was "Exx" where xx are two hex digits, or 99314564Sdim /// -1 if the call is unsupported or any other unexpected 100314564Sdim /// response was received. 101314564Sdim int SendArgumentsPacket(const ProcessLaunchInfo &launch_info); 102254721Semaste 103314564Sdim /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the 104314564Sdim /// environment that will get used when launching an application 105314564Sdim /// in conjunction with the 'A' packet. This function can be called 106314564Sdim /// multiple times in a row in order to pass on the desired 107314564Sdim /// environment that the inferior should be launched with. 108314564Sdim /// 109353358Sdim /// \param[in] name_equal_value 110314564Sdim /// A NULL terminated C string that contains a single environment 111314564Sdim /// in the format "NAME=VALUE". 112314564Sdim /// 113353358Sdim /// \return 114314564Sdim /// Zero if the response was "OK", a positive value if the 115314564Sdim /// the response was "Exx" where xx are two hex digits, or 116314564Sdim /// -1 if the call is unsupported or any other unexpected 117314564Sdim /// response was received. 118314564Sdim int SendEnvironmentPacket(char const *name_equal_value); 119341825Sdim int SendEnvironment(const Environment &env); 120254721Semaste 121314564Sdim int SendLaunchArchPacket(const char *arch); 122254721Semaste 123314564Sdim int SendLaunchEventDataPacket(const char *data, 124314564Sdim bool *was_supported = nullptr); 125296417Sdim 126314564Sdim /// Sends a "vAttach:PID" where PID is in hex. 127314564Sdim /// 128353358Sdim /// \param[in] pid 129314564Sdim /// A process ID for the remote gdb server to attach to. 130314564Sdim /// 131353358Sdim /// \param[out] response 132314564Sdim /// The response received from the gdb server. If the return 133314564Sdim /// value is zero, \a response will contain a stop reply 134314564Sdim /// packet. 135314564Sdim /// 136353358Sdim /// \return 137314564Sdim /// Zero if the attach was successful, or an error indicating 138314564Sdim /// an error code. 139314564Sdim int SendAttach(lldb::pid_t pid, StringExtractorGDBRemote &response); 140296417Sdim 141314564Sdim /// Sends a GDB remote protocol 'I' packet that delivers stdin 142314564Sdim /// data to the remote process. 143314564Sdim /// 144353358Sdim /// \param[in] data 145314564Sdim /// A pointer to stdin data. 146314564Sdim /// 147353358Sdim /// \param[in] data_len 148314564Sdim /// The number of bytes available at \a data. 149314564Sdim /// 150353358Sdim /// \return 151314564Sdim /// Zero if the attach was successful, or an error indicating 152314564Sdim /// an error code. 153314564Sdim int SendStdinNotification(const char *data, size_t data_len); 154254721Semaste 155314564Sdim /// Sets the path to use for stdin/out/err for a process 156314564Sdim /// that will be launched with the 'A' packet. 157314564Sdim /// 158360784Sdim /// \param[in] file_spec 159314564Sdim /// The path to use for stdin/out/err 160314564Sdim /// 161353358Sdim /// \return 162314564Sdim /// Zero if the for success, or an error code for failure. 163314564Sdim int SetSTDIN(const FileSpec &file_spec); 164314564Sdim int SetSTDOUT(const FileSpec &file_spec); 165314564Sdim int SetSTDERR(const FileSpec &file_spec); 166254721Semaste 167314564Sdim /// Sets the disable ASLR flag to \a enable for a process that will 168314564Sdim /// be launched with the 'A' packet. 169314564Sdim /// 170353358Sdim /// \param[in] enable 171314564Sdim /// A boolean value indicating whether to disable ASLR or not. 172314564Sdim /// 173353358Sdim /// \return 174314564Sdim /// Zero if the for success, or an error code for failure. 175314564Sdim int SetDisableASLR(bool enable); 176254721Semaste 177314564Sdim /// Sets the DetachOnError flag to \a enable for the process controlled by the 178314564Sdim /// stub. 179314564Sdim /// 180353358Sdim /// \param[in] enable 181314564Sdim /// A boolean value indicating whether to detach on error or not. 182314564Sdim /// 183353358Sdim /// \return 184314564Sdim /// Zero if the for success, or an error code for failure. 185314564Sdim int SetDetachOnError(bool enable); 186254721Semaste 187314564Sdim /// Sets the working directory to \a path for a process that will 188314564Sdim /// be launched with the 'A' packet for non platform based 189314564Sdim /// connections. If this packet is sent to a GDB server that 190314564Sdim /// implements the platform, it will change the current working 191314564Sdim /// directory for the platform process. 192314564Sdim /// 193353358Sdim /// \param[in] working_dir 194314564Sdim /// The path to a directory to use when launching our process 195314564Sdim /// 196353358Sdim /// \return 197314564Sdim /// Zero if the for success, or an error code for failure. 198314564Sdim int SetWorkingDir(const FileSpec &working_dir); 199288943Sdim 200314564Sdim /// Gets the current working directory of a remote platform GDB 201314564Sdim /// server. 202314564Sdim /// 203353358Sdim /// \param[out] working_dir 204314564Sdim /// The current working directory on the remote platform. 205314564Sdim /// 206353358Sdim /// \return 207314564Sdim /// Boolean for success 208314564Sdim bool GetWorkingDir(FileSpec &working_dir); 209254721Semaste 210314564Sdim lldb::addr_t AllocateMemory(size_t size, uint32_t permissions); 211254721Semaste 212314564Sdim bool DeallocateMemory(lldb::addr_t addr); 213254721Semaste 214321369Sdim Status Detach(bool keep_stopped); 215258884Semaste 216321369Sdim Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); 217254721Semaste 218321369Sdim Status GetWatchpointSupportInfo(uint32_t &num); 219254721Semaste 220321369Sdim Status GetWatchpointSupportInfo(uint32_t &num, bool &after, 221321369Sdim const ArchSpec &arch); 222254721Semaste 223321369Sdim Status GetWatchpointsTriggerAfterInstruction(bool &after, 224321369Sdim const ArchSpec &arch); 225254721Semaste 226314564Sdim const ArchSpec &GetHostArchitecture(); 227254721Semaste 228314564Sdim std::chrono::seconds GetHostDefaultPacketTimeout(); 229254721Semaste 230314564Sdim const ArchSpec &GetProcessArchitecture(); 231254721Semaste 232314564Sdim void GetRemoteQSupported(); 233254721Semaste 234314564Sdim bool GetVContSupported(char flavor); 235262528Semaste 236314564Sdim bool GetpPacketSupported(lldb::tid_t tid); 237254721Semaste 238314564Sdim bool GetxPacketSupported(); 239258054Semaste 240314564Sdim bool GetVAttachOrWaitSupported(); 241276479Sdim 242314564Sdim bool GetSyncThreadStateSupported(); 243254721Semaste 244314564Sdim void ResetDiscoverableSettings(bool did_exec); 245288943Sdim 246314564Sdim bool GetHostInfo(bool force = false); 247254721Semaste 248314564Sdim bool GetDefaultThreadId(lldb::tid_t &tid); 249254721Semaste 250341825Sdim llvm::VersionTuple GetOSVersion(); 251254721Semaste 252360784Sdim llvm::VersionTuple GetMacCatalystVersion(); 253360784Sdim 254314564Sdim bool GetOSBuildString(std::string &s); 255254721Semaste 256314564Sdim bool GetOSKernelDescription(std::string &s); 257254721Semaste 258314564Sdim ArchSpec GetSystemArchitecture(); 259254721Semaste 260314564Sdim bool GetHostname(std::string &s); 261254721Semaste 262314564Sdim lldb::addr_t GetShlibInfoAddr(); 263254721Semaste 264314564Sdim bool GetSupportsThreadSuffix(); 265254721Semaste 266314564Sdim bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info); 267254721Semaste 268314564Sdim uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, 269314564Sdim ProcessInstanceInfoList &process_infos); 270254721Semaste 271314564Sdim bool GetUserName(uint32_t uid, std::string &name); 272254721Semaste 273314564Sdim bool GetGroupName(uint32_t gid, std::string &name); 274314564Sdim 275314564Sdim bool HasFullVContSupport() { return GetVContSupported('A'); } 276314564Sdim 277314564Sdim bool HasAnyVContSupport() { return GetVContSupported('a'); } 278314564Sdim 279314564Sdim bool GetStopReply(StringExtractorGDBRemote &response); 280314564Sdim 281314564Sdim bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response); 282314564Sdim 283314564Sdim bool SupportsGDBStoppointPacket(GDBStoppointType type) { 284314564Sdim switch (type) { 285314564Sdim case eBreakpointSoftware: 286314564Sdim return m_supports_z0; 287314564Sdim case eBreakpointHardware: 288314564Sdim return m_supports_z1; 289314564Sdim case eWatchpointWrite: 290314564Sdim return m_supports_z2; 291314564Sdim case eWatchpointRead: 292314564Sdim return m_supports_z3; 293314564Sdim case eWatchpointReadWrite: 294314564Sdim return m_supports_z4; 295314564Sdim default: 296314564Sdim return false; 297254721Semaste } 298314564Sdim } 299296417Sdim 300314564Sdim uint8_t SendGDBStoppointTypePacket( 301314564Sdim GDBStoppointType type, // Type of breakpoint or watchpoint 302314564Sdim bool insert, // Insert or remove? 303314564Sdim lldb::addr_t addr, // Address of breakpoint or watchpoint 304314564Sdim uint32_t length); // Byte Size of breakpoint or watchpoint 305254721Semaste 306314564Sdim bool SetNonStopMode(const bool enable); 307288943Sdim 308314564Sdim void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, 309314564Sdim uint32_t max_recv, uint64_t recv_amount, bool json, 310314564Sdim Stream &strm); 311254721Semaste 312314564Sdim // This packet is for testing the speed of the interface only. Both 313314564Sdim // the client and server need to support it, but this allows us to 314314564Sdim // measure the packet speed without any other work being done on the 315314564Sdim // other end and avoids any of that work affecting the packet send 316314564Sdim // and response times. 317314564Sdim bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); 318254721Semaste 319314564Sdim bool SetCurrentThread(uint64_t tid); 320276479Sdim 321314564Sdim bool SetCurrentThreadForRun(uint64_t tid); 322262528Semaste 323314564Sdim bool GetQXferAuxvReadSupported(); 324262528Semaste 325321369Sdim void EnableErrorStringInPacket(); 326321369Sdim 327314564Sdim bool GetQXferLibrariesReadSupported(); 328262528Semaste 329314564Sdim bool GetQXferLibrariesSVR4ReadSupported(); 330288943Sdim 331314564Sdim uint64_t GetRemoteMaxPacketSize(); 332262528Semaste 333314564Sdim bool GetEchoSupported(); 334288943Sdim 335321369Sdim bool GetQPassSignalsSupported(); 336321369Sdim 337314564Sdim bool GetAugmentedLibrariesSVR4ReadSupported(); 338254721Semaste 339314564Sdim bool GetQXferFeaturesReadSupported(); 340258054Semaste 341341825Sdim bool GetQXferMemoryMapReadSupported(); 342341825Sdim 343314564Sdim LazyBool SupportsAllocDeallocMemory() // const 344314564Sdim { 345314564Sdim // Uncomment this to have lldb pretend the debug server doesn't respond to 346314564Sdim // alloc/dealloc memory packets. 347314564Sdim // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; 348314564Sdim return m_supports_alloc_dealloc_memory; 349314564Sdim } 350258884Semaste 351314564Sdim size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids, 352314564Sdim bool &sequence_mutex_unavailable); 353258884Semaste 354360784Sdim lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, 355321369Sdim mode_t mode, Status &error); 356288943Sdim 357321369Sdim bool CloseFile(lldb::user_id_t fd, Status &error); 358288943Sdim 359314564Sdim lldb::user_id_t GetFileSize(const FileSpec &file_spec); 360258054Semaste 361321369Sdim Status GetFilePermissions(const FileSpec &file_spec, 362321369Sdim uint32_t &file_permissions); 363258884Semaste 364321369Sdim Status SetFilePermissions(const FileSpec &file_spec, 365321369Sdim uint32_t file_permissions); 366258884Semaste 367314564Sdim uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, 368321369Sdim uint64_t dst_len, Status &error); 369276479Sdim 370314564Sdim uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, 371321369Sdim uint64_t src_len, Status &error); 372276479Sdim 373321369Sdim Status CreateSymlink(const FileSpec &src, const FileSpec &dst); 374276479Sdim 375321369Sdim Status Unlink(const FileSpec &file_spec); 376288943Sdim 377321369Sdim Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); 378276479Sdim 379314564Sdim bool GetFileExists(const FileSpec &file_spec); 380288943Sdim 381321369Sdim Status RunShellCommand( 382314564Sdim const char *command, // Shouldn't be nullptr 383314564Sdim const FileSpec &working_dir, // Pass empty FileSpec to use the current 384314564Sdim // working directory 385314564Sdim int *status_ptr, // Pass nullptr if you don't want the process exit status 386314564Sdim int *signo_ptr, // Pass nullptr if you don't want the signal that caused 387314564Sdim // the process to exit 388314564Sdim std::string 389314564Sdim *command_output, // Pass nullptr if you don't want the command output 390341825Sdim const Timeout<std::micro> &timeout); 391288943Sdim 392314564Sdim bool CalculateMD5(const FileSpec &file_spec, uint64_t &high, uint64_t &low); 393288943Sdim 394314564Sdim lldb::DataBufferSP ReadRegister( 395314564Sdim lldb::tid_t tid, 396314564Sdim uint32_t 397314564Sdim reg_num); // Must be the eRegisterKindProcessPlugin register number 398288943Sdim 399314564Sdim lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid); 400314564Sdim 401314564Sdim bool 402314564Sdim WriteRegister(lldb::tid_t tid, 403314564Sdim uint32_t reg_num, // eRegisterKindProcessPlugin register number 404314564Sdim llvm::ArrayRef<uint8_t> data); 405314564Sdim 406314564Sdim bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data); 407314564Sdim 408314564Sdim bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id); 409314564Sdim 410314564Sdim bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id); 411314564Sdim 412314564Sdim bool SyncThreadState(lldb::tid_t tid); 413314564Sdim 414314564Sdim const char *GetGDBServerProgramName(); 415314564Sdim 416314564Sdim uint32_t GetGDBServerProgramVersion(); 417314564Sdim 418314564Sdim bool AvoidGPackets(ProcessGDBRemote *process); 419314564Sdim 420314564Sdim StructuredData::ObjectSP GetThreadsInfo(); 421314564Sdim 422314564Sdim bool GetThreadExtendedInfoSupported(); 423314564Sdim 424314564Sdim bool GetLoadedDynamicLibrariesInfosSupported(); 425314564Sdim 426314564Sdim bool GetSharedCacheInfoSupported(); 427314564Sdim 428314564Sdim bool GetModuleInfo(const FileSpec &module_file_spec, 429314564Sdim const ArchSpec &arch_spec, ModuleSpec &module_spec); 430314564Sdim 431314564Sdim llvm::Optional<std::vector<ModuleSpec>> 432314564Sdim GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs, 433314564Sdim const llvm::Triple &triple); 434314564Sdim 435314564Sdim bool ReadExtFeature(const lldb_private::ConstString object, 436314564Sdim const lldb_private::ConstString annex, std::string &out, 437321369Sdim lldb_private::Status &err); 438314564Sdim 439314564Sdim void ServeSymbolLookups(lldb_private::Process *process); 440314564Sdim 441321369Sdim // Sends QPassSignals packet to the server with given signals to ignore. 442321369Sdim Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); 443321369Sdim 444314564Sdim /// Return the feature set supported by the gdb-remote server. 445314564Sdim /// 446314564Sdim /// This method returns the remote side's response to the qSupported 447314564Sdim /// packet. The response is the complete string payload returned 448314564Sdim /// to the client. 449314564Sdim /// 450353358Sdim /// \return 451314564Sdim /// The string returned by the server to the qSupported query. 452314564Sdim const std::string &GetServerSupportedFeatures() const { 453314564Sdim return m_qSupported_response; 454314564Sdim } 455314564Sdim 456314564Sdim /// Return the array of async JSON packet types supported by the remote. 457314564Sdim /// 458314564Sdim /// This method returns the remote side's array of supported JSON 459314564Sdim /// packet types as a list of type names. Each of the results are 460314564Sdim /// expected to have an Enable{type_name} command to enable and configure 461314564Sdim /// the related feature. Each type_name for an enabled feature will 462314564Sdim /// possibly send async-style packets that contain a payload of a 463314564Sdim /// binhex-encoded JSON dictionary. The dictionary will have a 464314564Sdim /// string field named 'type', that contains the type_name of the 465314564Sdim /// supported packet type. 466314564Sdim /// 467314564Sdim /// There is a Plugin category called structured-data plugins. 468314564Sdim /// A plugin indicates whether it knows how to handle a type_name. 469314564Sdim /// If so, it can be used to process the async JSON packet. 470314564Sdim /// 471353358Sdim /// \return 472314564Sdim /// The string returned by the server to the qSupported query. 473314564Sdim lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins(); 474314564Sdim 475314564Sdim /// Configure a StructuredData feature on the remote end. 476314564Sdim /// 477353358Sdim /// \see \b Process::ConfigureStructuredData(...) for details. 478321369Sdim Status 479353358Sdim ConfigureRemoteStructuredData(ConstString type_name, 480314564Sdim const StructuredData::ObjectSP &config_sp); 481314564Sdim 482321369Sdim lldb::user_id_t SendStartTracePacket(const TraceOptions &options, 483321369Sdim Status &error); 484321369Sdim 485321369Sdim Status SendStopTracePacket(lldb::user_id_t uid, lldb::tid_t thread_id); 486321369Sdim 487321369Sdim Status SendGetDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, 488321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 489321369Sdim size_t offset = 0); 490321369Sdim 491321369Sdim Status SendGetMetaDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, 492321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 493321369Sdim size_t offset = 0); 494321369Sdim 495321369Sdim Status SendGetTraceConfigPacket(lldb::user_id_t uid, TraceOptions &options); 496321369Sdim 497254721Semasteprotected: 498314564Sdim LazyBool m_supports_not_sending_acks; 499314564Sdim LazyBool m_supports_thread_suffix; 500314564Sdim LazyBool m_supports_threads_in_stop_reply; 501314564Sdim LazyBool m_supports_vCont_all; 502314564Sdim LazyBool m_supports_vCont_any; 503314564Sdim LazyBool m_supports_vCont_c; 504314564Sdim LazyBool m_supports_vCont_C; 505314564Sdim LazyBool m_supports_vCont_s; 506314564Sdim LazyBool m_supports_vCont_S; 507314564Sdim LazyBool m_qHostInfo_is_valid; 508314564Sdim LazyBool m_curr_pid_is_valid; 509314564Sdim LazyBool m_qProcessInfo_is_valid; 510314564Sdim LazyBool m_qGDBServerVersion_is_valid; 511314564Sdim LazyBool m_supports_alloc_dealloc_memory; 512314564Sdim LazyBool m_supports_memory_region_info; 513314564Sdim LazyBool m_supports_watchpoint_support_info; 514314564Sdim LazyBool m_supports_detach_stay_stopped; 515314564Sdim LazyBool m_watchpoints_trigger_after_instruction; 516314564Sdim LazyBool m_attach_or_wait_reply; 517314564Sdim LazyBool m_prepare_for_reg_writing_reply; 518314564Sdim LazyBool m_supports_p; 519314564Sdim LazyBool m_supports_x; 520314564Sdim LazyBool m_avoid_g_packets; 521314564Sdim LazyBool m_supports_QSaveRegisterState; 522314564Sdim LazyBool m_supports_qXfer_auxv_read; 523314564Sdim LazyBool m_supports_qXfer_libraries_read; 524314564Sdim LazyBool m_supports_qXfer_libraries_svr4_read; 525314564Sdim LazyBool m_supports_qXfer_features_read; 526341825Sdim LazyBool m_supports_qXfer_memory_map_read; 527314564Sdim LazyBool m_supports_augmented_libraries_svr4_read; 528314564Sdim LazyBool m_supports_jThreadExtendedInfo; 529314564Sdim LazyBool m_supports_jLoadedDynamicLibrariesInfos; 530314564Sdim LazyBool m_supports_jGetSharedCacheInfo; 531321369Sdim LazyBool m_supports_QPassSignals; 532321369Sdim LazyBool m_supports_error_string_reply; 533262528Semaste 534314564Sdim bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1, 535314564Sdim m_supports_qUserName : 1, m_supports_qGroupName : 1, 536314564Sdim m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1, 537314564Sdim m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1, 538314564Sdim m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1, 539314564Sdim m_supports_qSymbol : 1, m_qSymbol_requests_done : 1, 540314564Sdim m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1, 541314564Sdim m_supports_jModulesInfo : 1; 542254721Semaste 543314564Sdim lldb::pid_t m_curr_pid; 544314564Sdim lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all 545314564Sdim // other operations 546314564Sdim lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for 547314564Sdim // continue, step, etc 548254721Semaste 549314564Sdim uint32_t m_num_supported_hardware_watchpoints; 550288943Sdim 551314564Sdim ArchSpec m_host_arch; 552314564Sdim ArchSpec m_process_arch; 553341825Sdim llvm::VersionTuple m_os_version; 554360784Sdim llvm::VersionTuple m_maccatalyst_version; 555314564Sdim std::string m_os_build; 556314564Sdim std::string m_os_kernel; 557314564Sdim std::string m_hostname; 558314564Sdim std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if 559314564Sdim // qGDBServerVersion is not supported 560314564Sdim uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if 561314564Sdim // qGDBServerVersion is not supported 562314564Sdim std::chrono::seconds m_default_packet_timeout; 563314564Sdim uint64_t m_max_packet_size; // as returned by qSupported 564314564Sdim std::string m_qSupported_response; // the complete response to qSupported 565296417Sdim 566314564Sdim bool m_supported_async_json_packets_is_valid; 567314564Sdim lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp; 568296417Sdim 569341825Sdim std::vector<MemoryRegionInfo> m_qXfer_memory_map; 570341825Sdim bool m_qXfer_memory_map_loaded; 571341825Sdim 572314564Sdim bool GetCurrentProcessInfo(bool allow_lazy_pid = true); 573296417Sdim 574314564Sdim bool GetGDBServerVersion(); 575296417Sdim 576314564Sdim // Given the list of compression types that the remote debug stub can support, 577314564Sdim // possibly enable compression if we find an encoding we can handle. 578314564Sdim void MaybeEnableCompression(std::vector<std::string> supported_compressions); 579296417Sdim 580314564Sdim bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response, 581314564Sdim ProcessInstanceInfo &process_info); 582314564Sdim 583314564Sdim void OnRunPacketSent(bool first) override; 584314564Sdim 585314564Sdim PacketResult SendThreadSpecificPacketAndWaitForResponse( 586314564Sdim lldb::tid_t tid, StreamString &&payload, 587314564Sdim StringExtractorGDBRemote &response, bool send_async); 588314564Sdim 589321369Sdim Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid, 590321369Sdim lldb::tid_t thread_id, 591321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 592321369Sdim size_t offset); 593321369Sdim 594341825Sdim Status LoadQXferMemoryMap(); 595341825Sdim 596341825Sdim Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr, 597341825Sdim MemoryRegionInfo ®ion); 598341825Sdim 599360784Sdim LazyBool GetThreadPacketSupported(lldb::tid_t tid, llvm::StringRef packetStr); 600360784Sdim 601254721Semasteprivate: 602314564Sdim DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationClient); 603254721Semaste}; 604254721Semaste 605288943Sdim} // namespace process_gdb_remote 606288943Sdim} // namespace lldb_private 607288943Sdim 608296417Sdim#endif // liblldb_GDBRemoteCommunicationClient_h_ 609