blob: 10072730e746217256c7d6e1fe16cecf67365446 [file] [log] [blame]
Greg Clayton576d8832011-03-22 04:00:09 +00001//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_GDBRemoteCommunicationClient_h_
11#define liblldb_GDBRemoteCommunicationClient_h_
12
13// C Includes
14// C++ Includes
Greg Claytonadc00cb2011-05-20 23:38:13 +000015#include <vector>
16
Greg Clayton576d8832011-03-22 04:00:09 +000017// Other libraries and framework includes
18// Project includes
19#include "lldb/Core/ArchSpec.h"
Greg Clayton46fb5582011-11-18 07:03:08 +000020#include "lldb/Target/Process.h"
Greg Clayton576d8832011-03-22 04:00:09 +000021
22#include "GDBRemoteCommunication.h"
23
Tamas Berghammerdb264a62015-03-31 09:52:22 +000024namespace lldb_private {
25namespace process_gdb_remote {
26
Greg Clayton576d8832011-03-22 04:00:09 +000027class GDBRemoteCommunicationClient : public GDBRemoteCommunication
28{
29public:
30 //------------------------------------------------------------------
31 // Constructors and Destructors
32 //------------------------------------------------------------------
Tamas Berghammere13c2732015-02-11 10:29:30 +000033 GDBRemoteCommunicationClient();
Greg Clayton576d8832011-03-22 04:00:09 +000034
Greg Clayton576d8832011-03-22 04:00:09 +000035 ~GDBRemoteCommunicationClient();
36
Greg Clayton1cb64962011-03-24 04:28:38 +000037 //------------------------------------------------------------------
38 // After connecting, send the handshake to the server to make sure
39 // we are communicating with it.
40 //------------------------------------------------------------------
41 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +000042 HandshakeWithServer (Error *error_ptr);
Greg Clayton1cb64962011-03-24 04:28:38 +000043
Greg Clayton3dedae12013-12-06 21:45:27 +000044 PacketResult
Greg Clayton576d8832011-03-22 04:00:09 +000045 SendPacketAndWaitForResponse (const char *send_payload,
46 StringExtractorGDBRemote &response,
47 bool send_async);
48
Greg Clayton3dedae12013-12-06 21:45:27 +000049 PacketResult
Greg Clayton576d8832011-03-22 04:00:09 +000050 SendPacketAndWaitForResponse (const char *send_payload,
51 size_t send_length,
52 StringExtractorGDBRemote &response,
53 bool send_async);
54
Steve Pucci5ae54ae2014-01-25 05:46:51 +000055 // For packets which specify a range of output to be returned,
56 // return all of the output via a series of request packets of the form
57 // <prefix>0,<size>
58 // <prefix><size>,<size>
59 // <prefix><size>*2,<size>
60 // <prefix><size>*3,<size>
61 // ...
62 // until a "$l..." packet is received, indicating the end.
63 // (size is in hex; this format is used by a standard gdbserver to
64 // return the given portion of the output specified by <prefix>;
65 // for example, "qXfer:libraries-svr4:read::fff,1000" means
66 // "return a chunk of the xml description file for shared
67 // library load addresses, where the chunk starts at offset 0xfff
68 // and continues for 0x1000 bytes").
69 // Concatenate the resulting server response packets together and
70 // return in response_string. If any packet fails, the return value
71 // indicates that failure and the returned string value is undefined.
72 PacketResult
73 SendPacketsAndConcatenateResponses (const char *send_payload_prefix,
74 std::string &response_string);
75
Greg Clayton576d8832011-03-22 04:00:09 +000076 lldb::StateType
77 SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process,
78 const char *packet_payload,
79 size_t packet_length,
80 StringExtractorGDBRemote &response);
81
Greg Claytonfbb76342013-11-20 21:07:01 +000082 bool
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000083 GetThreadSuffixSupported () override;
Greg Clayton576d8832011-03-22 04:00:09 +000084
Greg Claytonfb909312013-11-23 01:58:15 +000085 // This packet is usually sent first and the boolean return value
86 // indicates if the packet was send and any response was received
87 // even in the response is UNIMPLEMENTED. If the packet failed to
88 // get a response, then false is returned. This quickly tells us
Bruce Mitchenerd93c4a32014-07-01 21:22:11 +000089 // if we were able to connect and communicate with the remote GDB
Greg Claytonfb909312013-11-23 01:58:15 +000090 // server
91 bool
Greg Clayton1cb64962011-03-24 04:28:38 +000092 QueryNoAckModeSupported ();
Greg Clayton576d8832011-03-22 04:00:09 +000093
Greg Clayton44633992012-04-10 03:22:03 +000094 void
95 GetListThreadsInStopReplySupported ();
96
Greg Clayton576d8832011-03-22 04:00:09 +000097 bool
98 SendAsyncSignal (int signo);
99
100 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000101 SendInterrupt (Mutex::Locker &locker,
Greg Clayton576d8832011-03-22 04:00:09 +0000102 uint32_t seconds_to_wait_for_stop,
Greg Clayton576d8832011-03-22 04:00:09 +0000103 bool &timed_out);
104
105 lldb::pid_t
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000106 GetCurrentProcessID (bool allow_lazy = true);
Greg Clayton576d8832011-03-22 04:00:09 +0000107
108 bool
109 GetLaunchSuccess (std::string &error_str);
110
Greg Clayton8b82f082011-04-12 05:54:46 +0000111 uint16_t
Greg Claytondbf04572013-12-04 19:40:33 +0000112 LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000113
114 bool
115 KillSpawnedProcess (lldb::pid_t pid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000116
Greg Clayton576d8832011-03-22 04:00:09 +0000117 //------------------------------------------------------------------
118 /// Sends a GDB remote protocol 'A' packet that delivers program
119 /// arguments to the remote server.
120 ///
121 /// @param[in] argv
122 /// A NULL terminated array of const C strings to use as the
123 /// arguments.
124 ///
125 /// @return
126 /// Zero if the response was "OK", a positive value if the
127 /// the response was "Exx" where xx are two hex digits, or
128 /// -1 if the call is unsupported or any other unexpected
129 /// response was received.
130 //------------------------------------------------------------------
131 int
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000132 SendArgumentsPacket (const ProcessLaunchInfo &launch_info);
Greg Clayton576d8832011-03-22 04:00:09 +0000133
134 //------------------------------------------------------------------
135 /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
136 /// environment that will get used when launching an application
137 /// in conjunction with the 'A' packet. This function can be called
138 /// multiple times in a row in order to pass on the desired
139 /// environment that the inferior should be launched with.
140 ///
141 /// @param[in] name_equal_value
142 /// A NULL terminated C string that contains a single environment
143 /// in the format "NAME=VALUE".
144 ///
145 /// @return
146 /// Zero if the response was "OK", a positive value if the
147 /// the response was "Exx" where xx are two hex digits, or
148 /// -1 if the call is unsupported or any other unexpected
149 /// response was received.
150 //------------------------------------------------------------------
151 int
152 SendEnvironmentPacket (char const *name_equal_value);
153
Greg Claytonc4103b32011-05-08 04:53:50 +0000154 int
155 SendLaunchArchPacket (const char *arch);
Jason Molendaa3329782014-03-29 18:54:20 +0000156
157 int
158 SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL);
159
Greg Clayton576d8832011-03-22 04:00:09 +0000160 //------------------------------------------------------------------
161 /// Sends a "vAttach:PID" where PID is in hex.
162 ///
163 /// @param[in] pid
164 /// A process ID for the remote gdb server to attach to.
165 ///
166 /// @param[out] response
167 /// The response received from the gdb server. If the return
168 /// value is zero, \a response will contain a stop reply
169 /// packet.
170 ///
171 /// @return
172 /// Zero if the attach was successful, or an error indicating
173 /// an error code.
174 //------------------------------------------------------------------
175 int
176 SendAttach (lldb::pid_t pid,
177 StringExtractorGDBRemote& response);
178
179
180 //------------------------------------------------------------------
Vince Harrone0be4252015-02-06 18:32:57 +0000181 /// Sends a GDB remote protocol 'I' packet that delivers stdin
182 /// data to the remote process.
183 ///
184 /// @param[in] data
185 /// A pointer to stdin data.
186 ///
187 /// @param[in] data_len
188 /// The number of bytes available at \a data.
189 ///
190 /// @return
191 /// Zero if the attach was successful, or an error indicating
192 /// an error code.
193 //------------------------------------------------------------------
194 int
195 SendStdinNotification(const char* data, size_t data_len);
196
197 //------------------------------------------------------------------
Greg Clayton576d8832011-03-22 04:00:09 +0000198 /// Sets the path to use for stdin/out/err for a process
199 /// that will be launched with the 'A' packet.
200 ///
201 /// @param[in] path
202 /// The path to use for stdin/out/err
203 ///
204 /// @return
205 /// Zero if the for success, or an error code for failure.
206 //------------------------------------------------------------------
207 int
208 SetSTDIN (char const *path);
209 int
210 SetSTDOUT (char const *path);
211 int
212 SetSTDERR (char const *path);
213
214 //------------------------------------------------------------------
215 /// Sets the disable ASLR flag to \a enable for a process that will
216 /// be launched with the 'A' packet.
217 ///
218 /// @param[in] enable
Jim Ingham106d0282014-06-25 02:32:56 +0000219 /// A boolean value indicating whether to disable ASLR or not.
Greg Clayton576d8832011-03-22 04:00:09 +0000220 ///
221 /// @return
222 /// Zero if the for success, or an error code for failure.
223 //------------------------------------------------------------------
224 int
225 SetDisableASLR (bool enable);
Jim Ingham106d0282014-06-25 02:32:56 +0000226
227 //------------------------------------------------------------------
228 /// Sets the DetachOnError flag to \a enable for the process controlled by the stub.
229 ///
230 /// @param[in] enable
231 /// A boolean value indicating whether to detach on error or not.
232 ///
233 /// @return
234 /// Zero if the for success, or an error code for failure.
235 //------------------------------------------------------------------
236 int
237 SetDetachOnError (bool enable);
Greg Clayton576d8832011-03-22 04:00:09 +0000238
239 //------------------------------------------------------------------
240 /// Sets the working directory to \a path for a process that will
Greg Claytonfbb76342013-11-20 21:07:01 +0000241 /// be launched with the 'A' packet for non platform based
242 /// connections. If this packet is sent to a GDB server that
243 /// implements the platform, it will change the current working
244 /// directory for the platform process.
Greg Clayton576d8832011-03-22 04:00:09 +0000245 ///
246 /// @param[in] path
Bruce Mitchenerd93c4a32014-07-01 21:22:11 +0000247 /// The path to a directory to use when launching our process
Greg Clayton576d8832011-03-22 04:00:09 +0000248 ///
249 /// @return
250 /// Zero if the for success, or an error code for failure.
251 //------------------------------------------------------------------
252 int
253 SetWorkingDir (char const *path);
254
Greg Claytonfbb76342013-11-20 21:07:01 +0000255 //------------------------------------------------------------------
256 /// Gets the current working directory of a remote platform GDB
257 /// server.
258 ///
259 /// @param[out] cwd
260 /// The current working directory on the remote platform.
261 ///
262 /// @return
263 /// Boolean for success
264 //------------------------------------------------------------------
265 bool
266 GetWorkingDir (std::string &cwd);
267
Greg Clayton576d8832011-03-22 04:00:09 +0000268 lldb::addr_t
269 AllocateMemory (size_t size, uint32_t permissions);
270
271 bool
272 DeallocateMemory (lldb::addr_t addr);
273
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000274 Error
Jim Inghamacff8952013-05-02 00:27:30 +0000275 Detach (bool keep_stopped);
Greg Clayton37a0a242012-04-11 00:24:49 +0000276
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000277 Error
278 GetMemoryRegionInfo (lldb::addr_t addr, MemoryRegionInfo &range_info);
Greg Clayton46fb5582011-11-18 07:03:08 +0000279
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000280 Error
Johnny Chen64637202012-05-23 21:09:52 +0000281 GetWatchpointSupportInfo (uint32_t &num);
282
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000283 Error
Enrico Granataf04a2192012-07-13 23:18:48 +0000284 GetWatchpointSupportInfo (uint32_t &num, bool& after);
285
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000286 Error
Enrico Granataf04a2192012-07-13 23:18:48 +0000287 GetWatchpointsTriggerAfterInstruction (bool &after);
288
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000289 const ArchSpec &
Greg Clayton576d8832011-03-22 04:00:09 +0000290 GetHostArchitecture ();
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000291
292 uint32_t
293 GetHostDefaultPacketTimeout();
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000294
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000295 const ArchSpec &
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000296 GetProcessArchitecture ();
297
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000298 void
299 GetRemoteQSupported();
300
Greg Clayton576d8832011-03-22 04:00:09 +0000301 bool
302 GetVContSupported (char flavor);
303
Jim Inghamcd16df92012-07-20 21:37:13 +0000304 bool
Sean Callananb1de1142013-09-04 23:24:15 +0000305 GetpPacketSupported (lldb::tid_t tid);
Hafiz Abid Qadeer9a78cdf2013-08-29 09:09:45 +0000306
307 bool
Jason Molendabdc4f122014-05-06 02:59:39 +0000308 GetxPacketSupported ();
309
310 bool
Jim Inghamcd16df92012-07-20 21:37:13 +0000311 GetVAttachOrWaitSupported ();
312
Jim Ingham279ceec2012-07-25 21:12:43 +0000313 bool
314 GetSyncThreadStateSupported();
315
Greg Clayton576d8832011-03-22 04:00:09 +0000316 void
317 ResetDiscoverableSettings();
318
319 bool
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000320 GetHostInfo (bool force = false);
Greg Clayton576d8832011-03-22 04:00:09 +0000321
322 bool
Greg Clayton1cb64962011-03-24 04:28:38 +0000323 GetOSVersion (uint32_t &major,
324 uint32_t &minor,
325 uint32_t &update);
326
327 bool
328 GetOSBuildString (std::string &s);
329
330 bool
331 GetOSKernelDescription (std::string &s);
332
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000333 ArchSpec
Greg Clayton1cb64962011-03-24 04:28:38 +0000334 GetSystemArchitecture ();
335
336 bool
337 GetHostname (std::string &s);
338
Greg Clayton37a0a242012-04-11 00:24:49 +0000339 lldb::addr_t
340 GetShlibInfoAddr();
341
Greg Clayton1cb64962011-03-24 04:28:38 +0000342 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000343 GetSupportsThreadSuffix ();
344
345 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000346 GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info);
Greg Clayton32e0a752011-03-30 18:16:51 +0000347
348 uint32_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000349 FindProcesses (const ProcessInstanceInfoMatch &process_match_info,
350 ProcessInstanceInfoList &process_infos);
Greg Clayton32e0a752011-03-30 18:16:51 +0000351
352 bool
353 GetUserName (uint32_t uid, std::string &name);
354
355 bool
356 GetGroupName (uint32_t gid, std::string &name);
357
358 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000359 HasFullVContSupport ()
360 {
361 return GetVContSupported ('A');
362 }
363
364 bool
365 HasAnyVContSupport ()
366 {
367 return GetVContSupported ('a');
368 }
369
Greg Clayton8b82f082011-04-12 05:54:46 +0000370 bool
371 GetStopReply (StringExtractorGDBRemote &response);
372
373 bool
Greg Claytonf402f782012-10-13 02:11:55 +0000374 GetThreadStopInfo (lldb::tid_t tid,
Greg Clayton8b82f082011-04-12 05:54:46 +0000375 StringExtractorGDBRemote &response);
376
377 bool
378 SupportsGDBStoppointPacket (GDBStoppointType type)
379 {
380 switch (type)
381 {
382 case eBreakpointSoftware: return m_supports_z0;
383 case eBreakpointHardware: return m_supports_z1;
384 case eWatchpointWrite: return m_supports_z2;
385 case eWatchpointRead: return m_supports_z3;
386 case eWatchpointReadWrite: return m_supports_z4;
Zachary Turner568b0de2015-02-18 18:44:03 +0000387 default: return false;
Greg Clayton8b82f082011-04-12 05:54:46 +0000388 }
Greg Clayton8b82f082011-04-12 05:54:46 +0000389 }
390 uint8_t
391 SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint
392 bool insert, // Insert or remove?
393 lldb::addr_t addr, // Address of breakpoint or watchpoint
394 uint32_t length); // Byte Size of breakpoint or watchpoint
395
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000396 void
397 TestPacketSpeed (const uint32_t num_packets);
398
399 // This packet is for testing the speed of the interface only. Both
400 // the client and server need to support it, but this allows us to
401 // measure the packet speed without any other work being done on the
402 // other end and avoids any of that work affecting the packet send
403 // and response times.
404 bool
405 SendSpeedTestPacket (uint32_t send_size,
406 uint32_t recv_size);
Greg Clayton8b82f082011-04-12 05:54:46 +0000407
408 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000409 SetCurrentThread (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000410
411 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000412 SetCurrentThreadForRun (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000413
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000414 bool
Steve Pucci03904ac2014-03-04 23:18:46 +0000415 GetQXferAuxvReadSupported ();
416
417 bool
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000418 GetQXferLibrariesReadSupported ();
419
420 bool
421 GetQXferLibrariesSVR4ReadSupported ();
422
423 uint64_t
424 GetRemoteMaxPacketSize();
425
426 bool
427 GetAugmentedLibrariesSVR4ReadSupported ();
428
Colin Rileyc3c95b22015-04-16 15:51:33 +0000429 bool
430 GetQXferFeaturesReadSupported ();
431
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000432 LazyBool
Jim Ingham372787f2012-04-07 00:00:41 +0000433 SupportsAllocDeallocMemory () // const
Greg Clayton2a48f522011-05-14 01:50:35 +0000434 {
Jim Ingham372787f2012-04-07 00:00:41 +0000435 // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets.
436 // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;
Greg Clayton70b57652011-05-15 01:25:55 +0000437 return m_supports_alloc_dealloc_memory;
Greg Clayton2a48f522011-05-14 01:50:35 +0000438 }
439
Greg Claytonadc00cb2011-05-20 23:38:13 +0000440 size_t
441 GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids,
442 bool &sequence_mutex_unavailable);
443
Greg Clayton2687cd12012-03-29 01:55:41 +0000444 bool
445 GetInterruptWasSent () const
446 {
447 return m_interrupt_sent;
448 }
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000449
Greg Claytonfbb76342013-11-20 21:07:01 +0000450 lldb::user_id_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000451 OpenFile (const FileSpec& file_spec, uint32_t flags, mode_t mode, Error &error);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000452
Greg Claytonfbb76342013-11-20 21:07:01 +0000453 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000454 CloseFile (lldb::user_id_t fd, Error &error);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000455
Greg Claytonfbb76342013-11-20 21:07:01 +0000456 lldb::user_id_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000457 GetFileSize (const FileSpec& file_spec);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000458
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000459 Error
Greg Claytonfbb76342013-11-20 21:07:01 +0000460 GetFilePermissions(const char *path, uint32_t &file_permissions);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000461
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000462 Error
Greg Claytonfbb76342013-11-20 21:07:01 +0000463 SetFilePermissions(const char *path, uint32_t file_permissions);
464
465 uint64_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000466 ReadFile (lldb::user_id_t fd,
467 uint64_t offset,
468 void *dst,
469 uint64_t dst_len,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000470 Error &error);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000471
Greg Claytonfbb76342013-11-20 21:07:01 +0000472 uint64_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000473 WriteFile (lldb::user_id_t fd,
474 uint64_t offset,
475 const void* src,
476 uint64_t src_len,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000477 Error &error);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000478
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000479 Error
Greg Claytonfbb76342013-11-20 21:07:01 +0000480 CreateSymlink (const char *src,
481 const char *dst);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000482
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000483 Error
Greg Claytonfbb76342013-11-20 21:07:01 +0000484 Unlink (const char *path);
485
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000486 Error
487 MakeDirectory (const char *path, uint32_t mode);
Greg Claytonfbb76342013-11-20 21:07:01 +0000488
489 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000490 GetFileExists (const FileSpec& file_spec);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000491
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000492 Error
Daniel Maleae0f8f572013-08-26 23:57:52 +0000493 RunShellCommand (const char *command, // Shouldn't be NULL
494 const char *working_dir, // Pass NULL to use the current working directory
495 int *status_ptr, // Pass NULL if you don't want the process exit status
496 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
497 std::string *command_output, // Pass NULL if you don't want the command output
498 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
499
Greg Claytonfbb76342013-11-20 21:07:01 +0000500 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000501 CalculateMD5 (const FileSpec& file_spec, uint64_t &high, uint64_t &low);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000502
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000503 std::string
504 HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process,
505 StringExtractorGDBRemote &inputStringExtractor);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000506
Greg Claytonf74cf862013-11-13 23:28:31 +0000507 bool
508 ReadRegister(lldb::tid_t tid,
509 uint32_t reg_num,
510 StringExtractorGDBRemote &response);
511
512 bool
513 ReadAllRegisters (lldb::tid_t tid,
514 StringExtractorGDBRemote &response);
515
516 bool
517 SaveRegisterState (lldb::tid_t tid, uint32_t &save_id);
518
519 bool
520 RestoreRegisterState (lldb::tid_t tid, uint32_t save_id);
Jason Molendaa3329782014-03-29 18:54:20 +0000521
522 const char *
523 GetGDBServerProgramName();
Greg Claytonf74cf862013-11-13 23:28:31 +0000524
Jason Molendaa3329782014-03-29 18:54:20 +0000525 uint32_t
526 GetGDBServerProgramVersion();
527
528 bool
529 AvoidGPackets(ProcessGDBRemote *process);
530
Jason Molenda705b1802014-06-13 02:37:02 +0000531 bool
532 GetThreadExtendedInfoSupported();
533
Oleksiy Vyalov6801be32015-02-25 22:15:44 +0000534 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000535 GetModuleInfo (const FileSpec& module_file_spec,
536 const ArchSpec& arch_spec,
537 ModuleSpec &module_spec);
Oleksiy Vyalov6801be32015-02-25 22:15:44 +0000538
Colin Rileyc3c95b22015-04-16 15:51:33 +0000539 bool
540 ReadExtFeature (const lldb_private::ConstString object,
541 const lldb_private::ConstString annex,
542 std::string & out,
543 lldb_private::Error & err);
544
Greg Clayton576d8832011-03-22 04:00:09 +0000545protected:
546
Greg Clayton3dedae12013-12-06 21:45:27 +0000547 PacketResult
548 SendPacketAndWaitForResponseNoLock (const char *payload,
549 size_t payload_length,
550 StringExtractorGDBRemote &response);
551
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000552 bool
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000553 GetCurrentProcessInfo (bool allow_lazy_pid = true);
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000554
Jason Molendaa3329782014-03-29 18:54:20 +0000555 bool
556 GetGDBServerVersion();
557
Greg Clayton576d8832011-03-22 04:00:09 +0000558 //------------------------------------------------------------------
559 // Classes that inherit from GDBRemoteCommunicationClient can see and modify these
560 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000561 LazyBool m_supports_not_sending_acks;
562 LazyBool m_supports_thread_suffix;
563 LazyBool m_supports_threads_in_stop_reply;
564 LazyBool m_supports_vCont_all;
565 LazyBool m_supports_vCont_any;
566 LazyBool m_supports_vCont_c;
567 LazyBool m_supports_vCont_C;
568 LazyBool m_supports_vCont_s;
569 LazyBool m_supports_vCont_S;
570 LazyBool m_qHostInfo_is_valid;
571 LazyBool m_curr_pid_is_valid;
572 LazyBool m_qProcessInfo_is_valid;
573 LazyBool m_qGDBServerVersion_is_valid;
574 LazyBool m_supports_alloc_dealloc_memory;
575 LazyBool m_supports_memory_region_info;
576 LazyBool m_supports_watchpoint_support_info;
577 LazyBool m_supports_detach_stay_stopped;
578 LazyBool m_watchpoints_trigger_after_instruction;
579 LazyBool m_attach_or_wait_reply;
580 LazyBool m_prepare_for_reg_writing_reply;
581 LazyBool m_supports_p;
582 LazyBool m_supports_x;
583 LazyBool m_avoid_g_packets;
584 LazyBool m_supports_QSaveRegisterState;
585 LazyBool m_supports_qXfer_auxv_read;
586 LazyBool m_supports_qXfer_libraries_read;
587 LazyBool m_supports_qXfer_libraries_svr4_read;
Colin Rileyc3c95b22015-04-16 15:51:33 +0000588 LazyBool m_supports_qXfer_features_read;
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000589 LazyBool m_supports_augmented_libraries_svr4_read;
590 LazyBool m_supports_jThreadExtendedInfo;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000591
Greg Clayton8b82f082011-04-12 05:54:46 +0000592 bool
593 m_supports_qProcessInfoPID:1,
594 m_supports_qfProcessInfo:1,
595 m_supports_qUserName:1,
596 m_supports_qGroupName:1,
597 m_supports_qThreadStopInfo:1,
598 m_supports_z0:1,
599 m_supports_z1:1,
600 m_supports_z2:1,
601 m_supports_z3:1,
Greg Clayton89600582013-10-10 17:53:50 +0000602 m_supports_z4:1,
603 m_supports_QEnvironment:1,
604 m_supports_QEnvironmentHexEncoded:1;
Greg Clayton2a48f522011-05-14 01:50:35 +0000605
Todd Fiala9f72b3a2014-05-07 19:28:21 +0000606 lldb::pid_t m_curr_pid;
Greg Clayton8b82f082011-04-12 05:54:46 +0000607 lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations
608 lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc
609
Greg Clayton576d8832011-03-22 04:00:09 +0000610
Johnny Chen64637202012-05-23 21:09:52 +0000611 uint32_t m_num_supported_hardware_watchpoints;
612
Greg Clayton576d8832011-03-22 04:00:09 +0000613 // If we need to send a packet while the target is running, the m_async_XXX
614 // member variables take care of making this happen.
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000615 Mutex m_async_mutex;
616 Predicate<bool> m_async_packet_predicate;
Greg Clayton576d8832011-03-22 04:00:09 +0000617 std::string m_async_packet;
Jim Inghama6195b72013-12-18 01:24:33 +0000618 PacketResult m_async_result;
Greg Clayton576d8832011-03-22 04:00:09 +0000619 StringExtractorGDBRemote m_async_response;
620 int m_async_signal; // We were asked to deliver a signal to the inferior process.
Greg Clayton2687cd12012-03-29 01:55:41 +0000621 bool m_interrupt_sent;
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000622 std::string m_partial_profile_data;
623 std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
Greg Clayton576d8832011-03-22 04:00:09 +0000624
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000625 ArchSpec m_host_arch;
626 ArchSpec m_process_arch;
Greg Clayton1cb64962011-03-24 04:28:38 +0000627 uint32_t m_os_version_major;
628 uint32_t m_os_version_minor;
629 uint32_t m_os_version_update;
630 std::string m_os_build;
631 std::string m_os_kernel;
632 std::string m_hostname;
Jason Molendaa3329782014-03-29 18:54:20 +0000633 std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if qGDBServerVersion is not supported
634 uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if qGDBServerVersion is not supported
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000635 uint32_t m_default_packet_timeout;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000636 uint64_t m_max_packet_size; // as returned by qSupported
Greg Clayton576d8832011-03-22 04:00:09 +0000637
Greg Clayton32e0a752011-03-30 18:16:51 +0000638 bool
639 DecodeProcessInfoResponse (StringExtractorGDBRemote &response,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000640 ProcessInstanceInfo &process_info);
Greg Clayton576d8832011-03-22 04:00:09 +0000641private:
642 //------------------------------------------------------------------
643 // For GDBRemoteCommunicationClient only
644 //------------------------------------------------------------------
645 DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
646};
647
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000648} // namespace process_gdb_remote
649} // namespace lldb_private
650
Greg Clayton576d8832011-03-22 04:00:09 +0000651#endif // liblldb_GDBRemoteCommunicationClient_h_