GDBRemoteCommunicationClient.h revision 321369
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// Other libraries and framework includes 24254721Semaste// Project includes 25254721Semaste#include "lldb/Core/ArchSpec.h" 26254721Semaste#include "lldb/Target/Process.h" 27321369Sdim#include "lldb/Utility/StreamGDBRemote.h" 28321369Sdim#include "lldb/Utility/StructuredData.h" 29254721Semaste 30314564Sdim#include "llvm/ADT/Optional.h" 31254721Semaste 32288943Sdimnamespace lldb_private { 33288943Sdimnamespace process_gdb_remote { 34254721Semaste 35314564Sdimclass GDBRemoteCommunicationClient : public GDBRemoteClientBase { 36254721Semastepublic: 37314564Sdim GDBRemoteCommunicationClient(); 38254721Semaste 39314564Sdim ~GDBRemoteCommunicationClient() override; 40254721Semaste 41314564Sdim //------------------------------------------------------------------ 42314564Sdim // After connecting, send the handshake to the server to make sure 43314564Sdim // we are communicating with it. 44314564Sdim //------------------------------------------------------------------ 45321369Sdim bool HandshakeWithServer(Status *error_ptr); 46254721Semaste 47314564Sdim // For packets which specify a range of output to be returned, 48314564Sdim // return all of the output via a series of request packets of the form 49314564Sdim // <prefix>0,<size> 50314564Sdim // <prefix><size>,<size> 51314564Sdim // <prefix><size>*2,<size> 52314564Sdim // <prefix><size>*3,<size> 53314564Sdim // ... 54314564Sdim // until a "$l..." packet is received, indicating the end. 55314564Sdim // (size is in hex; this format is used by a standard gdbserver to 56314564Sdim // return the given portion of the output specified by <prefix>; 57314564Sdim // for example, "qXfer:libraries-svr4:read::fff,1000" means 58314564Sdim // "return a chunk of the xml description file for shared 59314564Sdim // library load addresses, where the chunk starts at offset 0xfff 60314564Sdim // and continues for 0x1000 bytes"). 61314564Sdim // Concatenate the resulting server response packets together and 62314564Sdim // return in response_string. If any packet fails, the return value 63314564Sdim // indicates that failure and the returned string value is undefined. 64314564Sdim PacketResult 65314564Sdim SendPacketsAndConcatenateResponses(const char *send_payload_prefix, 66314564Sdim std::string &response_string); 67254721Semaste 68314564Sdim bool GetThreadSuffixSupported(); 69254721Semaste 70314564Sdim // This packet is usually sent first and the boolean return value 71314564Sdim // indicates if the packet was send and any response was received 72314564Sdim // even in the response is UNIMPLEMENTED. If the packet failed to 73314564Sdim // get a response, then false is returned. This quickly tells us 74314564Sdim // if we were able to connect and communicate with the remote GDB 75314564Sdim // server 76314564Sdim bool QueryNoAckModeSupported(); 77262528Semaste 78314564Sdim void GetListThreadsInStopReplySupported(); 79296417Sdim 80314564Sdim lldb::pid_t GetCurrentProcessID(bool allow_lazy = true); 81254721Semaste 82314564Sdim bool GetLaunchSuccess(std::string &error_str); 83254721Semaste 84314564Sdim bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid, 85314564Sdim uint16_t &port, std::string &socket_name); 86254721Semaste 87314564Sdim size_t QueryGDBServer( 88314564Sdim std::vector<std::pair<uint16_t, std::string>> &connection_urls); 89254721Semaste 90314564Sdim bool KillSpawnedProcess(lldb::pid_t pid); 91254721Semaste 92314564Sdim //------------------------------------------------------------------ 93314564Sdim /// Sends a GDB remote protocol 'A' packet that delivers program 94314564Sdim /// arguments to the remote server. 95314564Sdim /// 96314564Sdim /// @param[in] argv 97314564Sdim /// A NULL terminated array of const C strings to use as the 98314564Sdim /// arguments. 99314564Sdim /// 100314564Sdim /// @return 101314564Sdim /// Zero if the response was "OK", a positive value if the 102314564Sdim /// the response was "Exx" where xx are two hex digits, or 103314564Sdim /// -1 if the call is unsupported or any other unexpected 104314564Sdim /// response was received. 105314564Sdim //------------------------------------------------------------------ 106314564Sdim int SendArgumentsPacket(const ProcessLaunchInfo &launch_info); 107254721Semaste 108314564Sdim //------------------------------------------------------------------ 109314564Sdim /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the 110314564Sdim /// environment that will get used when launching an application 111314564Sdim /// in conjunction with the 'A' packet. This function can be called 112314564Sdim /// multiple times in a row in order to pass on the desired 113314564Sdim /// environment that the inferior should be launched with. 114314564Sdim /// 115314564Sdim /// @param[in] name_equal_value 116314564Sdim /// A NULL terminated C string that contains a single environment 117314564Sdim /// in the format "NAME=VALUE". 118314564Sdim /// 119314564Sdim /// @return 120314564Sdim /// Zero if the response was "OK", a positive value if the 121314564Sdim /// the response was "Exx" where xx are two hex digits, or 122314564Sdim /// -1 if the call is unsupported or any other unexpected 123314564Sdim /// response was received. 124314564Sdim //------------------------------------------------------------------ 125314564Sdim int SendEnvironmentPacket(char const *name_equal_value); 126254721Semaste 127314564Sdim int SendLaunchArchPacket(const char *arch); 128254721Semaste 129314564Sdim int SendLaunchEventDataPacket(const char *data, 130314564Sdim bool *was_supported = nullptr); 131296417Sdim 132314564Sdim //------------------------------------------------------------------ 133314564Sdim /// Sends a "vAttach:PID" where PID is in hex. 134314564Sdim /// 135314564Sdim /// @param[in] pid 136314564Sdim /// A process ID for the remote gdb server to attach to. 137314564Sdim /// 138314564Sdim /// @param[out] response 139314564Sdim /// The response received from the gdb server. If the return 140314564Sdim /// value is zero, \a response will contain a stop reply 141314564Sdim /// packet. 142314564Sdim /// 143314564Sdim /// @return 144314564Sdim /// Zero if the attach was successful, or an error indicating 145314564Sdim /// an error code. 146314564Sdim //------------------------------------------------------------------ 147314564Sdim int SendAttach(lldb::pid_t pid, StringExtractorGDBRemote &response); 148296417Sdim 149314564Sdim //------------------------------------------------------------------ 150314564Sdim /// Sends a GDB remote protocol 'I' packet that delivers stdin 151314564Sdim /// data to the remote process. 152314564Sdim /// 153314564Sdim /// @param[in] data 154314564Sdim /// A pointer to stdin data. 155314564Sdim /// 156314564Sdim /// @param[in] data_len 157314564Sdim /// The number of bytes available at \a data. 158314564Sdim /// 159314564Sdim /// @return 160314564Sdim /// Zero if the attach was successful, or an error indicating 161314564Sdim /// an error code. 162314564Sdim //------------------------------------------------------------------ 163314564Sdim int SendStdinNotification(const char *data, size_t data_len); 164254721Semaste 165314564Sdim //------------------------------------------------------------------ 166314564Sdim /// Sets the path to use for stdin/out/err for a process 167314564Sdim /// that will be launched with the 'A' packet. 168314564Sdim /// 169314564Sdim /// @param[in] path 170314564Sdim /// The path to use for stdin/out/err 171314564Sdim /// 172314564Sdim /// @return 173314564Sdim /// Zero if the for success, or an error code for failure. 174314564Sdim //------------------------------------------------------------------ 175314564Sdim int SetSTDIN(const FileSpec &file_spec); 176314564Sdim int SetSTDOUT(const FileSpec &file_spec); 177314564Sdim int SetSTDERR(const FileSpec &file_spec); 178254721Semaste 179314564Sdim //------------------------------------------------------------------ 180314564Sdim /// Sets the disable ASLR flag to \a enable for a process that will 181314564Sdim /// be launched with the 'A' packet. 182314564Sdim /// 183314564Sdim /// @param[in] enable 184314564Sdim /// A boolean value indicating whether to disable ASLR or not. 185314564Sdim /// 186314564Sdim /// @return 187314564Sdim /// Zero if the for success, or an error code for failure. 188314564Sdim //------------------------------------------------------------------ 189314564Sdim int SetDisableASLR(bool enable); 190254721Semaste 191314564Sdim //------------------------------------------------------------------ 192314564Sdim /// Sets the DetachOnError flag to \a enable for the process controlled by the 193314564Sdim /// stub. 194314564Sdim /// 195314564Sdim /// @param[in] enable 196314564Sdim /// A boolean value indicating whether to detach on error or not. 197314564Sdim /// 198314564Sdim /// @return 199314564Sdim /// Zero if the for success, or an error code for failure. 200314564Sdim //------------------------------------------------------------------ 201314564Sdim int SetDetachOnError(bool enable); 202254721Semaste 203314564Sdim //------------------------------------------------------------------ 204314564Sdim /// Sets the working directory to \a path for a process that will 205314564Sdim /// be launched with the 'A' packet for non platform based 206314564Sdim /// connections. If this packet is sent to a GDB server that 207314564Sdim /// implements the platform, it will change the current working 208314564Sdim /// directory for the platform process. 209314564Sdim /// 210314564Sdim /// @param[in] working_dir 211314564Sdim /// The path to a directory to use when launching our process 212314564Sdim /// 213314564Sdim /// @return 214314564Sdim /// Zero if the for success, or an error code for failure. 215314564Sdim //------------------------------------------------------------------ 216314564Sdim int SetWorkingDir(const FileSpec &working_dir); 217288943Sdim 218314564Sdim //------------------------------------------------------------------ 219314564Sdim /// Gets the current working directory of a remote platform GDB 220314564Sdim /// server. 221314564Sdim /// 222314564Sdim /// @param[out] working_dir 223314564Sdim /// The current working directory on the remote platform. 224314564Sdim /// 225314564Sdim /// @return 226314564Sdim /// Boolean for success 227314564Sdim //------------------------------------------------------------------ 228314564Sdim bool GetWorkingDir(FileSpec &working_dir); 229254721Semaste 230314564Sdim lldb::addr_t AllocateMemory(size_t size, uint32_t permissions); 231254721Semaste 232314564Sdim bool DeallocateMemory(lldb::addr_t addr); 233254721Semaste 234321369Sdim Status Detach(bool keep_stopped); 235258884Semaste 236321369Sdim Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); 237254721Semaste 238321369Sdim Status GetWatchpointSupportInfo(uint32_t &num); 239254721Semaste 240321369Sdim Status GetWatchpointSupportInfo(uint32_t &num, bool &after, 241321369Sdim const ArchSpec &arch); 242254721Semaste 243321369Sdim Status GetWatchpointsTriggerAfterInstruction(bool &after, 244321369Sdim const ArchSpec &arch); 245254721Semaste 246314564Sdim const ArchSpec &GetHostArchitecture(); 247254721Semaste 248314564Sdim std::chrono::seconds GetHostDefaultPacketTimeout(); 249254721Semaste 250314564Sdim const ArchSpec &GetProcessArchitecture(); 251254721Semaste 252314564Sdim void GetRemoteQSupported(); 253254721Semaste 254314564Sdim bool GetVContSupported(char flavor); 255262528Semaste 256314564Sdim bool GetpPacketSupported(lldb::tid_t tid); 257254721Semaste 258314564Sdim bool GetxPacketSupported(); 259258054Semaste 260314564Sdim bool GetVAttachOrWaitSupported(); 261276479Sdim 262314564Sdim bool GetSyncThreadStateSupported(); 263254721Semaste 264314564Sdim void ResetDiscoverableSettings(bool did_exec); 265288943Sdim 266314564Sdim bool GetHostInfo(bool force = false); 267254721Semaste 268314564Sdim bool GetDefaultThreadId(lldb::tid_t &tid); 269254721Semaste 270314564Sdim bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); 271254721Semaste 272314564Sdim bool GetOSBuildString(std::string &s); 273254721Semaste 274314564Sdim bool GetOSKernelDescription(std::string &s); 275254721Semaste 276314564Sdim ArchSpec GetSystemArchitecture(); 277254721Semaste 278314564Sdim bool GetHostname(std::string &s); 279254721Semaste 280314564Sdim lldb::addr_t GetShlibInfoAddr(); 281254721Semaste 282314564Sdim bool GetSupportsThreadSuffix(); 283254721Semaste 284314564Sdim bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info); 285254721Semaste 286314564Sdim uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, 287314564Sdim ProcessInstanceInfoList &process_infos); 288254721Semaste 289314564Sdim bool GetUserName(uint32_t uid, std::string &name); 290254721Semaste 291314564Sdim bool GetGroupName(uint32_t gid, std::string &name); 292314564Sdim 293314564Sdim bool HasFullVContSupport() { return GetVContSupported('A'); } 294314564Sdim 295314564Sdim bool HasAnyVContSupport() { return GetVContSupported('a'); } 296314564Sdim 297314564Sdim bool GetStopReply(StringExtractorGDBRemote &response); 298314564Sdim 299314564Sdim bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response); 300314564Sdim 301314564Sdim bool SupportsGDBStoppointPacket(GDBStoppointType type) { 302314564Sdim switch (type) { 303314564Sdim case eBreakpointSoftware: 304314564Sdim return m_supports_z0; 305314564Sdim case eBreakpointHardware: 306314564Sdim return m_supports_z1; 307314564Sdim case eWatchpointWrite: 308314564Sdim return m_supports_z2; 309314564Sdim case eWatchpointRead: 310314564Sdim return m_supports_z3; 311314564Sdim case eWatchpointReadWrite: 312314564Sdim return m_supports_z4; 313314564Sdim default: 314314564Sdim return false; 315254721Semaste } 316314564Sdim } 317296417Sdim 318314564Sdim uint8_t SendGDBStoppointTypePacket( 319314564Sdim GDBStoppointType type, // Type of breakpoint or watchpoint 320314564Sdim bool insert, // Insert or remove? 321314564Sdim lldb::addr_t addr, // Address of breakpoint or watchpoint 322314564Sdim uint32_t length); // Byte Size of breakpoint or watchpoint 323254721Semaste 324314564Sdim bool SetNonStopMode(const bool enable); 325288943Sdim 326314564Sdim void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, 327314564Sdim uint32_t max_recv, uint64_t recv_amount, bool json, 328314564Sdim Stream &strm); 329254721Semaste 330314564Sdim // This packet is for testing the speed of the interface only. Both 331314564Sdim // the client and server need to support it, but this allows us to 332314564Sdim // measure the packet speed without any other work being done on the 333314564Sdim // other end and avoids any of that work affecting the packet send 334314564Sdim // and response times. 335314564Sdim bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); 336254721Semaste 337314564Sdim bool SetCurrentThread(uint64_t tid); 338276479Sdim 339314564Sdim bool SetCurrentThreadForRun(uint64_t tid); 340262528Semaste 341314564Sdim bool GetQXferAuxvReadSupported(); 342262528Semaste 343321369Sdim void EnableErrorStringInPacket(); 344321369Sdim 345314564Sdim bool GetQXferLibrariesReadSupported(); 346262528Semaste 347314564Sdim bool GetQXferLibrariesSVR4ReadSupported(); 348288943Sdim 349314564Sdim uint64_t GetRemoteMaxPacketSize(); 350262528Semaste 351314564Sdim bool GetEchoSupported(); 352288943Sdim 353321369Sdim bool GetQPassSignalsSupported(); 354321369Sdim 355314564Sdim bool GetAugmentedLibrariesSVR4ReadSupported(); 356254721Semaste 357314564Sdim bool GetQXferFeaturesReadSupported(); 358258054Semaste 359314564Sdim LazyBool SupportsAllocDeallocMemory() // const 360314564Sdim { 361314564Sdim // Uncomment this to have lldb pretend the debug server doesn't respond to 362314564Sdim // alloc/dealloc memory packets. 363314564Sdim // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; 364314564Sdim return m_supports_alloc_dealloc_memory; 365314564Sdim } 366258884Semaste 367314564Sdim size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids, 368314564Sdim bool &sequence_mutex_unavailable); 369258884Semaste 370314564Sdim lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, 371321369Sdim mode_t mode, Status &error); 372288943Sdim 373321369Sdim bool CloseFile(lldb::user_id_t fd, Status &error); 374288943Sdim 375314564Sdim lldb::user_id_t GetFileSize(const FileSpec &file_spec); 376258054Semaste 377321369Sdim Status GetFilePermissions(const FileSpec &file_spec, 378321369Sdim uint32_t &file_permissions); 379258884Semaste 380321369Sdim Status SetFilePermissions(const FileSpec &file_spec, 381321369Sdim uint32_t file_permissions); 382258884Semaste 383314564Sdim uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, 384321369Sdim uint64_t dst_len, Status &error); 385276479Sdim 386314564Sdim uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, 387321369Sdim uint64_t src_len, Status &error); 388276479Sdim 389321369Sdim Status CreateSymlink(const FileSpec &src, const FileSpec &dst); 390276479Sdim 391321369Sdim Status Unlink(const FileSpec &file_spec); 392288943Sdim 393321369Sdim Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); 394276479Sdim 395314564Sdim bool GetFileExists(const FileSpec &file_spec); 396288943Sdim 397321369Sdim Status RunShellCommand( 398314564Sdim const char *command, // Shouldn't be nullptr 399314564Sdim const FileSpec &working_dir, // Pass empty FileSpec to use the current 400314564Sdim // working directory 401314564Sdim int *status_ptr, // Pass nullptr if you don't want the process exit status 402314564Sdim int *signo_ptr, // Pass nullptr if you don't want the signal that caused 403314564Sdim // the process to exit 404314564Sdim std::string 405314564Sdim *command_output, // Pass nullptr if you don't want the command output 406314564Sdim uint32_t timeout_sec); // Timeout in seconds to wait for shell program to 407314564Sdim // finish 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; 549314564Sdim LazyBool m_supports_augmented_libraries_svr4_read; 550314564Sdim LazyBool m_supports_jThreadExtendedInfo; 551314564Sdim LazyBool m_supports_jLoadedDynamicLibrariesInfos; 552314564Sdim LazyBool m_supports_jGetSharedCacheInfo; 553321369Sdim LazyBool m_supports_QPassSignals; 554321369Sdim LazyBool m_supports_error_string_reply; 555262528Semaste 556314564Sdim bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1, 557314564Sdim m_supports_qUserName : 1, m_supports_qGroupName : 1, 558314564Sdim m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1, 559314564Sdim m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1, 560314564Sdim m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1, 561314564Sdim m_supports_qSymbol : 1, m_qSymbol_requests_done : 1, 562314564Sdim m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1, 563314564Sdim m_supports_jModulesInfo : 1; 564254721Semaste 565314564Sdim lldb::pid_t m_curr_pid; 566314564Sdim lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all 567314564Sdim // other operations 568314564Sdim lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for 569314564Sdim // continue, step, etc 570254721Semaste 571314564Sdim uint32_t m_num_supported_hardware_watchpoints; 572288943Sdim 573314564Sdim ArchSpec m_host_arch; 574314564Sdim ArchSpec m_process_arch; 575314564Sdim uint32_t m_os_version_major; 576314564Sdim uint32_t m_os_version_minor; 577314564Sdim uint32_t m_os_version_update; 578314564Sdim std::string m_os_build; 579314564Sdim std::string m_os_kernel; 580314564Sdim std::string m_hostname; 581314564Sdim std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if 582314564Sdim // qGDBServerVersion is not supported 583314564Sdim uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if 584314564Sdim // qGDBServerVersion is not supported 585314564Sdim std::chrono::seconds m_default_packet_timeout; 586314564Sdim uint64_t m_max_packet_size; // as returned by qSupported 587314564Sdim std::string m_qSupported_response; // the complete response to qSupported 588296417Sdim 589314564Sdim bool m_supported_async_json_packets_is_valid; 590314564Sdim lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp; 591296417Sdim 592314564Sdim bool GetCurrentProcessInfo(bool allow_lazy_pid = true); 593296417Sdim 594314564Sdim bool GetGDBServerVersion(); 595296417Sdim 596314564Sdim // Given the list of compression types that the remote debug stub can support, 597314564Sdim // possibly enable compression if we find an encoding we can handle. 598314564Sdim void MaybeEnableCompression(std::vector<std::string> supported_compressions); 599296417Sdim 600314564Sdim bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response, 601314564Sdim ProcessInstanceInfo &process_info); 602314564Sdim 603314564Sdim void OnRunPacketSent(bool first) override; 604314564Sdim 605314564Sdim PacketResult SendThreadSpecificPacketAndWaitForResponse( 606314564Sdim lldb::tid_t tid, StreamString &&payload, 607314564Sdim StringExtractorGDBRemote &response, bool send_async); 608314564Sdim 609321369Sdim Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid, 610321369Sdim lldb::tid_t thread_id, 611321369Sdim llvm::MutableArrayRef<uint8_t> &buffer, 612321369Sdim size_t offset); 613321369Sdim 614254721Semasteprivate: 615314564Sdim DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationClient); 616254721Semaste}; 617254721Semaste 618288943Sdim} // namespace process_gdb_remote 619288943Sdim} // namespace lldb_private 620288943Sdim 621296417Sdim#endif // liblldb_GDBRemoteCommunicationClient_h_ 622