blob: 0338c26238b48e62373470df420b40ae8b2c1286 [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
24class GDBRemoteCommunicationClient : public GDBRemoteCommunication
25{
26public:
27 //------------------------------------------------------------------
28 // Constructors and Destructors
29 //------------------------------------------------------------------
Greg Clayton8b82f082011-04-12 05:54:46 +000030 GDBRemoteCommunicationClient(bool is_platform);
Greg Clayton576d8832011-03-22 04:00:09 +000031
Greg Clayton576d8832011-03-22 04:00:09 +000032 ~GDBRemoteCommunicationClient();
33
Greg Clayton1cb64962011-03-24 04:28:38 +000034 //------------------------------------------------------------------
35 // After connecting, send the handshake to the server to make sure
36 // we are communicating with it.
37 //------------------------------------------------------------------
38 bool
39 HandshakeWithServer (lldb_private::Error *error_ptr);
40
Greg Clayton3dedae12013-12-06 21:45:27 +000041 PacketResult
Greg Clayton576d8832011-03-22 04:00:09 +000042 SendPacketAndWaitForResponse (const char *send_payload,
43 StringExtractorGDBRemote &response,
44 bool send_async);
45
Greg Clayton3dedae12013-12-06 21:45:27 +000046 PacketResult
Greg Clayton576d8832011-03-22 04:00:09 +000047 SendPacketAndWaitForResponse (const char *send_payload,
48 size_t send_length,
49 StringExtractorGDBRemote &response,
50 bool send_async);
51
Steve Pucci5ae54ae2014-01-25 05:46:51 +000052 // For packets which specify a range of output to be returned,
53 // return all of the output via a series of request packets of the form
54 // <prefix>0,<size>
55 // <prefix><size>,<size>
56 // <prefix><size>*2,<size>
57 // <prefix><size>*3,<size>
58 // ...
59 // until a "$l..." packet is received, indicating the end.
60 // (size is in hex; this format is used by a standard gdbserver to
61 // return the given portion of the output specified by <prefix>;
62 // for example, "qXfer:libraries-svr4:read::fff,1000" means
63 // "return a chunk of the xml description file for shared
64 // library load addresses, where the chunk starts at offset 0xfff
65 // and continues for 0x1000 bytes").
66 // Concatenate the resulting server response packets together and
67 // return in response_string. If any packet fails, the return value
68 // indicates that failure and the returned string value is undefined.
69 PacketResult
70 SendPacketsAndConcatenateResponses (const char *send_payload_prefix,
71 std::string &response_string);
72
Greg Clayton576d8832011-03-22 04:00:09 +000073 lldb::StateType
74 SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process,
75 const char *packet_payload,
76 size_t packet_length,
77 StringExtractorGDBRemote &response);
78
Greg Claytonfbb76342013-11-20 21:07:01 +000079 bool
Greg Clayton576d8832011-03-22 04:00:09 +000080 GetThreadSuffixSupported ();
81
Greg Claytonfb909312013-11-23 01:58:15 +000082 // This packet is usually sent first and the boolean return value
83 // indicates if the packet was send and any response was received
84 // even in the response is UNIMPLEMENTED. If the packet failed to
85 // get a response, then false is returned. This quickly tells us
Bruce Mitchenerd93c4a32014-07-01 21:22:11 +000086 // if we were able to connect and communicate with the remote GDB
Greg Claytonfb909312013-11-23 01:58:15 +000087 // server
88 bool
Greg Clayton1cb64962011-03-24 04:28:38 +000089 QueryNoAckModeSupported ();
Greg Clayton576d8832011-03-22 04:00:09 +000090
Greg Clayton44633992012-04-10 03:22:03 +000091 void
92 GetListThreadsInStopReplySupported ();
93
Greg Clayton576d8832011-03-22 04:00:09 +000094 bool
95 SendAsyncSignal (int signo);
96
97 bool
98 SendInterrupt (lldb_private::Mutex::Locker &locker,
99 uint32_t seconds_to_wait_for_stop,
Greg Clayton576d8832011-03-22 04:00:09 +0000100 bool &timed_out);
101
102 lldb::pid_t
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000103 GetCurrentProcessID (bool allow_lazy = true);
Greg Clayton576d8832011-03-22 04:00:09 +0000104
105 bool
106 GetLaunchSuccess (std::string &error_str);
107
Greg Clayton8b82f082011-04-12 05:54:46 +0000108 uint16_t
Greg Claytondbf04572013-12-04 19:40:33 +0000109 LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000110
111 bool
112 KillSpawnedProcess (lldb::pid_t pid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000113
Greg Clayton576d8832011-03-22 04:00:09 +0000114 //------------------------------------------------------------------
115 /// Sends a GDB remote protocol 'A' packet that delivers program
116 /// arguments to the remote server.
117 ///
118 /// @param[in] argv
119 /// A NULL terminated array of const C strings to use as the
120 /// arguments.
121 ///
122 /// @return
123 /// Zero if the response was "OK", a positive value if the
124 /// the response was "Exx" where xx are two hex digits, or
125 /// -1 if the call is unsupported or any other unexpected
126 /// response was received.
127 //------------------------------------------------------------------
128 int
Greg Claytonfbb76342013-11-20 21:07:01 +0000129 SendArgumentsPacket (const lldb_private::ProcessLaunchInfo &launch_info);
Greg Clayton576d8832011-03-22 04:00:09 +0000130
131 //------------------------------------------------------------------
132 /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
133 /// environment that will get used when launching an application
134 /// in conjunction with the 'A' packet. This function can be called
135 /// multiple times in a row in order to pass on the desired
136 /// environment that the inferior should be launched with.
137 ///
138 /// @param[in] name_equal_value
139 /// A NULL terminated C string that contains a single environment
140 /// in the format "NAME=VALUE".
141 ///
142 /// @return
143 /// Zero if the response was "OK", a positive value if the
144 /// the response was "Exx" where xx are two hex digits, or
145 /// -1 if the call is unsupported or any other unexpected
146 /// response was received.
147 //------------------------------------------------------------------
148 int
149 SendEnvironmentPacket (char const *name_equal_value);
150
Greg Claytonc4103b32011-05-08 04:53:50 +0000151 int
152 SendLaunchArchPacket (const char *arch);
Jason Molendaa3329782014-03-29 18:54:20 +0000153
154 int
155 SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL);
156
Greg Clayton576d8832011-03-22 04:00:09 +0000157 //------------------------------------------------------------------
158 /// Sends a "vAttach:PID" where PID is in hex.
159 ///
160 /// @param[in] pid
161 /// A process ID for the remote gdb server to attach to.
162 ///
163 /// @param[out] response
164 /// The response received from the gdb server. If the return
165 /// value is zero, \a response will contain a stop reply
166 /// packet.
167 ///
168 /// @return
169 /// Zero if the attach was successful, or an error indicating
170 /// an error code.
171 //------------------------------------------------------------------
172 int
173 SendAttach (lldb::pid_t pid,
174 StringExtractorGDBRemote& response);
175
176
177 //------------------------------------------------------------------
178 /// Sets the path to use for stdin/out/err for a process
179 /// that will be launched with the 'A' packet.
180 ///
181 /// @param[in] path
182 /// The path to use for stdin/out/err
183 ///
184 /// @return
185 /// Zero if the for success, or an error code for failure.
186 //------------------------------------------------------------------
187 int
188 SetSTDIN (char const *path);
189 int
190 SetSTDOUT (char const *path);
191 int
192 SetSTDERR (char const *path);
193
194 //------------------------------------------------------------------
195 /// Sets the disable ASLR flag to \a enable for a process that will
196 /// be launched with the 'A' packet.
197 ///
198 /// @param[in] enable
Jim Ingham106d0282014-06-25 02:32:56 +0000199 /// A boolean value indicating whether to disable ASLR or not.
Greg Clayton576d8832011-03-22 04:00:09 +0000200 ///
201 /// @return
202 /// Zero if the for success, or an error code for failure.
203 //------------------------------------------------------------------
204 int
205 SetDisableASLR (bool enable);
Jim Ingham106d0282014-06-25 02:32:56 +0000206
207 //------------------------------------------------------------------
208 /// Sets the DetachOnError flag to \a enable for the process controlled by the stub.
209 ///
210 /// @param[in] enable
211 /// A boolean value indicating whether to detach on error or not.
212 ///
213 /// @return
214 /// Zero if the for success, or an error code for failure.
215 //------------------------------------------------------------------
216 int
217 SetDetachOnError (bool enable);
Greg Clayton576d8832011-03-22 04:00:09 +0000218
219 //------------------------------------------------------------------
220 /// Sets the working directory to \a path for a process that will
Greg Claytonfbb76342013-11-20 21:07:01 +0000221 /// be launched with the 'A' packet for non platform based
222 /// connections. If this packet is sent to a GDB server that
223 /// implements the platform, it will change the current working
224 /// directory for the platform process.
Greg Clayton576d8832011-03-22 04:00:09 +0000225 ///
226 /// @param[in] path
Bruce Mitchenerd93c4a32014-07-01 21:22:11 +0000227 /// The path to a directory to use when launching our process
Greg Clayton576d8832011-03-22 04:00:09 +0000228 ///
229 /// @return
230 /// Zero if the for success, or an error code for failure.
231 //------------------------------------------------------------------
232 int
233 SetWorkingDir (char const *path);
234
Greg Claytonfbb76342013-11-20 21:07:01 +0000235 //------------------------------------------------------------------
236 /// Gets the current working directory of a remote platform GDB
237 /// server.
238 ///
239 /// @param[out] cwd
240 /// The current working directory on the remote platform.
241 ///
242 /// @return
243 /// Boolean for success
244 //------------------------------------------------------------------
245 bool
246 GetWorkingDir (std::string &cwd);
247
Greg Clayton576d8832011-03-22 04:00:09 +0000248 lldb::addr_t
249 AllocateMemory (size_t size, uint32_t permissions);
250
251 bool
252 DeallocateMemory (lldb::addr_t addr);
253
Jim Inghamacff8952013-05-02 00:27:30 +0000254 lldb_private::Error
255 Detach (bool keep_stopped);
Greg Clayton37a0a242012-04-11 00:24:49 +0000256
Greg Clayton46fb5582011-11-18 07:03:08 +0000257 lldb_private::Error
258 GetMemoryRegionInfo (lldb::addr_t addr,
259 lldb_private::MemoryRegionInfo &range_info);
260
Johnny Chen64637202012-05-23 21:09:52 +0000261 lldb_private::Error
262 GetWatchpointSupportInfo (uint32_t &num);
263
Enrico Granataf04a2192012-07-13 23:18:48 +0000264 lldb_private::Error
265 GetWatchpointSupportInfo (uint32_t &num, bool& after);
266
267 lldb_private::Error
268 GetWatchpointsTriggerAfterInstruction (bool &after);
269
Greg Clayton576d8832011-03-22 04:00:09 +0000270 const lldb_private::ArchSpec &
271 GetHostArchitecture ();
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000272
273 uint32_t
274 GetHostDefaultPacketTimeout();
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000275
276 const lldb_private::ArchSpec &
277 GetProcessArchitecture ();
278
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000279 void
280 GetRemoteQSupported();
281
Greg Clayton576d8832011-03-22 04:00:09 +0000282 bool
283 GetVContSupported (char flavor);
284
Jim Inghamcd16df92012-07-20 21:37:13 +0000285 bool
Sean Callananb1de1142013-09-04 23:24:15 +0000286 GetpPacketSupported (lldb::tid_t tid);
Hafiz Abid Qadeer9a78cdf2013-08-29 09:09:45 +0000287
288 bool
Jason Molendabdc4f122014-05-06 02:59:39 +0000289 GetxPacketSupported ();
290
291 bool
Jim Inghamcd16df92012-07-20 21:37:13 +0000292 GetVAttachOrWaitSupported ();
293
Jim Ingham279ceec2012-07-25 21:12:43 +0000294 bool
295 GetSyncThreadStateSupported();
296
Greg Clayton576d8832011-03-22 04:00:09 +0000297 void
298 ResetDiscoverableSettings();
299
300 bool
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000301 GetHostInfo (bool force = false);
Greg Clayton576d8832011-03-22 04:00:09 +0000302
303 bool
Greg Clayton1cb64962011-03-24 04:28:38 +0000304 GetOSVersion (uint32_t &major,
305 uint32_t &minor,
306 uint32_t &update);
307
308 bool
309 GetOSBuildString (std::string &s);
310
311 bool
312 GetOSKernelDescription (std::string &s);
313
314 lldb_private::ArchSpec
315 GetSystemArchitecture ();
316
317 bool
318 GetHostname (std::string &s);
319
Greg Clayton37a0a242012-04-11 00:24:49 +0000320 lldb::addr_t
321 GetShlibInfoAddr();
322
Greg Clayton1cb64962011-03-24 04:28:38 +0000323 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000324 GetSupportsThreadSuffix ();
325
326 bool
Greg Clayton32e0a752011-03-30 18:16:51 +0000327 GetProcessInfo (lldb::pid_t pid,
Greg Clayton8b82f082011-04-12 05:54:46 +0000328 lldb_private::ProcessInstanceInfo &process_info);
Greg Clayton32e0a752011-03-30 18:16:51 +0000329
330 uint32_t
Greg Clayton8b82f082011-04-12 05:54:46 +0000331 FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info,
332 lldb_private::ProcessInstanceInfoList &process_infos);
Greg Clayton32e0a752011-03-30 18:16:51 +0000333
334 bool
335 GetUserName (uint32_t uid, std::string &name);
336
337 bool
338 GetGroupName (uint32_t gid, std::string &name);
339
340 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000341 HasFullVContSupport ()
342 {
343 return GetVContSupported ('A');
344 }
345
346 bool
347 HasAnyVContSupport ()
348 {
349 return GetVContSupported ('a');
350 }
351
Greg Clayton8b82f082011-04-12 05:54:46 +0000352 bool
353 GetStopReply (StringExtractorGDBRemote &response);
354
355 bool
Greg Claytonf402f782012-10-13 02:11:55 +0000356 GetThreadStopInfo (lldb::tid_t tid,
Greg Clayton8b82f082011-04-12 05:54:46 +0000357 StringExtractorGDBRemote &response);
358
359 bool
360 SupportsGDBStoppointPacket (GDBStoppointType type)
361 {
362 switch (type)
363 {
364 case eBreakpointSoftware: return m_supports_z0;
365 case eBreakpointHardware: return m_supports_z1;
366 case eWatchpointWrite: return m_supports_z2;
367 case eWatchpointRead: return m_supports_z3;
368 case eWatchpointReadWrite: return m_supports_z4;
Chaoren Lin0be9ebb2015-02-03 01:51:50 +0000369 case eStoppointInvalid: return false;
Greg Clayton8b82f082011-04-12 05:54:46 +0000370 }
Greg Clayton8b82f082011-04-12 05:54:46 +0000371 }
372 uint8_t
373 SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint
374 bool insert, // Insert or remove?
375 lldb::addr_t addr, // Address of breakpoint or watchpoint
376 uint32_t length); // Byte Size of breakpoint or watchpoint
377
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000378 void
379 TestPacketSpeed (const uint32_t num_packets);
380
381 // This packet is for testing the speed of the interface only. Both
382 // the client and server need to support it, but this allows us to
383 // measure the packet speed without any other work being done on the
384 // other end and avoids any of that work affecting the packet send
385 // and response times.
386 bool
387 SendSpeedTestPacket (uint32_t send_size,
388 uint32_t recv_size);
Greg Clayton8b82f082011-04-12 05:54:46 +0000389
390 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000391 SetCurrentThread (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000392
393 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000394 SetCurrentThreadForRun (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000395
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000396 bool
Steve Pucci03904ac2014-03-04 23:18:46 +0000397 GetQXferAuxvReadSupported ();
398
399 bool
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000400 GetQXferLibrariesReadSupported ();
401
402 bool
403 GetQXferLibrariesSVR4ReadSupported ();
404
405 uint64_t
406 GetRemoteMaxPacketSize();
407
408 bool
409 GetAugmentedLibrariesSVR4ReadSupported ();
410
Greg Clayton2a48f522011-05-14 01:50:35 +0000411 lldb_private::LazyBool
Jim Ingham372787f2012-04-07 00:00:41 +0000412 SupportsAllocDeallocMemory () // const
Greg Clayton2a48f522011-05-14 01:50:35 +0000413 {
Jim Ingham372787f2012-04-07 00:00:41 +0000414 // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets.
415 // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;
Greg Clayton70b57652011-05-15 01:25:55 +0000416 return m_supports_alloc_dealloc_memory;
Greg Clayton2a48f522011-05-14 01:50:35 +0000417 }
418
Greg Claytonadc00cb2011-05-20 23:38:13 +0000419 size_t
420 GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids,
421 bool &sequence_mutex_unavailable);
422
Greg Clayton2687cd12012-03-29 01:55:41 +0000423 bool
424 GetInterruptWasSent () const
425 {
426 return m_interrupt_sent;
427 }
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000428
Greg Claytonfbb76342013-11-20 21:07:01 +0000429 lldb::user_id_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000430 OpenFile (const lldb_private::FileSpec& file_spec,
431 uint32_t flags,
432 mode_t mode,
433 lldb_private::Error &error);
434
Greg Claytonfbb76342013-11-20 21:07:01 +0000435 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000436 CloseFile (lldb::user_id_t fd,
437 lldb_private::Error &error);
438
Greg Claytonfbb76342013-11-20 21:07:01 +0000439 lldb::user_id_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000440 GetFileSize (const lldb_private::FileSpec& file_spec);
441
Greg Claytonfbb76342013-11-20 21:07:01 +0000442 lldb_private::Error
443 GetFilePermissions(const char *path, uint32_t &file_permissions);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000444
Greg Claytonfbb76342013-11-20 21:07:01 +0000445 lldb_private::Error
446 SetFilePermissions(const char *path, uint32_t file_permissions);
447
448 uint64_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000449 ReadFile (lldb::user_id_t fd,
450 uint64_t offset,
451 void *dst,
452 uint64_t dst_len,
453 lldb_private::Error &error);
454
Greg Claytonfbb76342013-11-20 21:07:01 +0000455 uint64_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000456 WriteFile (lldb::user_id_t fd,
457 uint64_t offset,
458 const void* src,
459 uint64_t src_len,
460 lldb_private::Error &error);
461
Greg Claytonfbb76342013-11-20 21:07:01 +0000462 lldb_private::Error
463 CreateSymlink (const char *src,
464 const char *dst);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000465
Greg Claytonfbb76342013-11-20 21:07:01 +0000466 lldb_private::Error
467 Unlink (const char *path);
468
469 lldb_private::Error
470 MakeDirectory (const char *path,
471 uint32_t mode);
472
473 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000474 GetFileExists (const lldb_private::FileSpec& file_spec);
475
Greg Claytonfbb76342013-11-20 21:07:01 +0000476 lldb_private::Error
Daniel Maleae0f8f572013-08-26 23:57:52 +0000477 RunShellCommand (const char *command, // Shouldn't be NULL
478 const char *working_dir, // Pass NULL to use the current working directory
479 int *status_ptr, // Pass NULL if you don't want the process exit status
480 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
481 std::string *command_output, // Pass NULL if you don't want the command output
482 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
483
Greg Claytonfbb76342013-11-20 21:07:01 +0000484 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000485 CalculateMD5 (const lldb_private::FileSpec& file_spec,
486 uint64_t &high,
487 uint64_t &low);
488
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000489 std::string
490 HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process,
491 StringExtractorGDBRemote &inputStringExtractor);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000492
Greg Claytonf74cf862013-11-13 23:28:31 +0000493 bool
494 ReadRegister(lldb::tid_t tid,
495 uint32_t reg_num,
496 StringExtractorGDBRemote &response);
497
498 bool
499 ReadAllRegisters (lldb::tid_t tid,
500 StringExtractorGDBRemote &response);
501
502 bool
503 SaveRegisterState (lldb::tid_t tid, uint32_t &save_id);
504
505 bool
506 RestoreRegisterState (lldb::tid_t tid, uint32_t save_id);
Jason Molendaa3329782014-03-29 18:54:20 +0000507
508 const char *
509 GetGDBServerProgramName();
Greg Claytonf74cf862013-11-13 23:28:31 +0000510
Jason Molendaa3329782014-03-29 18:54:20 +0000511 uint32_t
512 GetGDBServerProgramVersion();
513
514 bool
515 AvoidGPackets(ProcessGDBRemote *process);
516
Jason Molenda705b1802014-06-13 02:37:02 +0000517 bool
518 GetThreadExtendedInfoSupported();
519
Greg Clayton576d8832011-03-22 04:00:09 +0000520protected:
521
Greg Clayton3dedae12013-12-06 21:45:27 +0000522 PacketResult
523 SendPacketAndWaitForResponseNoLock (const char *payload,
524 size_t payload_length,
525 StringExtractorGDBRemote &response);
526
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000527 bool
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000528 GetCurrentProcessInfo (bool allow_lazy_pid = true);
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000529
Jason Molendaa3329782014-03-29 18:54:20 +0000530 bool
531 GetGDBServerVersion();
532
Greg Clayton576d8832011-03-22 04:00:09 +0000533 //------------------------------------------------------------------
534 // Classes that inherit from GDBRemoteCommunicationClient can see and modify these
535 //------------------------------------------------------------------
Greg Claytone0d378b2011-03-24 21:19:54 +0000536 lldb_private::LazyBool m_supports_not_sending_acks;
537 lldb_private::LazyBool m_supports_thread_suffix;
Greg Clayton44633992012-04-10 03:22:03 +0000538 lldb_private::LazyBool m_supports_threads_in_stop_reply;
Greg Claytone0d378b2011-03-24 21:19:54 +0000539 lldb_private::LazyBool m_supports_vCont_all;
540 lldb_private::LazyBool m_supports_vCont_any;
541 lldb_private::LazyBool m_supports_vCont_c;
542 lldb_private::LazyBool m_supports_vCont_C;
543 lldb_private::LazyBool m_supports_vCont_s;
544 lldb_private::LazyBool m_supports_vCont_S;
Greg Clayton32e0a752011-03-30 18:16:51 +0000545 lldb_private::LazyBool m_qHostInfo_is_valid;
Todd Fiala9f72b3a2014-05-07 19:28:21 +0000546 lldb_private::LazyBool m_curr_pid_is_valid;
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000547 lldb_private::LazyBool m_qProcessInfo_is_valid;
Jason Molendaa3329782014-03-29 18:54:20 +0000548 lldb_private::LazyBool m_qGDBServerVersion_is_valid;
Greg Clayton70b57652011-05-15 01:25:55 +0000549 lldb_private::LazyBool m_supports_alloc_dealloc_memory;
Greg Clayton46fb5582011-11-18 07:03:08 +0000550 lldb_private::LazyBool m_supports_memory_region_info;
Johnny Chen64637202012-05-23 21:09:52 +0000551 lldb_private::LazyBool m_supports_watchpoint_support_info;
Jim Inghamacff8952013-05-02 00:27:30 +0000552 lldb_private::LazyBool m_supports_detach_stay_stopped;
Enrico Granataf04a2192012-07-13 23:18:48 +0000553 lldb_private::LazyBool m_watchpoints_trigger_after_instruction;
Jim Inghamcd16df92012-07-20 21:37:13 +0000554 lldb_private::LazyBool m_attach_or_wait_reply;
Jim Ingham279ceec2012-07-25 21:12:43 +0000555 lldb_private::LazyBool m_prepare_for_reg_writing_reply;
Hafiz Abid Qadeer9a78cdf2013-08-29 09:09:45 +0000556 lldb_private::LazyBool m_supports_p;
Jason Molendabdc4f122014-05-06 02:59:39 +0000557 lldb_private::LazyBool m_supports_x;
Jason Molendaa3329782014-03-29 18:54:20 +0000558 lldb_private::LazyBool m_avoid_g_packets;
Greg Claytonf74cf862013-11-13 23:28:31 +0000559 lldb_private::LazyBool m_supports_QSaveRegisterState;
Steve Pucci03904ac2014-03-04 23:18:46 +0000560 lldb_private::LazyBool m_supports_qXfer_auxv_read;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000561 lldb_private::LazyBool m_supports_qXfer_libraries_read;
562 lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read;
563 lldb_private::LazyBool m_supports_augmented_libraries_svr4_read;
Jason Molenda705b1802014-06-13 02:37:02 +0000564 lldb_private::LazyBool m_supports_jThreadExtendedInfo;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000565
Greg Clayton8b82f082011-04-12 05:54:46 +0000566 bool
567 m_supports_qProcessInfoPID:1,
568 m_supports_qfProcessInfo:1,
569 m_supports_qUserName:1,
570 m_supports_qGroupName:1,
571 m_supports_qThreadStopInfo:1,
572 m_supports_z0:1,
573 m_supports_z1:1,
574 m_supports_z2:1,
575 m_supports_z3:1,
Greg Clayton89600582013-10-10 17:53:50 +0000576 m_supports_z4:1,
577 m_supports_QEnvironment:1,
578 m_supports_QEnvironmentHexEncoded:1;
Greg Clayton2a48f522011-05-14 01:50:35 +0000579
Todd Fiala9f72b3a2014-05-07 19:28:21 +0000580 lldb::pid_t m_curr_pid;
Greg Clayton8b82f082011-04-12 05:54:46 +0000581 lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations
582 lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc
583
Greg Clayton576d8832011-03-22 04:00:09 +0000584
Johnny Chen64637202012-05-23 21:09:52 +0000585 uint32_t m_num_supported_hardware_watchpoints;
586
Greg Clayton576d8832011-03-22 04:00:09 +0000587 // If we need to send a packet while the target is running, the m_async_XXX
588 // member variables take care of making this happen.
589 lldb_private::Mutex m_async_mutex;
590 lldb_private::Predicate<bool> m_async_packet_predicate;
591 std::string m_async_packet;
Jim Inghama6195b72013-12-18 01:24:33 +0000592 PacketResult m_async_result;
Greg Clayton576d8832011-03-22 04:00:09 +0000593 StringExtractorGDBRemote m_async_response;
594 int m_async_signal; // We were asked to deliver a signal to the inferior process.
Greg Clayton2687cd12012-03-29 01:55:41 +0000595 bool m_interrupt_sent;
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000596 std::string m_partial_profile_data;
597 std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
Greg Clayton576d8832011-03-22 04:00:09 +0000598
Greg Claytond314e812011-03-23 00:09:55 +0000599 lldb_private::ArchSpec m_host_arch;
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000600 lldb_private::ArchSpec m_process_arch;
Greg Clayton1cb64962011-03-24 04:28:38 +0000601 uint32_t m_os_version_major;
602 uint32_t m_os_version_minor;
603 uint32_t m_os_version_update;
604 std::string m_os_build;
605 std::string m_os_kernel;
606 std::string m_hostname;
Jason Molendaa3329782014-03-29 18:54:20 +0000607 std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if qGDBServerVersion is not supported
608 uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if qGDBServerVersion is not supported
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000609 uint32_t m_default_packet_timeout;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000610 uint64_t m_max_packet_size; // as returned by qSupported
Greg Clayton576d8832011-03-22 04:00:09 +0000611
Greg Clayton32e0a752011-03-30 18:16:51 +0000612 bool
613 DecodeProcessInfoResponse (StringExtractorGDBRemote &response,
Greg Clayton8b82f082011-04-12 05:54:46 +0000614 lldb_private::ProcessInstanceInfo &process_info);
Greg Clayton576d8832011-03-22 04:00:09 +0000615private:
616 //------------------------------------------------------------------
617 // For GDBRemoteCommunicationClient only
618 //------------------------------------------------------------------
619 DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
620};
621
622#endif // liblldb_GDBRemoteCommunicationClient_h_