GDBRemoteCommunicationClient.h revision 288943
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
13254721Semaste// C Includes
14254721Semaste// C++ Includes
15254721Semaste#include <vector>
16254721Semaste
17254721Semaste// Other libraries and framework includes
18254721Semaste// Project includes
19254721Semaste#include "lldb/Core/ArchSpec.h"
20288943Sdim#include "lldb/Core/StructuredData.h"
21254721Semaste#include "lldb/Target/Process.h"
22254721Semaste
23254721Semaste#include "GDBRemoteCommunication.h"
24254721Semaste
25288943Sdimnamespace lldb_private {
26288943Sdimnamespace process_gdb_remote {
27254721Semaste
28254721Semasteclass GDBRemoteCommunicationClient : public GDBRemoteCommunication
29254721Semaste{
30254721Semastepublic:
31254721Semaste    //------------------------------------------------------------------
32254721Semaste    // Constructors and Destructors
33254721Semaste    //------------------------------------------------------------------
34288943Sdim    GDBRemoteCommunicationClient();
35254721Semaste
36254721Semaste    ~GDBRemoteCommunicationClient();
37254721Semaste
38254721Semaste    //------------------------------------------------------------------
39254721Semaste    // After connecting, send the handshake to the server to make sure
40254721Semaste    // we are communicating with it.
41254721Semaste    //------------------------------------------------------------------
42254721Semaste    bool
43288943Sdim    HandshakeWithServer (Error *error_ptr);
44254721Semaste
45262528Semaste    PacketResult
46254721Semaste    SendPacketAndWaitForResponse (const char *send_payload,
47254721Semaste                                  StringExtractorGDBRemote &response,
48254721Semaste                                  bool send_async);
49254721Semaste
50262528Semaste    PacketResult
51254721Semaste    SendPacketAndWaitForResponse (const char *send_payload,
52254721Semaste                                  size_t send_length,
53254721Semaste                                  StringExtractorGDBRemote &response,
54254721Semaste                                  bool send_async);
55254721Semaste
56262528Semaste    // For packets which specify a range of output to be returned,
57262528Semaste    // return all of the output via a series of request packets of the form
58262528Semaste    // <prefix>0,<size>
59262528Semaste    // <prefix><size>,<size>
60262528Semaste    // <prefix><size>*2,<size>
61262528Semaste    // <prefix><size>*3,<size>
62262528Semaste    // ...
63262528Semaste    // until a "$l..." packet is received, indicating the end.
64262528Semaste    // (size is in hex; this format is used by a standard gdbserver to
65262528Semaste    // return the given portion of the output specified by <prefix>;
66262528Semaste    // for example, "qXfer:libraries-svr4:read::fff,1000" means
67262528Semaste    // "return a chunk of the xml description file for shared
68262528Semaste    // library load addresses, where the chunk starts at offset 0xfff
69262528Semaste    // and continues for 0x1000 bytes").
70262528Semaste    // Concatenate the resulting server response packets together and
71262528Semaste    // return in response_string.  If any packet fails, the return value
72262528Semaste    // indicates that failure and the returned string value is undefined.
73262528Semaste    PacketResult
74262528Semaste    SendPacketsAndConcatenateResponses (const char *send_payload_prefix,
75262528Semaste                                        std::string &response_string);
76262528Semaste
77254721Semaste    lldb::StateType
78254721Semaste    SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process,
79254721Semaste                                          const char *packet_payload,
80254721Semaste                                          size_t packet_length,
81254721Semaste                                          StringExtractorGDBRemote &response);
82288943Sdim    bool
83288943Sdim    SendvContPacket (ProcessGDBRemote *process,
84288943Sdim                     const char *payload,
85288943Sdim                     size_t packet_length,
86288943Sdim                     StringExtractorGDBRemote &response);
87254721Semaste
88258884Semaste    bool
89288943Sdim    GetThreadSuffixSupported () override;
90254721Semaste
91258884Semaste    // This packet is usually sent first and the boolean return value
92258884Semaste    // indicates if the packet was send and any response was received
93258884Semaste    // even in the response is UNIMPLEMENTED. If the packet failed to
94258884Semaste    // get a response, then false is returned. This quickly tells us
95276479Sdim    // if we were able to connect and communicate with the remote GDB
96258884Semaste    // server
97258884Semaste    bool
98254721Semaste    QueryNoAckModeSupported ();
99254721Semaste
100254721Semaste    void
101254721Semaste    GetListThreadsInStopReplySupported ();
102254721Semaste
103254721Semaste    bool
104254721Semaste    SendAsyncSignal (int signo);
105254721Semaste
106254721Semaste    bool
107288943Sdim    SendInterrupt (Mutex::Locker &locker,
108254721Semaste                   uint32_t seconds_to_wait_for_stop,
109254721Semaste                   bool &timed_out);
110254721Semaste
111254721Semaste    lldb::pid_t
112288943Sdim    GetCurrentProcessID (bool allow_lazy = true);
113254721Semaste
114254721Semaste    bool
115254721Semaste    GetLaunchSuccess (std::string &error_str);
116254721Semaste
117254721Semaste    uint16_t
118262528Semaste    LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname);
119258054Semaste
120258054Semaste    bool
121258054Semaste    KillSpawnedProcess (lldb::pid_t pid);
122254721Semaste
123254721Semaste    //------------------------------------------------------------------
124254721Semaste    /// Sends a GDB remote protocol 'A' packet that delivers program
125254721Semaste    /// arguments to the remote server.
126254721Semaste    ///
127254721Semaste    /// @param[in] argv
128254721Semaste    ///     A NULL terminated array of const C strings to use as the
129254721Semaste    ///     arguments.
130254721Semaste    ///
131254721Semaste    /// @return
132254721Semaste    ///     Zero if the response was "OK", a positive value if the
133254721Semaste    ///     the response was "Exx" where xx are two hex digits, or
134254721Semaste    ///     -1 if the call is unsupported or any other unexpected
135254721Semaste    ///     response was received.
136254721Semaste    //------------------------------------------------------------------
137254721Semaste    int
138288943Sdim    SendArgumentsPacket (const ProcessLaunchInfo &launch_info);
139254721Semaste
140254721Semaste    //------------------------------------------------------------------
141254721Semaste    /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
142254721Semaste    /// environment that will get used when launching an application
143254721Semaste    /// in conjunction with the 'A' packet. This function can be called
144254721Semaste    /// multiple times in a row in order to pass on the desired
145254721Semaste    /// environment that the inferior should be launched with.
146254721Semaste    ///
147254721Semaste    /// @param[in] name_equal_value
148254721Semaste    ///     A NULL terminated C string that contains a single environment
149254721Semaste    ///     in the format "NAME=VALUE".
150254721Semaste    ///
151254721Semaste    /// @return
152254721Semaste    ///     Zero if the response was "OK", a positive value if the
153254721Semaste    ///     the response was "Exx" where xx are two hex digits, or
154254721Semaste    ///     -1 if the call is unsupported or any other unexpected
155254721Semaste    ///     response was received.
156254721Semaste    //------------------------------------------------------------------
157254721Semaste    int
158254721Semaste    SendEnvironmentPacket (char const *name_equal_value);
159254721Semaste
160254721Semaste    int
161254721Semaste    SendLaunchArchPacket (const char *arch);
162276479Sdim
163276479Sdim    int
164276479Sdim    SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL);
165276479Sdim
166254721Semaste    //------------------------------------------------------------------
167254721Semaste    /// Sends a "vAttach:PID" where PID is in hex.
168254721Semaste    ///
169254721Semaste    /// @param[in] pid
170254721Semaste    ///     A process ID for the remote gdb server to attach to.
171254721Semaste    ///
172254721Semaste    /// @param[out] response
173254721Semaste    ///     The response received from the gdb server. If the return
174254721Semaste    ///     value is zero, \a response will contain a stop reply
175254721Semaste    ///     packet.
176254721Semaste    ///
177254721Semaste    /// @return
178254721Semaste    ///     Zero if the attach was successful, or an error indicating
179254721Semaste    ///     an error code.
180254721Semaste    //------------------------------------------------------------------
181254721Semaste    int
182254721Semaste    SendAttach (lldb::pid_t pid,
183254721Semaste                StringExtractorGDBRemote& response);
184254721Semaste
185254721Semaste
186254721Semaste    //------------------------------------------------------------------
187288943Sdim    /// Sends a GDB remote protocol 'I' packet that delivers stdin
188288943Sdim    /// data to the remote process.
189288943Sdim    ///
190288943Sdim    /// @param[in] data
191288943Sdim    ///     A pointer to stdin data.
192288943Sdim    ///
193288943Sdim    /// @param[in] data_len
194288943Sdim    ///     The number of bytes available at \a data.
195288943Sdim    ///
196288943Sdim    /// @return
197288943Sdim    ///     Zero if the attach was successful, or an error indicating
198288943Sdim    ///     an error code.
199288943Sdim    //------------------------------------------------------------------
200288943Sdim    int
201288943Sdim    SendStdinNotification(const char* data, size_t data_len);
202288943Sdim
203288943Sdim    //------------------------------------------------------------------
204254721Semaste    /// Sets the path to use for stdin/out/err for a process
205254721Semaste    /// that will be launched with the 'A' packet.
206254721Semaste    ///
207254721Semaste    /// @param[in] path
208254721Semaste    ///     The path to use for stdin/out/err
209254721Semaste    ///
210254721Semaste    /// @return
211254721Semaste    ///     Zero if the for success, or an error code for failure.
212254721Semaste    //------------------------------------------------------------------
213254721Semaste    int
214288943Sdim    SetSTDIN(const FileSpec &file_spec);
215254721Semaste    int
216288943Sdim    SetSTDOUT(const FileSpec &file_spec);
217254721Semaste    int
218288943Sdim    SetSTDERR(const FileSpec &file_spec);
219254721Semaste
220254721Semaste    //------------------------------------------------------------------
221254721Semaste    /// Sets the disable ASLR flag to \a enable for a process that will
222254721Semaste    /// be launched with the 'A' packet.
223254721Semaste    ///
224254721Semaste    /// @param[in] enable
225276479Sdim    ///     A boolean value indicating whether to disable ASLR or not.
226254721Semaste    ///
227254721Semaste    /// @return
228254721Semaste    ///     Zero if the for success, or an error code for failure.
229254721Semaste    //------------------------------------------------------------------
230254721Semaste    int
231254721Semaste    SetDisableASLR (bool enable);
232276479Sdim
233276479Sdim    //------------------------------------------------------------------
234276479Sdim    /// Sets the DetachOnError flag to \a enable for the process controlled by the stub.
235276479Sdim    ///
236276479Sdim    /// @param[in] enable
237276479Sdim    ///     A boolean value indicating whether to detach on error or not.
238276479Sdim    ///
239276479Sdim    /// @return
240276479Sdim    ///     Zero if the for success, or an error code for failure.
241276479Sdim    //------------------------------------------------------------------
242276479Sdim    int
243276479Sdim    SetDetachOnError (bool enable);
244254721Semaste
245254721Semaste    //------------------------------------------------------------------
246254721Semaste    /// Sets the working directory to \a path for a process that will
247258884Semaste    /// be launched with the 'A' packet for non platform based
248258884Semaste    /// connections. If this packet is sent to a GDB server that
249258884Semaste    /// implements the platform, it will change the current working
250258884Semaste    /// directory for the platform process.
251254721Semaste    ///
252288943Sdim    /// @param[in] working_dir
253276479Sdim    ///     The path to a directory to use when launching our process
254254721Semaste    ///
255254721Semaste    /// @return
256254721Semaste    ///     Zero if the for success, or an error code for failure.
257254721Semaste    //------------------------------------------------------------------
258254721Semaste    int
259288943Sdim    SetWorkingDir(const FileSpec &working_dir);
260254721Semaste
261258884Semaste    //------------------------------------------------------------------
262258884Semaste    /// Gets the current working directory of a remote platform GDB
263258884Semaste    /// server.
264258884Semaste    ///
265288943Sdim    /// @param[out] working_dir
266258884Semaste    ///     The current working directory on the remote platform.
267258884Semaste    ///
268258884Semaste    /// @return
269258884Semaste    ///     Boolean for success
270258884Semaste    //------------------------------------------------------------------
271258884Semaste    bool
272288943Sdim    GetWorkingDir(FileSpec &working_dir);
273258884Semaste
274254721Semaste    lldb::addr_t
275254721Semaste    AllocateMemory (size_t size, uint32_t permissions);
276254721Semaste
277254721Semaste    bool
278254721Semaste    DeallocateMemory (lldb::addr_t addr);
279254721Semaste
280288943Sdim    Error
281254721Semaste    Detach (bool keep_stopped);
282254721Semaste
283288943Sdim    Error
284288943Sdim    GetMemoryRegionInfo (lldb::addr_t addr, MemoryRegionInfo &range_info);
285254721Semaste
286288943Sdim    Error
287254721Semaste    GetWatchpointSupportInfo (uint32_t &num);
288254721Semaste
289288943Sdim    Error
290288943Sdim    GetWatchpointSupportInfo (uint32_t &num, bool& after, const ArchSpec &arch);
291254721Semaste
292288943Sdim    Error
293288943Sdim    GetWatchpointsTriggerAfterInstruction (bool &after, const ArchSpec &arch);
294254721Semaste
295288943Sdim    const ArchSpec &
296254721Semaste    GetHostArchitecture ();
297258054Semaste
298258054Semaste    uint32_t
299258054Semaste    GetHostDefaultPacketTimeout();
300254721Semaste
301288943Sdim    const ArchSpec &
302254721Semaste    GetProcessArchitecture ();
303254721Semaste
304262528Semaste    void
305262528Semaste    GetRemoteQSupported();
306262528Semaste
307254721Semaste    bool
308254721Semaste    GetVContSupported (char flavor);
309254721Semaste
310254721Semaste    bool
311258054Semaste    GetpPacketSupported (lldb::tid_t tid);
312258054Semaste
313258054Semaste    bool
314276479Sdim    GetxPacketSupported ();
315276479Sdim
316276479Sdim    bool
317254721Semaste    GetVAttachOrWaitSupported ();
318254721Semaste
319254721Semaste    bool
320254721Semaste    GetSyncThreadStateSupported();
321254721Semaste
322254721Semaste    void
323288943Sdim    ResetDiscoverableSettings (bool did_exec);
324254721Semaste
325254721Semaste    bool
326254721Semaste    GetHostInfo (bool force = false);
327288943Sdim
328288943Sdim    bool
329288943Sdim    GetDefaultThreadId (lldb::tid_t &tid);
330254721Semaste
331254721Semaste    bool
332254721Semaste    GetOSVersion (uint32_t &major,
333254721Semaste                  uint32_t &minor,
334254721Semaste                  uint32_t &update);
335254721Semaste
336254721Semaste    bool
337254721Semaste    GetOSBuildString (std::string &s);
338254721Semaste
339254721Semaste    bool
340254721Semaste    GetOSKernelDescription (std::string &s);
341254721Semaste
342288943Sdim    ArchSpec
343254721Semaste    GetSystemArchitecture ();
344254721Semaste
345254721Semaste    bool
346254721Semaste    GetHostname (std::string &s);
347254721Semaste
348254721Semaste    lldb::addr_t
349254721Semaste    GetShlibInfoAddr();
350254721Semaste
351254721Semaste    bool
352254721Semaste    GetSupportsThreadSuffix ();
353254721Semaste
354254721Semaste    bool
355288943Sdim    GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info);
356254721Semaste
357254721Semaste    uint32_t
358288943Sdim    FindProcesses (const ProcessInstanceInfoMatch &process_match_info,
359288943Sdim                   ProcessInstanceInfoList &process_infos);
360254721Semaste
361254721Semaste    bool
362254721Semaste    GetUserName (uint32_t uid, std::string &name);
363254721Semaste
364254721Semaste    bool
365254721Semaste    GetGroupName (uint32_t gid, std::string &name);
366254721Semaste
367254721Semaste    bool
368254721Semaste    HasFullVContSupport ()
369254721Semaste    {
370254721Semaste        return GetVContSupported ('A');
371254721Semaste    }
372254721Semaste
373254721Semaste    bool
374254721Semaste    HasAnyVContSupport ()
375254721Semaste    {
376254721Semaste        return GetVContSupported ('a');
377254721Semaste    }
378254721Semaste
379254721Semaste    bool
380254721Semaste    GetStopReply (StringExtractorGDBRemote &response);
381254721Semaste
382254721Semaste    bool
383254721Semaste    GetThreadStopInfo (lldb::tid_t tid,
384254721Semaste                       StringExtractorGDBRemote &response);
385254721Semaste
386254721Semaste    bool
387254721Semaste    SupportsGDBStoppointPacket (GDBStoppointType type)
388254721Semaste    {
389254721Semaste        switch (type)
390254721Semaste        {
391254721Semaste        case eBreakpointSoftware:   return m_supports_z0;
392254721Semaste        case eBreakpointHardware:   return m_supports_z1;
393254721Semaste        case eWatchpointWrite:      return m_supports_z2;
394254721Semaste        case eWatchpointRead:       return m_supports_z3;
395254721Semaste        case eWatchpointReadWrite:  return m_supports_z4;
396288943Sdim        default:                    return false;
397254721Semaste        }
398254721Semaste    }
399254721Semaste    uint8_t
400254721Semaste    SendGDBStoppointTypePacket (GDBStoppointType type,   // Type of breakpoint or watchpoint
401254721Semaste                                bool insert,              // Insert or remove?
402254721Semaste                                lldb::addr_t addr,        // Address of breakpoint or watchpoint
403254721Semaste                                uint32_t length);         // Byte Size of breakpoint or watchpoint
404254721Semaste
405288943Sdim    bool
406288943Sdim    SetNonStopMode (const bool enable);
407288943Sdim
408254721Semaste    void
409288943Sdim    TestPacketSpeed (const uint32_t num_packets, uint32_t max_send, uint32_t max_recv, bool json, Stream &strm);
410254721Semaste
411254721Semaste    // This packet is for testing the speed of the interface only. Both
412254721Semaste    // the client and server need to support it, but this allows us to
413254721Semaste    // measure the packet speed without any other work being done on the
414254721Semaste    // other end and avoids any of that work affecting the packet send
415254721Semaste    // and response times.
416254721Semaste    bool
417254721Semaste    SendSpeedTestPacket (uint32_t send_size,
418254721Semaste                         uint32_t recv_size);
419254721Semaste
420254721Semaste    bool
421254721Semaste    SetCurrentThread (uint64_t tid);
422254721Semaste
423254721Semaste    bool
424254721Semaste    SetCurrentThreadForRun (uint64_t tid);
425254721Semaste
426262528Semaste    bool
427276479Sdim    GetQXferAuxvReadSupported ();
428276479Sdim
429276479Sdim    bool
430262528Semaste    GetQXferLibrariesReadSupported ();
431262528Semaste
432262528Semaste    bool
433262528Semaste    GetQXferLibrariesSVR4ReadSupported ();
434262528Semaste
435262528Semaste    uint64_t
436262528Semaste    GetRemoteMaxPacketSize();
437262528Semaste
438262528Semaste    bool
439288943Sdim    GetEchoSupported ();
440288943Sdim
441288943Sdim    bool
442262528Semaste    GetAugmentedLibrariesSVR4ReadSupported ();
443262528Semaste
444288943Sdim    bool
445288943Sdim    GetQXferFeaturesReadSupported ();
446288943Sdim
447288943Sdim    LazyBool
448254721Semaste    SupportsAllocDeallocMemory () // const
449254721Semaste    {
450254721Semaste        // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets.
451254721Semaste        // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;
452254721Semaste        return m_supports_alloc_dealloc_memory;
453254721Semaste    }
454254721Semaste
455254721Semaste    size_t
456254721Semaste    GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids,
457254721Semaste                         bool &sequence_mutex_unavailable);
458254721Semaste
459254721Semaste    bool
460254721Semaste    GetInterruptWasSent () const
461254721Semaste    {
462254721Semaste        return m_interrupt_sent;
463254721Semaste    }
464254721Semaste
465258884Semaste    lldb::user_id_t
466288943Sdim    OpenFile (const FileSpec& file_spec, uint32_t flags, mode_t mode, Error &error);
467258054Semaste
468258884Semaste    bool
469288943Sdim    CloseFile (lldb::user_id_t fd, Error &error);
470258054Semaste
471258884Semaste    lldb::user_id_t
472288943Sdim    GetFileSize (const FileSpec& file_spec);
473258054Semaste
474288943Sdim    Error
475288943Sdim    GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions);
476258054Semaste
477288943Sdim    Error
478288943Sdim    SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions);
479258884Semaste
480258884Semaste    uint64_t
481258054Semaste    ReadFile (lldb::user_id_t fd,
482258054Semaste              uint64_t offset,
483258054Semaste              void *dst,
484258054Semaste              uint64_t dst_len,
485288943Sdim              Error &error);
486258054Semaste
487258884Semaste    uint64_t
488258054Semaste    WriteFile (lldb::user_id_t fd,
489258054Semaste               uint64_t offset,
490258054Semaste               const void* src,
491258054Semaste               uint64_t src_len,
492288943Sdim               Error &error);
493258054Semaste
494288943Sdim    Error
495288943Sdim    CreateSymlink(const FileSpec &src,
496288943Sdim                  const FileSpec &dst);
497258054Semaste
498288943Sdim    Error
499288943Sdim    Unlink(const FileSpec &file_spec);
500258884Semaste
501288943Sdim    Error
502288943Sdim    MakeDirectory(const FileSpec &file_spec, uint32_t mode);
503288943Sdim
504258884Semaste    bool
505288943Sdim    GetFileExists (const FileSpec& file_spec);
506258054Semaste
507288943Sdim    Error
508288943Sdim    RunShellCommand(const char *command,           // Shouldn't be NULL
509288943Sdim                    const FileSpec &working_dir,   // Pass empty FileSpec to use the current working directory
510288943Sdim                    int *status_ptr,               // Pass NULL if you don't want the process exit status
511288943Sdim                    int *signo_ptr,                // Pass NULL if you don't want the signal that caused the process to exit
512288943Sdim                    std::string *command_output,   // Pass NULL if you don't want the command output
513288943Sdim                    uint32_t timeout_sec);         // Timeout in seconds to wait for shell program to finish
514288943Sdim
515258884Semaste    bool
516288943Sdim    CalculateMD5 (const FileSpec& file_spec, uint64_t &high, uint64_t &low);
517258054Semaste
518254721Semaste    std::string
519254721Semaste    HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process,
520254721Semaste                                      StringExtractorGDBRemote &inputStringExtractor);
521258054Semaste
522258884Semaste    bool
523258884Semaste    ReadRegister(lldb::tid_t tid,
524258884Semaste                 uint32_t reg_num,
525258884Semaste                 StringExtractorGDBRemote &response);
526258884Semaste
527258884Semaste    bool
528258884Semaste    ReadAllRegisters (lldb::tid_t tid,
529258884Semaste                      StringExtractorGDBRemote &response);
530258884Semaste
531258884Semaste    bool
532258884Semaste    SaveRegisterState (lldb::tid_t tid, uint32_t &save_id);
533258884Semaste
534258884Semaste    bool
535258884Semaste    RestoreRegisterState (lldb::tid_t tid, uint32_t save_id);
536276479Sdim
537276479Sdim    const char *
538276479Sdim    GetGDBServerProgramName();
539258884Semaste
540276479Sdim    uint32_t
541276479Sdim    GetGDBServerProgramVersion();
542276479Sdim
543276479Sdim    bool
544276479Sdim    AvoidGPackets(ProcessGDBRemote *process);
545276479Sdim
546288943Sdim    StructuredData::ObjectSP
547288943Sdim    GetThreadsInfo();
548288943Sdim
549276479Sdim    bool
550276479Sdim    GetThreadExtendedInfoSupported();
551276479Sdim
552288943Sdim    bool
553288943Sdim    GetLoadedDynamicLibrariesInfosSupported();
554288943Sdim
555288943Sdim    bool
556288943Sdim    GetModuleInfo (const FileSpec& module_file_spec,
557288943Sdim                   const ArchSpec& arch_spec,
558288943Sdim                   ModuleSpec &module_spec);
559288943Sdim
560288943Sdim    bool
561288943Sdim    ReadExtFeature (const lldb_private::ConstString object,
562288943Sdim                    const lldb_private::ConstString annex,
563288943Sdim                    std::string & out,
564288943Sdim                    lldb_private::Error & err);
565288943Sdim
566288943Sdim    void
567288943Sdim    ServeSymbolLookups(lldb_private::Process *process);
568288943Sdim
569254721Semasteprotected:
570254721Semaste
571262528Semaste    PacketResult
572262528Semaste    SendPacketAndWaitForResponseNoLock (const char *payload,
573262528Semaste                                        size_t payload_length,
574262528Semaste                                        StringExtractorGDBRemote &response);
575262528Semaste
576254721Semaste    bool
577288943Sdim    GetCurrentProcessInfo (bool allow_lazy_pid = true);
578254721Semaste
579276479Sdim    bool
580276479Sdim    GetGDBServerVersion();
581276479Sdim
582288943Sdim    // Given the list of compression types that the remote debug stub can support,
583288943Sdim    // possibly enable compression if we find an encoding we can handle.
584288943Sdim    void
585288943Sdim    MaybeEnableCompression (std::vector<std::string> supported_compressions);
586288943Sdim
587254721Semaste    //------------------------------------------------------------------
588254721Semaste    // Classes that inherit from GDBRemoteCommunicationClient can see and modify these
589254721Semaste    //------------------------------------------------------------------
590288943Sdim    LazyBool m_supports_not_sending_acks;
591288943Sdim    LazyBool m_supports_thread_suffix;
592288943Sdim    LazyBool m_supports_threads_in_stop_reply;
593288943Sdim    LazyBool m_supports_vCont_all;
594288943Sdim    LazyBool m_supports_vCont_any;
595288943Sdim    LazyBool m_supports_vCont_c;
596288943Sdim    LazyBool m_supports_vCont_C;
597288943Sdim    LazyBool m_supports_vCont_s;
598288943Sdim    LazyBool m_supports_vCont_S;
599288943Sdim    LazyBool m_qHostInfo_is_valid;
600288943Sdim    LazyBool m_curr_pid_is_valid;
601288943Sdim    LazyBool m_qProcessInfo_is_valid;
602288943Sdim    LazyBool m_qGDBServerVersion_is_valid;
603288943Sdim    LazyBool m_supports_alloc_dealloc_memory;
604288943Sdim    LazyBool m_supports_memory_region_info;
605288943Sdim    LazyBool m_supports_watchpoint_support_info;
606288943Sdim    LazyBool m_supports_detach_stay_stopped;
607288943Sdim    LazyBool m_watchpoints_trigger_after_instruction;
608288943Sdim    LazyBool m_attach_or_wait_reply;
609288943Sdim    LazyBool m_prepare_for_reg_writing_reply;
610288943Sdim    LazyBool m_supports_p;
611288943Sdim    LazyBool m_supports_x;
612288943Sdim    LazyBool m_avoid_g_packets;
613288943Sdim    LazyBool m_supports_QSaveRegisterState;
614288943Sdim    LazyBool m_supports_qXfer_auxv_read;
615288943Sdim    LazyBool m_supports_qXfer_libraries_read;
616288943Sdim    LazyBool m_supports_qXfer_libraries_svr4_read;
617288943Sdim    LazyBool m_supports_qXfer_features_read;
618288943Sdim    LazyBool m_supports_augmented_libraries_svr4_read;
619288943Sdim    LazyBool m_supports_jThreadExtendedInfo;
620288943Sdim    LazyBool m_supports_jLoadedDynamicLibrariesInfos;
621262528Semaste
622254721Semaste    bool
623254721Semaste        m_supports_qProcessInfoPID:1,
624254721Semaste        m_supports_qfProcessInfo:1,
625254721Semaste        m_supports_qUserName:1,
626254721Semaste        m_supports_qGroupName:1,
627254721Semaste        m_supports_qThreadStopInfo:1,
628254721Semaste        m_supports_z0:1,
629254721Semaste        m_supports_z1:1,
630254721Semaste        m_supports_z2:1,
631254721Semaste        m_supports_z3:1,
632258054Semaste        m_supports_z4:1,
633258054Semaste        m_supports_QEnvironment:1,
634288943Sdim        m_supports_QEnvironmentHexEncoded:1,
635288943Sdim        m_supports_qSymbol:1,
636288943Sdim        m_supports_jThreadsInfo:1;
637254721Semaste
638276479Sdim    lldb::pid_t m_curr_pid;
639254721Semaste    lldb::tid_t m_curr_tid;         // Current gdb remote protocol thread index for all other operations
640254721Semaste    lldb::tid_t m_curr_tid_run;     // Current gdb remote protocol thread index for continue, step, etc
641254721Semaste
642254721Semaste
643254721Semaste    uint32_t m_num_supported_hardware_watchpoints;
644254721Semaste
645254721Semaste    // If we need to send a packet while the target is running, the m_async_XXX
646254721Semaste    // member variables take care of making this happen.
647288943Sdim    Mutex m_async_mutex;
648288943Sdim    Predicate<bool> m_async_packet_predicate;
649254721Semaste    std::string m_async_packet;
650262528Semaste    PacketResult m_async_result;
651254721Semaste    StringExtractorGDBRemote m_async_response;
652254721Semaste    int m_async_signal; // We were asked to deliver a signal to the inferior process.
653254721Semaste    bool m_interrupt_sent;
654254721Semaste    std::string m_partial_profile_data;
655254721Semaste    std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
656254721Semaste
657288943Sdim    ArchSpec m_host_arch;
658288943Sdim    ArchSpec m_process_arch;
659254721Semaste    uint32_t m_os_version_major;
660254721Semaste    uint32_t m_os_version_minor;
661254721Semaste    uint32_t m_os_version_update;
662254721Semaste    std::string m_os_build;
663254721Semaste    std::string m_os_kernel;
664254721Semaste    std::string m_hostname;
665276479Sdim    std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if qGDBServerVersion is not supported
666276479Sdim    uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if qGDBServerVersion is not supported
667258054Semaste    uint32_t m_default_packet_timeout;
668262528Semaste    uint64_t m_max_packet_size;  // as returned by qSupported
669288943Sdim
670254721Semaste
671254721Semaste    bool
672254721Semaste    DecodeProcessInfoResponse (StringExtractorGDBRemote &response,
673288943Sdim                               ProcessInstanceInfo &process_info);
674254721Semasteprivate:
675254721Semaste    //------------------------------------------------------------------
676254721Semaste    // For GDBRemoteCommunicationClient only
677254721Semaste    //------------------------------------------------------------------
678254721Semaste    DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
679254721Semaste};
680254721Semaste
681288943Sdim} // namespace process_gdb_remote
682288943Sdim} // namespace lldb_private
683288943Sdim
684254721Semaste#endif  // liblldb_GDBRemoteCommunicationClient_h_
685