GDBRemoteCommunicationClient.h revision 341825
1254721Semaste//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#ifndef liblldb_GDBRemoteCommunicationClient_h_ 11254721Semaste#define liblldb_GDBRemoteCommunicationClient_h_ 12254721Semaste 13314564Sdim#include "GDBRemoteClientBase.h" 14314564Sdim 15254721Semaste// C Includes 16254721Semaste// C++ Includes 17314564Sdim#include <chrono> 18296417Sdim#include <map> 19309124Sdim#include <mutex> 20296417Sdim#include <string> 21254721Semaste#include <vector> 22254721Semaste 23254721Semaste#include "lldb/Target/Process.h" 24327952Sdim#include "lldb/Utility/ArchSpec.h" 25321369Sdim#include "lldb/Utility/StreamGDBRemote.h" 26321369Sdim#include "lldb/Utility/StructuredData.h" 27254721Semaste 28314564Sdim#include "llvm/ADT/Optional.h" 29254721Semaste 30288943Sdimnamespace lldb_private { 31288943Sdimnamespace process_gdb_remote { 32254721Semaste 33314564Sdimclass GDBRemoteCommunicationClient : public GDBRemoteClientBase { 34254721Semastepublic: 35314564Sdim GDBRemoteCommunicationClient(); 36254721Semaste 37314564Sdim ~GDBRemoteCommunicationClient() override; 38254721Semaste 39314564Sdim //------------------------------------------------------------------ 40314564Sdim // After connecting, send the handshake to the server to make sure 41314564Sdim // we are communicating with it. 42314564Sdim //------------------------------------------------------------------ 43321369Sdim bool HandshakeWithServer(Status *error_ptr); 44254721Semaste 45314564Sdim // For packets which specify a range of output to be returned, 46314564Sdim // return all of the output via a series of request packets of the form 47314564Sdim // <prefix>0,<size> 48314564Sdim // <prefix><size>,<size> 49314564Sdim // <prefix><size>*2,<size> 50314564Sdim // <prefix><size>*3,<size> 51314564Sdim // ... 52314564Sdim // until a "$l..." packet is received, indicating the end. 53314564Sdim // (size is in hex; this format is used by a standard gdbserver to 54314564Sdim // return the given portion of the output specified by <prefix>; 55314564Sdim // for example, "qXfer:libraries-svr4:read::fff,1000" means 56314564Sdim // "return a chunk of the xml description file for shared 57314564Sdim // library load addresses, where the chunk starts at offset 0xfff 58314564Sdim // and continues for 0x1000 bytes"). 59314564Sdim // Concatenate the resulting server response packets together and 60314564Sdim // return in response_string. If any packet fails, the return value 61314564Sdim // indicates that failure and the returned string value is undefined. 62314564Sdim PacketResult 63314564Sdim SendPacketsAndConcatenateResponses(const char *send_payload_prefix, 64314564Sdim std::string &response_string); 65254721Semaste 66314564Sdim bool GetThreadSuffixSupported(); 67254721Semaste 68314564Sdim // This packet is usually sent first and the boolean return value 69314564Sdim // indicates if the packet was send and any response was received 70314564Sdim // even in the response is UNIMPLEMENTED. If the packet failed to 71314564Sdim // get a response, then false is returned. This quickly tells us 72314564Sdim // if we were able to connect and communicate with the remote GDB 73314564Sdim // server 74314564Sdim bool QueryNoAckModeSupported(); 75262528Semaste 76314564Sdim void GetListThreadsInStopReplySupported(); 77296417Sdim 78314564Sdim lldb::pid_t GetCurrentProcessID(bool allow_lazy = true); 79254721Semaste 80314564Sdim bool GetLaunchSuccess(std::string &error_str); 81254721Semaste 82314564Sdim bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid, 83314564Sdim uint16_t &port, std::string &socket_name); 84254721Semaste 85314564Sdim size_t QueryGDBServer( 86314564Sdim std::vector<std::pair<uint16_t, std::string>> &connection_urls); 87254721Semaste 88314564Sdim bool KillSpawnedProcess(lldb::pid_t pid); 89254721Semaste 90314564Sdim //------------------------------------------------------------------ 91314564Sdim /// Sends a GDB remote protocol 'A' packet that delivers program 92314564Sdim /// arguments to the remote server. 93314564Sdim /// 94314564Sdim /// @param[in] argv 95314564Sdim /// A NULL terminated array of const C strings to use as the 96314564Sdim /// arguments. 97314564Sdim /// 98314564Sdim /// @return 99314564Sdim /// Zero if the response was "OK", a positive value if the 100314564Sdim /// the response was "Exx" where xx are two hex digits, or 101314564Sdim /// -1 if the call is unsupported or any other unexpected 102314564Sdim /// response was received. 103314564Sdim //------------------------------------------------------------------ 104314564Sdim int SendArgumentsPacket(const ProcessLaunchInfo &launch_info); 105254721Semaste 106314564Sdim //------------------------------------------------------------------ 107314564Sdim /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the 108314564Sdim /// environment that will get used when launching an application 109314564Sdim /// in conjunction with the 'A' packet. This function can be called 110314564Sdim /// multiple times in a row in order to pass on the desired 111314564Sdim /// environment that the inferior should be launched with. 112314564Sdim /// 113314564Sdim /// @param[in] name_equal_value 114314564Sdim /// A NULL terminated C string that contains a single environment 115314564Sdim /// in the format "NAME=VALUE". 116314564Sdim /// 117314564Sdim /// @return 118314564Sdim /// Zero if the response was "OK", a positive value if the 119314564Sdim /// the response was "Exx" where xx are two hex digits, or 120314564Sdim /// -1 if the call is unsupported or any other unexpected 121314564Sdim /// response was received. 122314564Sdim //------------------------------------------------------------------ 123314564Sdim int SendEnvironmentPacket(char const *name_equal_value); 124341825Sdim int SendEnvironment(const Environment &env); 125254721Semaste 126314564Sdim int SendLaunchArchPacket(const char *arch); 127254721Semaste 128314564Sdim int SendLaunchEventDataPacket(const char *data, 129314564Sdim bool *was_supported = nullptr); 130296417Sdim 131314564Sdim //------------------------------------------------------------------ 132314564Sdim /// Sends a "vAttach:PID" where PID is in hex. 133314564Sdim /// 134314564Sdim /// @param[in] pid 135314564Sdim /// A process ID for the remote gdb server to attach to. 136314564Sdim /// 137314564Sdim /// @param[out] response 138314564Sdim /// The response received from the gdb server. If the return 139314564Sdim /// value is zero, \a response will contain a stop reply 140314564Sdim /// packet. 141314564Sdim /// 142314564Sdim /// @return 143314564Sdim /// Zero if the attach was successful, or an error indicating 144314564Sdim /// an error code. 145314564Sdim //------------------------------------------------------------------ 146314564Sdim int SendAttach(lldb::pid_t pid, StringExtractorGDBRemote &response); 147296417Sdim 148314564Sdim //------------------------------------------------------------------ 149314564Sdim /// Sends a GDB remote protocol 'I' packet that delivers stdin 150314564Sdim /// data to the remote process. 151314564Sdim /// 152314564Sdim /// @param[in] data 153314564Sdim /// A pointer to stdin data. 154314564Sdim /// 155314564Sdim /// @param[in] data_len 156314564Sdim /// The number of bytes available at \a data. 157314564Sdim /// 158314564Sdim /// @return 159314564Sdim /// Zero if the attach was successful, or an error indicating 160314564Sdim /// an error code. 161314564Sdim //------------------------------------------------------------------ 162314564Sdim int SendStdinNotification(const char *data, size_t data_len); 163254721Semaste 164314564Sdim //------------------------------------------------------------------ 165314564Sdim /// Sets the path to use for stdin/out/err for a process 166314564Sdim /// that will be launched with the 'A' packet. 167314564Sdim /// 168314564Sdim /// @param[in] path 169314564Sdim /// The path to use for stdin/out/err 170314564Sdim /// 171314564Sdim /// @return 172314564Sdim /// Zero if the for success, or an error code for failure. 173314564Sdim //------------------------------------------------------------------ 174314564Sdim int SetSTDIN(const FileSpec &file_spec); 175314564Sdim int SetSTDOUT(const FileSpec &file_spec); 176314564Sdim int SetSTDERR(const FileSpec &file_spec); 177254721Semaste 178314564Sdim //------------------------------------------------------------------ 179314564Sdim /// Sets the disable ASLR flag to \a enable for a process that will 180314564Sdim /// be launched with the 'A' packet. 181314564Sdim /// 182314564Sdim /// @param[in] enable 183314564Sdim /// A boolean value indicating whether to disable ASLR or not. 184314564Sdim /// 185314564Sdim /// @return 186314564Sdim /// Zero if the for success, or an error code for failure. 187314564Sdim //------------------------------------------------------------------ 188314564Sdim int SetDisableASLR(bool enable); 189254721Semaste 190314564Sdim //------------------------------------------------------------------ 191314564Sdim /// Sets the DetachOnError flag to \a enable for the process controlled by the 192314564Sdim /// stub. 193314564Sdim /// 194314564Sdim /// @param[in] enable 195314564Sdim /// A boolean value indicating whether to detach on error or not. 196314564Sdim /// 197314564Sdim /// @return 198314564Sdim /// Zero if the for success, or an error code for failure. 199314564Sdim //------------------------------------------------------------------ 200314564Sdim int SetDetachOnError(bool enable); 201254721Semaste 202314564Sdim //------------------------------------------------------------------ 203314564Sdim /// Sets the working directory to \a path for a process that will 204314564Sdim /// be launched with the 'A' packet for non platform based 205314564Sdim /// connections. If this packet is sent to a GDB server that 206314564Sdim /// implements the platform, it will change the current working 207314564Sdim /// directory for the platform process. 208314564Sdim /// 209314564Sdim /// @param[in] working_dir 210314564Sdim /// The path to a directory to use when launching our process 211314564Sdim /// 212314564Sdim /// @return 213314564Sdim /// Zero if the for success, or an error code for failure. 214314564Sdim //------------------------------------------------------------------ 215314564Sdim int SetWorkingDir(const FileSpec &working_dir); 216288943Sdim 217314564Sdim //------------------------------------------------------------------ 218314564Sdim /// Gets the current working directory of a remote platform GDB 219314564Sdim /// server. 220314564Sdim /// 221314564Sdim /// @param[out] working_dir 222314564Sdim /// The current working directory on the remote platform. 223314564Sdim /// 224314564Sdim /// @return 225314564Sdim /// Boolean for success 226314564Sdim //------------------------------------------------------------------ 227314564Sdim bool GetWorkingDir(FileSpec &working_dir); 228254721Semaste 229314564Sdim lldb::addr_t AllocateMemory(size_t size, uint32_t permissions); 230254721Semaste 231314564Sdim bool DeallocateMemory(lldb::addr_t addr); 232254721Semaste 233321369Sdim Status Detach(bool keep_stopped); 234258884Semaste 235321369Sdim Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); 236254721Semaste 237321369Sdim Status GetWatchpointSupportInfo(uint32_t &num); 238254721Semaste 239321369Sdim Status GetWatchpointSupportInfo(uint32_t &num, bool &after, 240321369Sdim const ArchSpec &arch); 241254721Semaste 242321369Sdim Status GetWatchpointsTriggerAfterInstruction(bool &after, 243321369Sdim const ArchSpec &arch); 244254721Semaste 245314564Sdim const ArchSpec &GetHostArchitecture(); 246254721Semaste 247314564Sdim std::chrono::seconds GetHostDefaultPacketTimeout(); 248254721Semaste 249314564Sdim const ArchSpec &GetProcessArchitecture(); 250254721Semaste 251314564Sdim void GetRemoteQSupported(); 252254721Semaste 253314564Sdim bool GetVContSupported(char flavor); 254262528Semaste 255314564Sdim bool GetpPacketSupported(lldb::tid_t tid); 256254721Semaste 257314564Sdim bool GetxPacketSupported(); 258258054Semaste 259314564Sdim bool GetVAttachOrWaitSupported(); 260276479Sdim 261314564Sdim bool GetSyncThreadStateSupported(); 262254721Semaste 263314564Sdim void ResetDiscoverableSettings(bool did_exec); 264288943Sdim 265314564Sdim bool GetHostInfo(bool force = false); 266254721Semaste 267314564Sdim bool GetDefaultThreadId(lldb::tid_t &tid); 268254721Semaste 269341825Sdim llvm::VersionTuple GetOSVersion(); 270254721Semaste 271314564Sdim bool GetOSBuildString(std::string &s); 272254721Semaste 273314564Sdim bool GetOSKernelDescription(std::string &s); 274254721Semaste 275314564Sdim ArchSpec GetSystemArchitecture(); 276254721Semaste 277314564Sdim bool GetHostname(std::string &s); 278254721Semaste 279314564Sdim lldb::addr_t GetShlibInfoAddr(); 280254721Semaste 281314564Sdim bool GetSupportsThreadSuffix(); 282254721Semaste 283314564Sdim bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info); 284254721Semaste 285314564Sdim uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, 286314564Sdim ProcessInstanceInfoList &process_infos); 287254721Semaste 288314564Sdim bool GetUserName(uint32_t uid, std::string &name); 289254721Semaste 290314564Sdim bool GetGroupName(uint32_t gid, std::string &name); 291314564Sdim 292314564Sdim bool HasFullVContSupport() { return GetVContSupported('A'); } 293314564Sdim 294314564Sdim bool HasAnyVContSupport() { return GetVContSupported('a'); } 295314564Sdim 296314564Sdim bool GetStopReply(StringExtractorGDBRemote &response); 297314564Sdim 298314564Sdim bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response); 299314564Sdim 300314564Sdim bool SupportsGDBStoppointPacket(GDBStoppointType type) { 301314564Sdim switch (type) { 302314564Sdim case eBreakpointSoftware: 303314564Sdim return m_supports_z0; 304314564Sdim case eBreakpointHardware: 305314564Sdim return m_supports_z1; 306314564Sdim case eWatchpointWrite: 307314564Sdim return m_supports_z2; 308314564Sdim case eWatchpointRead: 309314564Sdim return m_supports_z3; 310314564Sdim case eWatchpointReadWrite: 311314564Sdim return m_supports_z4; 312314564Sdim default: 313314564Sdim return false; 314254721Semaste } 315314564Sdim } 316296417Sdim 317314564Sdim uint8_t SendGDBStoppointTypePacket( 318314564Sdim GDBStoppointType type, // Type of breakpoint or watchpoint 319314564Sdim bool insert, // Insert or remove? 320314564Sdim lldb::addr_t addr, // Address of breakpoint or watchpoint 321314564Sdim uint32_t length); // Byte Size of breakpoint or watchpoint 322254721Semaste 323314564Sdim bool SetNonStopMode(const bool enable); 324288943Sdim 325314564Sdim void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, 326314564Sdim uint32_t max_recv, uint64_t recv_amount, bool json, 327314564Sdim Stream &strm); 328254721Semaste 329314564Sdim // This packet is for testing the speed of the interface only. Both 330314564Sdim // the client and server need to support it, but this allows us to 331314564Sdim // measure the packet speed without any other work being done on the 332314564Sdim // other end and avoids any of that work affecting the packet send 333314564Sdim // and response times. 334314564Sdim bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); 335254721Semaste 336314564Sdim bool SetCurrentThread(uint64_t tid); 337276479Sdim 338314564Sdim bool SetCurrentThreadForRun(uint64_t tid); 339262528Semaste 340314564Sdim bool GetQXferAuxvReadSupported(); 341262528Semaste 342321369Sdim void EnableErrorStringInPacket(); 343321369Sdim 344314564Sdim bool GetQXferLibrariesReadSupported(); 345262528Semaste 346314564Sdim bool GetQXferLibrariesSVR4ReadSupported(); 347288943Sdim 348314564Sdim uint64_t GetRemoteMaxPacketSize(); 349262528Semaste 350314564Sdim bool GetEchoSupported(); 351288943Sdim 352321369Sdim bool GetQPassSignalsSupported(); 353321369Sdim 354314564Sdim bool GetAugmentedLibrariesSVR4ReadSupported(); 355254721Semaste 356314564Sdim bool GetQXferFeaturesReadSupported(); 357258054Semaste 358341825Sdim bool GetQXferMemoryMapReadSupported(); 359341825Sdim 360314564Sdim LazyBool SupportsAllocDeallocMemory() // const 361314564Sdim { 362314564Sdim // Uncomment this to have lldb pretend the debug server doesn't respond to 363314564Sdim // alloc/dealloc memory packets. 364314564Sdim // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; 365314564Sdim return m_supports_alloc_dealloc_memory; 366314564Sdim } 367258884Semaste 368314564Sdim size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids, 369314564Sdim bool &sequence_mutex_unavailable); 370258884Semaste 371314564Sdim lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, 372321369Sdim mode_t mode, Status &error); 373288943Sdim 374321369Sdim bool CloseFile(lldb::user_id_t fd, Status &error); 375288943Sdim 376314564Sdim lldb::user_id_t GetFileSize(const FileSpec &file_spec); 377258054Semaste 378321369Sdim Status GetFilePermissions(const FileSpec &file_spec, 379321369Sdim uint32_t &file_permissions); 380258884Semaste 381321369Sdim Status SetFilePermissions(const FileSpec &file_spec, 382321369Sdim uint32_t file_permissions); 383258884Semaste 384314564Sdim uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, 385321369Sdim uint64_t dst_len, Status &error); 386276479Sdim 387314564Sdim uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, 388321369Sdim uint64_t src_len, Status &error); 389276479Sdim 390321369Sdim Status CreateSymlink(const FileSpec &src, const FileSpec &dst); 391276479Sdim 392321369Sdim Status Unlink(const FileSpec &file_spec); 393288943Sdim 394321369Sdim Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); 395276479Sdim 396314564Sdim bool GetFileExists(const FileSpec &file_spec); 397288943Sdim 398321369Sdim Status RunShellCommand( 399314564Sdim const char *command, // Shouldn't be nullptr 400314564Sdim const FileSpec &working_dir, // Pass empty FileSpec to use the current 401314564Sdim // working directory 402314564Sdim int *status_ptr, // Pass nullptr if you don't want the process exit status 403314564Sdim int *signo_ptr, // Pass nullptr if you don't want the signal that caused 404314564Sdim // the process to exit 405314564Sdim std::string 406314564Sdim *command_output, // Pass nullptr if you don't want the command output 407341825Sdim const Timeout<std::micro> &timeout); 408288943Sdim 409314564Sdim bool CalculateMD5(const FileSpec &file_spec, uint64_t &high, uint64_t &low); 410288943Sdim 411314564Sdim lldb::DataBufferSP ReadRegister( 412314564Sdim lldb::tid_t tid, 413314564Sdim uint32_t 414314564Sdim reg_num); // Must be the eRegisterKindProcessPlugin register number 415288943Sdim 416314564Sdim lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid); 417314564Sdim 418314564Sdim bool 419314564Sdim WriteRegister(lldb::tid_t tid, 420314564Sdim uint32_t reg_num, // eRegisterKindProcessPlugin register number 421314564Sdim llvm::ArrayRef<uint8_t> data); 422314564Sdim 423314564Sdim bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data); 424314564Sdim 425314564Sdim bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id); 426314564Sdim 427314564Sdim bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id); 428314564Sdim 429314564Sdim bool SyncThreadState(lldb::tid_t tid); 430314564Sdim 431314564Sdim const char *GetGDBServerProgramName(); 432314564Sdim 433314564Sdim uint32_t GetGDBServerProgramVersion(); 434314564Sdim 435314564Sdim bool AvoidGPackets(ProcessGDBRemote *process); 436314564Sdim 437314564Sdim StructuredData::ObjectSP GetThreadsInfo(); 438314564Sdim 439314564Sdim bool GetThreadExtendedInfoSupported(); 440314564Sdim 441314564Sdim bool GetLoadedDynamicLibrariesInfosSupported(); 442314564Sdim 443314564Sdim bool GetSharedCacheInfoSupported(); 444314564Sdim 445314564Sdim bool GetModuleInfo(const FileSpec &module_file_spec, 446314564Sdim const ArchSpec &arch_spec, ModuleSpec &module_spec); 447314564Sdim 448314564Sdim llvm::Optional<std::vector<ModuleSpec>> 449314564Sdim GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs, 450314564Sdim const llvm::Triple &triple); 451314564Sdim 452314564Sdim bool ReadExtFeature(const lldb_private::ConstString object, 453314564Sdim const lldb_private::ConstString annex, std::string &out, 454321369Sdim lldb_private::Status &err); 455314564Sdim 456314564Sdim void ServeSymbolLookups(lldb_private::Process *process); 457314564Sdim 458321369Sdim // Sends QPassSignals packet to the server with given signals to ignore. 459321369Sdim Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); 460321369Sdim 461314564Sdim //------------------------------------------------------------------ 462314564Sdim /// Return the feature set supported by the gdb-remote server. 463314564Sdim /// 464314564Sdim /// This method returns the remote side's response to the qSupported 465314564Sdim /// packet. The response is the complete string payload returned 466314564Sdim /// to the client. 467314564Sdim /// 468314564Sdim /// @return 469314564Sdim /// The string returned by the server to the qSupported query. 470314564Sdim //------------------------------------------------------------------ 471314564Sdim const std::string &GetServerSupportedFeatures() const { 472314564Sdim return m_qSupported_response; 473314564Sdim } 474314564Sdim 475314564Sdim //------------------------------------------------------------------ 476314564Sdim /// Return the array of async JSON packet types supported by the remote. 477314564Sdim /// 478314564Sdim /// This method returns the remote side's array of supported JSON 479314564Sdim /// packet types as a list of type names. Each of the results are 480314564Sdim /// expected to have an Enable{type_name} command to enable and configure 481314564Sdim /// the related feature. Each type_name for an enabled feature will 482314564Sdim /// possibly send async-style packets that contain a payload of a 483314564Sdim /// binhex-encoded JSON dictionary. The dictionary will have a 484314564Sdim /// string field named 'type', that contains the type_name of the 485314564Sdim /// supported packet type. 486314564Sdim /// 487314564Sdim /// There is a Plugin category called structured-data plugins. 488314564Sdim /// A plugin indicates whether it knows how to handle a type_name. 489314564Sdim /// If so, it can be used to process the async JSON packet. 490314564Sdim /// 491314564Sdim /// @return 492314564Sdim /// The string returned by the server to the qSupported query. 493314564Sdim //------------------------------------------------------------------ 494314564Sdim lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins(); 495314564Sdim 496314564Sdim //------------------------------------------------------------------ 497314564Sdim /// Configure a StructuredData feature on the remote end. 498314564Sdim /// 499314564Sdim /// @see \b Process::ConfigureStructuredData(...) for details. 500314564Sdim //------------------------------------------------------------------ 501321369Sdim Status 502314564Sdim ConfigureRemoteStructuredData(const ConstString &type_name, 503314564Sdim const StructuredData::ObjectSP &config_sp); 504314564Sdim 505321369Sdim lldb::user_id_t SendStartTracePacket(const TraceOptions &options, 506321369Sdim Status &error); 507321369Sdim 508321369Sdim Status SendStopTracePacket(lldb::user_id_t uid, lldb::tid_t thread_id); 509321369Sdim 510321369Sdim Status SendGetDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, 511321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 512321369Sdim size_t offset = 0); 513321369Sdim 514321369Sdim Status SendGetMetaDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, 515321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 516321369Sdim size_t offset = 0); 517321369Sdim 518321369Sdim Status SendGetTraceConfigPacket(lldb::user_id_t uid, TraceOptions &options); 519321369Sdim 520254721Semasteprotected: 521314564Sdim LazyBool m_supports_not_sending_acks; 522314564Sdim LazyBool m_supports_thread_suffix; 523314564Sdim LazyBool m_supports_threads_in_stop_reply; 524314564Sdim LazyBool m_supports_vCont_all; 525314564Sdim LazyBool m_supports_vCont_any; 526314564Sdim LazyBool m_supports_vCont_c; 527314564Sdim LazyBool m_supports_vCont_C; 528314564Sdim LazyBool m_supports_vCont_s; 529314564Sdim LazyBool m_supports_vCont_S; 530314564Sdim LazyBool m_qHostInfo_is_valid; 531314564Sdim LazyBool m_curr_pid_is_valid; 532314564Sdim LazyBool m_qProcessInfo_is_valid; 533314564Sdim LazyBool m_qGDBServerVersion_is_valid; 534314564Sdim LazyBool m_supports_alloc_dealloc_memory; 535314564Sdim LazyBool m_supports_memory_region_info; 536314564Sdim LazyBool m_supports_watchpoint_support_info; 537314564Sdim LazyBool m_supports_detach_stay_stopped; 538314564Sdim LazyBool m_watchpoints_trigger_after_instruction; 539314564Sdim LazyBool m_attach_or_wait_reply; 540314564Sdim LazyBool m_prepare_for_reg_writing_reply; 541314564Sdim LazyBool m_supports_p; 542314564Sdim LazyBool m_supports_x; 543314564Sdim LazyBool m_avoid_g_packets; 544314564Sdim LazyBool m_supports_QSaveRegisterState; 545314564Sdim LazyBool m_supports_qXfer_auxv_read; 546314564Sdim LazyBool m_supports_qXfer_libraries_read; 547314564Sdim LazyBool m_supports_qXfer_libraries_svr4_read; 548314564Sdim LazyBool m_supports_qXfer_features_read; 549341825Sdim LazyBool m_supports_qXfer_memory_map_read; 550314564Sdim LazyBool m_supports_augmented_libraries_svr4_read; 551314564Sdim LazyBool m_supports_jThreadExtendedInfo; 552314564Sdim LazyBool m_supports_jLoadedDynamicLibrariesInfos; 553314564Sdim LazyBool m_supports_jGetSharedCacheInfo; 554321369Sdim LazyBool m_supports_QPassSignals; 555321369Sdim LazyBool m_supports_error_string_reply; 556262528Semaste 557314564Sdim bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1, 558314564Sdim m_supports_qUserName : 1, m_supports_qGroupName : 1, 559314564Sdim m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1, 560314564Sdim m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1, 561314564Sdim m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1, 562314564Sdim m_supports_qSymbol : 1, m_qSymbol_requests_done : 1, 563314564Sdim m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1, 564314564Sdim m_supports_jModulesInfo : 1; 565254721Semaste 566314564Sdim lldb::pid_t m_curr_pid; 567314564Sdim lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all 568314564Sdim // other operations 569314564Sdim lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for 570314564Sdim // continue, step, etc 571254721Semaste 572314564Sdim uint32_t m_num_supported_hardware_watchpoints; 573288943Sdim 574314564Sdim ArchSpec m_host_arch; 575314564Sdim ArchSpec m_process_arch; 576341825Sdim llvm::VersionTuple m_os_version; 577314564Sdim std::string m_os_build; 578314564Sdim std::string m_os_kernel; 579314564Sdim std::string m_hostname; 580314564Sdim std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if 581314564Sdim // qGDBServerVersion is not supported 582314564Sdim uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if 583314564Sdim // qGDBServerVersion is not supported 584314564Sdim std::chrono::seconds m_default_packet_timeout; 585314564Sdim uint64_t m_max_packet_size; // as returned by qSupported 586314564Sdim std::string m_qSupported_response; // the complete response to qSupported 587296417Sdim 588314564Sdim bool m_supported_async_json_packets_is_valid; 589314564Sdim lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp; 590296417Sdim 591341825Sdim std::vector<MemoryRegionInfo> m_qXfer_memory_map; 592341825Sdim bool m_qXfer_memory_map_loaded; 593341825Sdim 594314564Sdim bool GetCurrentProcessInfo(bool allow_lazy_pid = true); 595296417Sdim 596314564Sdim bool GetGDBServerVersion(); 597296417Sdim 598314564Sdim // Given the list of compression types that the remote debug stub can support, 599314564Sdim // possibly enable compression if we find an encoding we can handle. 600314564Sdim void MaybeEnableCompression(std::vector<std::string> supported_compressions); 601296417Sdim 602314564Sdim bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response, 603314564Sdim ProcessInstanceInfo &process_info); 604314564Sdim 605314564Sdim void OnRunPacketSent(bool first) override; 606314564Sdim 607314564Sdim PacketResult SendThreadSpecificPacketAndWaitForResponse( 608314564Sdim lldb::tid_t tid, StreamString &&payload, 609314564Sdim StringExtractorGDBRemote &response, bool send_async); 610314564Sdim 611321369Sdim Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid, 612321369Sdim lldb::tid_t thread_id, 613321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 614321369Sdim size_t offset); 615321369Sdim 616341825Sdim Status LoadQXferMemoryMap(); 617341825Sdim 618341825Sdim Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr, 619341825Sdim MemoryRegionInfo ®ion); 620341825Sdim 621254721Semasteprivate: 622314564Sdim DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationClient); 623254721Semaste}; 624254721Semaste 625288943Sdim} // namespace process_gdb_remote 626288943Sdim} // namespace lldb_private 627288943Sdim 628296417Sdim#endif // liblldb_GDBRemoteCommunicationClient_h_ 629