blob: f8b3bdd51f5c8a0ea57818af5d969ab59f5e9442 [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 //------------------------------------------------------------------
Tamas Berghammere13c2732015-02-11 10:29:30 +000030 GDBRemoteCommunicationClient();
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 //------------------------------------------------------------------
Vince Harrone0be4252015-02-06 18:32:57 +0000178 /// Sends a GDB remote protocol 'I' packet that delivers stdin
179 /// data to the remote process.
180 ///
181 /// @param[in] data
182 /// A pointer to stdin data.
183 ///
184 /// @param[in] data_len
185 /// The number of bytes available at \a data.
186 ///
187 /// @return
188 /// Zero if the attach was successful, or an error indicating
189 /// an error code.
190 //------------------------------------------------------------------
191 int
192 SendStdinNotification(const char* data, size_t data_len);
193
194 //------------------------------------------------------------------
Greg Clayton576d8832011-03-22 04:00:09 +0000195 /// Sets the path to use for stdin/out/err for a process
196 /// that will be launched with the 'A' packet.
197 ///
198 /// @param[in] path
199 /// The path to use for stdin/out/err
200 ///
201 /// @return
202 /// Zero if the for success, or an error code for failure.
203 //------------------------------------------------------------------
204 int
205 SetSTDIN (char const *path);
206 int
207 SetSTDOUT (char const *path);
208 int
209 SetSTDERR (char const *path);
210
211 //------------------------------------------------------------------
212 /// Sets the disable ASLR flag to \a enable for a process that will
213 /// be launched with the 'A' packet.
214 ///
215 /// @param[in] enable
Jim Ingham106d0282014-06-25 02:32:56 +0000216 /// A boolean value indicating whether to disable ASLR or not.
Greg Clayton576d8832011-03-22 04:00:09 +0000217 ///
218 /// @return
219 /// Zero if the for success, or an error code for failure.
220 //------------------------------------------------------------------
221 int
222 SetDisableASLR (bool enable);
Jim Ingham106d0282014-06-25 02:32:56 +0000223
224 //------------------------------------------------------------------
225 /// Sets the DetachOnError flag to \a enable for the process controlled by the stub.
226 ///
227 /// @param[in] enable
228 /// A boolean value indicating whether to detach on error or not.
229 ///
230 /// @return
231 /// Zero if the for success, or an error code for failure.
232 //------------------------------------------------------------------
233 int
234 SetDetachOnError (bool enable);
Greg Clayton576d8832011-03-22 04:00:09 +0000235
236 //------------------------------------------------------------------
237 /// Sets the working directory to \a path for a process that will
Greg Claytonfbb76342013-11-20 21:07:01 +0000238 /// be launched with the 'A' packet for non platform based
239 /// connections. If this packet is sent to a GDB server that
240 /// implements the platform, it will change the current working
241 /// directory for the platform process.
Greg Clayton576d8832011-03-22 04:00:09 +0000242 ///
243 /// @param[in] path
Bruce Mitchenerd93c4a32014-07-01 21:22:11 +0000244 /// The path to a directory to use when launching our process
Greg Clayton576d8832011-03-22 04:00:09 +0000245 ///
246 /// @return
247 /// Zero if the for success, or an error code for failure.
248 //------------------------------------------------------------------
249 int
250 SetWorkingDir (char const *path);
251
Greg Claytonfbb76342013-11-20 21:07:01 +0000252 //------------------------------------------------------------------
253 /// Gets the current working directory of a remote platform GDB
254 /// server.
255 ///
256 /// @param[out] cwd
257 /// The current working directory on the remote platform.
258 ///
259 /// @return
260 /// Boolean for success
261 //------------------------------------------------------------------
262 bool
263 GetWorkingDir (std::string &cwd);
264
Greg Clayton576d8832011-03-22 04:00:09 +0000265 lldb::addr_t
266 AllocateMemory (size_t size, uint32_t permissions);
267
268 bool
269 DeallocateMemory (lldb::addr_t addr);
270
Jim Inghamacff8952013-05-02 00:27:30 +0000271 lldb_private::Error
272 Detach (bool keep_stopped);
Greg Clayton37a0a242012-04-11 00:24:49 +0000273
Greg Clayton46fb5582011-11-18 07:03:08 +0000274 lldb_private::Error
275 GetMemoryRegionInfo (lldb::addr_t addr,
276 lldb_private::MemoryRegionInfo &range_info);
277
Johnny Chen64637202012-05-23 21:09:52 +0000278 lldb_private::Error
279 GetWatchpointSupportInfo (uint32_t &num);
280
Enrico Granataf04a2192012-07-13 23:18:48 +0000281 lldb_private::Error
282 GetWatchpointSupportInfo (uint32_t &num, bool& after);
283
284 lldb_private::Error
285 GetWatchpointsTriggerAfterInstruction (bool &after);
286
Greg Clayton576d8832011-03-22 04:00:09 +0000287 const lldb_private::ArchSpec &
288 GetHostArchitecture ();
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000289
290 uint32_t
291 GetHostDefaultPacketTimeout();
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000292
293 const lldb_private::ArchSpec &
294 GetProcessArchitecture ();
295
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000296 void
297 GetRemoteQSupported();
298
Greg Clayton576d8832011-03-22 04:00:09 +0000299 bool
300 GetVContSupported (char flavor);
301
Jim Inghamcd16df92012-07-20 21:37:13 +0000302 bool
Sean Callananb1de1142013-09-04 23:24:15 +0000303 GetpPacketSupported (lldb::tid_t tid);
Hafiz Abid Qadeer9a78cdf2013-08-29 09:09:45 +0000304
305 bool
Jason Molendabdc4f122014-05-06 02:59:39 +0000306 GetxPacketSupported ();
307
308 bool
Jim Inghamcd16df92012-07-20 21:37:13 +0000309 GetVAttachOrWaitSupported ();
310
Jim Ingham279ceec2012-07-25 21:12:43 +0000311 bool
312 GetSyncThreadStateSupported();
313
Greg Clayton576d8832011-03-22 04:00:09 +0000314 void
315 ResetDiscoverableSettings();
316
317 bool
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000318 GetHostInfo (bool force = false);
Greg Clayton576d8832011-03-22 04:00:09 +0000319
320 bool
Greg Clayton1cb64962011-03-24 04:28:38 +0000321 GetOSVersion (uint32_t &major,
322 uint32_t &minor,
323 uint32_t &update);
324
325 bool
326 GetOSBuildString (std::string &s);
327
328 bool
329 GetOSKernelDescription (std::string &s);
330
331 lldb_private::ArchSpec
332 GetSystemArchitecture ();
333
334 bool
335 GetHostname (std::string &s);
336
Greg Clayton37a0a242012-04-11 00:24:49 +0000337 lldb::addr_t
338 GetShlibInfoAddr();
339
Greg Clayton1cb64962011-03-24 04:28:38 +0000340 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000341 GetSupportsThreadSuffix ();
342
343 bool
Greg Clayton32e0a752011-03-30 18:16:51 +0000344 GetProcessInfo (lldb::pid_t pid,
Greg Clayton8b82f082011-04-12 05:54:46 +0000345 lldb_private::ProcessInstanceInfo &process_info);
Greg Clayton32e0a752011-03-30 18:16:51 +0000346
347 uint32_t
Greg Clayton8b82f082011-04-12 05:54:46 +0000348 FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info,
349 lldb_private::ProcessInstanceInfoList &process_infos);
Greg Clayton32e0a752011-03-30 18:16:51 +0000350
351 bool
352 GetUserName (uint32_t uid, std::string &name);
353
354 bool
355 GetGroupName (uint32_t gid, std::string &name);
356
357 bool
Greg Clayton576d8832011-03-22 04:00:09 +0000358 HasFullVContSupport ()
359 {
360 return GetVContSupported ('A');
361 }
362
363 bool
364 HasAnyVContSupport ()
365 {
366 return GetVContSupported ('a');
367 }
368
Greg Clayton8b82f082011-04-12 05:54:46 +0000369 bool
370 GetStopReply (StringExtractorGDBRemote &response);
371
372 bool
Greg Claytonf402f782012-10-13 02:11:55 +0000373 GetThreadStopInfo (lldb::tid_t tid,
Greg Clayton8b82f082011-04-12 05:54:46 +0000374 StringExtractorGDBRemote &response);
375
376 bool
377 SupportsGDBStoppointPacket (GDBStoppointType type)
378 {
379 switch (type)
380 {
381 case eBreakpointSoftware: return m_supports_z0;
382 case eBreakpointHardware: return m_supports_z1;
383 case eWatchpointWrite: return m_supports_z2;
384 case eWatchpointRead: return m_supports_z3;
385 case eWatchpointReadWrite: return m_supports_z4;
Zachary Turner568b0de2015-02-18 18:44:03 +0000386 default: return false;
Greg Clayton8b82f082011-04-12 05:54:46 +0000387 }
Greg Clayton8b82f082011-04-12 05:54:46 +0000388 }
389 uint8_t
390 SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint
391 bool insert, // Insert or remove?
392 lldb::addr_t addr, // Address of breakpoint or watchpoint
393 uint32_t length); // Byte Size of breakpoint or watchpoint
394
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000395 void
396 TestPacketSpeed (const uint32_t num_packets);
397
398 // This packet is for testing the speed of the interface only. Both
399 // the client and server need to support it, but this allows us to
400 // measure the packet speed without any other work being done on the
401 // other end and avoids any of that work affecting the packet send
402 // and response times.
403 bool
404 SendSpeedTestPacket (uint32_t send_size,
405 uint32_t recv_size);
Greg Clayton8b82f082011-04-12 05:54:46 +0000406
407 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000408 SetCurrentThread (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000409
410 bool
Jason Molendae9ca4af2013-02-23 02:04:45 +0000411 SetCurrentThreadForRun (uint64_t tid);
Greg Clayton8b82f082011-04-12 05:54:46 +0000412
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000413 bool
Steve Pucci03904ac2014-03-04 23:18:46 +0000414 GetQXferAuxvReadSupported ();
415
416 bool
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000417 GetQXferLibrariesReadSupported ();
418
419 bool
420 GetQXferLibrariesSVR4ReadSupported ();
421
422 uint64_t
423 GetRemoteMaxPacketSize();
424
425 bool
426 GetAugmentedLibrariesSVR4ReadSupported ();
427
Greg Clayton2a48f522011-05-14 01:50:35 +0000428 lldb_private::LazyBool
Jim Ingham372787f2012-04-07 00:00:41 +0000429 SupportsAllocDeallocMemory () // const
Greg Clayton2a48f522011-05-14 01:50:35 +0000430 {
Jim Ingham372787f2012-04-07 00:00:41 +0000431 // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets.
432 // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo;
Greg Clayton70b57652011-05-15 01:25:55 +0000433 return m_supports_alloc_dealloc_memory;
Greg Clayton2a48f522011-05-14 01:50:35 +0000434 }
435
Greg Claytonadc00cb2011-05-20 23:38:13 +0000436 size_t
437 GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids,
438 bool &sequence_mutex_unavailable);
439
Greg Clayton2687cd12012-03-29 01:55:41 +0000440 bool
441 GetInterruptWasSent () const
442 {
443 return m_interrupt_sent;
444 }
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000445
Greg Claytonfbb76342013-11-20 21:07:01 +0000446 lldb::user_id_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000447 OpenFile (const lldb_private::FileSpec& file_spec,
448 uint32_t flags,
449 mode_t mode,
450 lldb_private::Error &error);
451
Greg Claytonfbb76342013-11-20 21:07:01 +0000452 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000453 CloseFile (lldb::user_id_t fd,
454 lldb_private::Error &error);
455
Greg Claytonfbb76342013-11-20 21:07:01 +0000456 lldb::user_id_t
Daniel Maleae0f8f572013-08-26 23:57:52 +0000457 GetFileSize (const lldb_private::FileSpec& file_spec);
458
Greg Claytonfbb76342013-11-20 21:07:01 +0000459 lldb_private::Error
460 GetFilePermissions(const char *path, uint32_t &file_permissions);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000461
Greg Claytonfbb76342013-11-20 21:07:01 +0000462 lldb_private::Error
463 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,
470 lldb_private::Error &error);
471
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,
477 lldb_private::Error &error);
478
Greg Claytonfbb76342013-11-20 21:07:01 +0000479 lldb_private::Error
480 CreateSymlink (const char *src,
481 const char *dst);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000482
Greg Claytonfbb76342013-11-20 21:07:01 +0000483 lldb_private::Error
484 Unlink (const char *path);
485
486 lldb_private::Error
487 MakeDirectory (const char *path,
488 uint32_t mode);
489
490 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000491 GetFileExists (const lldb_private::FileSpec& file_spec);
492
Greg Claytonfbb76342013-11-20 21:07:01 +0000493 lldb_private::Error
Daniel Maleae0f8f572013-08-26 23:57:52 +0000494 RunShellCommand (const char *command, // Shouldn't be NULL
495 const char *working_dir, // Pass NULL to use the current working directory
496 int *status_ptr, // Pass NULL if you don't want the process exit status
497 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
498 std::string *command_output, // Pass NULL if you don't want the command output
499 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
500
Greg Claytonfbb76342013-11-20 21:07:01 +0000501 bool
Daniel Maleae0f8f572013-08-26 23:57:52 +0000502 CalculateMD5 (const lldb_private::FileSpec& file_spec,
503 uint64_t &high,
504 uint64_t &low);
505
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000506 std::string
507 HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process,
508 StringExtractorGDBRemote &inputStringExtractor);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000509
Greg Claytonf74cf862013-11-13 23:28:31 +0000510 bool
511 ReadRegister(lldb::tid_t tid,
512 uint32_t reg_num,
513 StringExtractorGDBRemote &response);
514
515 bool
516 ReadAllRegisters (lldb::tid_t tid,
517 StringExtractorGDBRemote &response);
518
519 bool
520 SaveRegisterState (lldb::tid_t tid, uint32_t &save_id);
521
522 bool
523 RestoreRegisterState (lldb::tid_t tid, uint32_t save_id);
Jason Molendaa3329782014-03-29 18:54:20 +0000524
525 const char *
526 GetGDBServerProgramName();
Greg Claytonf74cf862013-11-13 23:28:31 +0000527
Jason Molendaa3329782014-03-29 18:54:20 +0000528 uint32_t
529 GetGDBServerProgramVersion();
530
531 bool
532 AvoidGPackets(ProcessGDBRemote *process);
533
Jason Molenda705b1802014-06-13 02:37:02 +0000534 bool
535 GetThreadExtendedInfoSupported();
536
Oleksiy Vyalov6801be32015-02-25 22:15:44 +0000537 bool
538 GetModuleInfo (const char* module_path,
539 const lldb_private::ArchSpec& arch_spec,
540 StringExtractorGDBRemote &response);
541
Greg Clayton576d8832011-03-22 04:00:09 +0000542protected:
543
Greg Clayton3dedae12013-12-06 21:45:27 +0000544 PacketResult
545 SendPacketAndWaitForResponseNoLock (const char *payload,
546 size_t payload_length,
547 StringExtractorGDBRemote &response);
548
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000549 bool
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000550 GetCurrentProcessInfo (bool allow_lazy_pid = true);
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000551
Jason Molendaa3329782014-03-29 18:54:20 +0000552 bool
553 GetGDBServerVersion();
554
Greg Clayton576d8832011-03-22 04:00:09 +0000555 //------------------------------------------------------------------
556 // Classes that inherit from GDBRemoteCommunicationClient can see and modify these
557 //------------------------------------------------------------------
Greg Claytone0d378b2011-03-24 21:19:54 +0000558 lldb_private::LazyBool m_supports_not_sending_acks;
559 lldb_private::LazyBool m_supports_thread_suffix;
Greg Clayton44633992012-04-10 03:22:03 +0000560 lldb_private::LazyBool m_supports_threads_in_stop_reply;
Greg Claytone0d378b2011-03-24 21:19:54 +0000561 lldb_private::LazyBool m_supports_vCont_all;
562 lldb_private::LazyBool m_supports_vCont_any;
563 lldb_private::LazyBool m_supports_vCont_c;
564 lldb_private::LazyBool m_supports_vCont_C;
565 lldb_private::LazyBool m_supports_vCont_s;
566 lldb_private::LazyBool m_supports_vCont_S;
Greg Clayton32e0a752011-03-30 18:16:51 +0000567 lldb_private::LazyBool m_qHostInfo_is_valid;
Todd Fiala9f72b3a2014-05-07 19:28:21 +0000568 lldb_private::LazyBool m_curr_pid_is_valid;
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000569 lldb_private::LazyBool m_qProcessInfo_is_valid;
Jason Molendaa3329782014-03-29 18:54:20 +0000570 lldb_private::LazyBool m_qGDBServerVersion_is_valid;
Greg Clayton70b57652011-05-15 01:25:55 +0000571 lldb_private::LazyBool m_supports_alloc_dealloc_memory;
Greg Clayton46fb5582011-11-18 07:03:08 +0000572 lldb_private::LazyBool m_supports_memory_region_info;
Johnny Chen64637202012-05-23 21:09:52 +0000573 lldb_private::LazyBool m_supports_watchpoint_support_info;
Jim Inghamacff8952013-05-02 00:27:30 +0000574 lldb_private::LazyBool m_supports_detach_stay_stopped;
Enrico Granataf04a2192012-07-13 23:18:48 +0000575 lldb_private::LazyBool m_watchpoints_trigger_after_instruction;
Jim Inghamcd16df92012-07-20 21:37:13 +0000576 lldb_private::LazyBool m_attach_or_wait_reply;
Jim Ingham279ceec2012-07-25 21:12:43 +0000577 lldb_private::LazyBool m_prepare_for_reg_writing_reply;
Hafiz Abid Qadeer9a78cdf2013-08-29 09:09:45 +0000578 lldb_private::LazyBool m_supports_p;
Jason Molendabdc4f122014-05-06 02:59:39 +0000579 lldb_private::LazyBool m_supports_x;
Jason Molendaa3329782014-03-29 18:54:20 +0000580 lldb_private::LazyBool m_avoid_g_packets;
Greg Claytonf74cf862013-11-13 23:28:31 +0000581 lldb_private::LazyBool m_supports_QSaveRegisterState;
Steve Pucci03904ac2014-03-04 23:18:46 +0000582 lldb_private::LazyBool m_supports_qXfer_auxv_read;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000583 lldb_private::LazyBool m_supports_qXfer_libraries_read;
584 lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read;
585 lldb_private::LazyBool m_supports_augmented_libraries_svr4_read;
Jason Molenda705b1802014-06-13 02:37:02 +0000586 lldb_private::LazyBool m_supports_jThreadExtendedInfo;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000587
Greg Clayton8b82f082011-04-12 05:54:46 +0000588 bool
589 m_supports_qProcessInfoPID:1,
590 m_supports_qfProcessInfo:1,
591 m_supports_qUserName:1,
592 m_supports_qGroupName:1,
593 m_supports_qThreadStopInfo:1,
594 m_supports_z0:1,
595 m_supports_z1:1,
596 m_supports_z2:1,
597 m_supports_z3:1,
Greg Clayton89600582013-10-10 17:53:50 +0000598 m_supports_z4:1,
599 m_supports_QEnvironment:1,
600 m_supports_QEnvironmentHexEncoded:1;
Greg Clayton2a48f522011-05-14 01:50:35 +0000601
Todd Fiala9f72b3a2014-05-07 19:28:21 +0000602 lldb::pid_t m_curr_pid;
Greg Clayton8b82f082011-04-12 05:54:46 +0000603 lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations
604 lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc
605
Greg Clayton576d8832011-03-22 04:00:09 +0000606
Johnny Chen64637202012-05-23 21:09:52 +0000607 uint32_t m_num_supported_hardware_watchpoints;
608
Greg Clayton576d8832011-03-22 04:00:09 +0000609 // If we need to send a packet while the target is running, the m_async_XXX
610 // member variables take care of making this happen.
611 lldb_private::Mutex m_async_mutex;
612 lldb_private::Predicate<bool> m_async_packet_predicate;
613 std::string m_async_packet;
Jim Inghama6195b72013-12-18 01:24:33 +0000614 PacketResult m_async_result;
Greg Clayton576d8832011-03-22 04:00:09 +0000615 StringExtractorGDBRemote m_async_response;
616 int m_async_signal; // We were asked to deliver a signal to the inferior process.
Greg Clayton2687cd12012-03-29 01:55:41 +0000617 bool m_interrupt_sent;
Han Ming Ong4b6459f2013-01-18 23:11:53 +0000618 std::string m_partial_profile_data;
619 std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
Greg Clayton576d8832011-03-22 04:00:09 +0000620
Greg Claytond314e812011-03-23 00:09:55 +0000621 lldb_private::ArchSpec m_host_arch;
Jason Molendaf17b5ac2012-12-19 02:54:03 +0000622 lldb_private::ArchSpec m_process_arch;
Greg Clayton1cb64962011-03-24 04:28:38 +0000623 uint32_t m_os_version_major;
624 uint32_t m_os_version_minor;
625 uint32_t m_os_version_update;
626 std::string m_os_build;
627 std::string m_os_kernel;
628 std::string m_hostname;
Jason Molendaa3329782014-03-29 18:54:20 +0000629 std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if qGDBServerVersion is not supported
630 uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if qGDBServerVersion is not supported
Greg Clayton9ac6d2d2013-10-25 18:13:17 +0000631 uint32_t m_default_packet_timeout;
Steve Pucci5ae54ae2014-01-25 05:46:51 +0000632 uint64_t m_max_packet_size; // as returned by qSupported
Greg Clayton576d8832011-03-22 04:00:09 +0000633
Greg Clayton32e0a752011-03-30 18:16:51 +0000634 bool
635 DecodeProcessInfoResponse (StringExtractorGDBRemote &response,
Greg Clayton8b82f082011-04-12 05:54:46 +0000636 lldb_private::ProcessInstanceInfo &process_info);
Greg Clayton576d8832011-03-22 04:00:09 +0000637private:
638 //------------------------------------------------------------------
639 // For GDBRemoteCommunicationClient only
640 //------------------------------------------------------------------
641 DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient);
642};
643
644#endif // liblldb_GDBRemoteCommunicationClient_h_