blob: 412b591e6ecc2acf0b7566885e1f84ff8d681164 [file] [log] [blame]
Greg Clayton576d8832011-03-22 04:00:09 +00001//===-- GDBRemoteCommunicationServer.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_GDBRemoteCommunicationServer_h_
11#define liblldb_GDBRemoteCommunicationServer_h_
12
13// C Includes
14// C++ Includes
Daniel Maleae0f8f572013-08-26 23:57:52 +000015#include <vector>
16#include <set>
Todd Fialaaf245d12014-06-30 21:05:18 +000017#include <unordered_map>
Greg Clayton576d8832011-03-22 04:00:09 +000018// Other libraries and framework includes
19// Project includes
Todd Fialaaf245d12014-06-30 21:05:18 +000020#include "lldb/lldb-private-forward.h"
21#include "lldb/Core/Communication.h"
Daniel Maleae0f8f572013-08-26 23:57:52 +000022#include "lldb/Host/Mutex.h"
Greg Clayton32e0a752011-03-30 18:16:51 +000023#include "lldb/Target/Process.h"
Greg Clayton576d8832011-03-22 04:00:09 +000024#include "GDBRemoteCommunication.h"
25
Todd Fialaaf245d12014-06-30 21:05:18 +000026#include "../../../Host/common/NativeProcessProtocol.h"
27
Greg Clayton576d8832011-03-22 04:00:09 +000028class ProcessGDBRemote;
Greg Clayton32e0a752011-03-30 18:16:51 +000029class StringExtractorGDBRemote;
Greg Clayton576d8832011-03-22 04:00:09 +000030
Todd Fialaaf245d12014-06-30 21:05:18 +000031class GDBRemoteCommunicationServer :
32 public GDBRemoteCommunication,
33 public lldb_private::NativeProcessProtocol::NativeDelegate
Greg Clayton576d8832011-03-22 04:00:09 +000034{
35public:
Greg Clayton29b8fc42013-11-21 01:44:58 +000036 typedef std::map<uint16_t, lldb::pid_t> PortMap;
37
Greg Clayton576d8832011-03-22 04:00:09 +000038 enum
39 {
40 eBroadcastBitRunPacketSent = kLoUserBroadcastBit
41 };
42 //------------------------------------------------------------------
43 // Constructors and Destructors
44 //------------------------------------------------------------------
Greg Clayton8b82f082011-04-12 05:54:46 +000045 GDBRemoteCommunicationServer(bool is_platform);
Greg Clayton576d8832011-03-22 04:00:09 +000046
Todd Fialab8b49ec2014-01-28 00:34:23 +000047 GDBRemoteCommunicationServer(bool is_platform,
Todd Fialaaf245d12014-06-30 21:05:18 +000048 const lldb::PlatformSP& platform_sp,
49 lldb::DebuggerSP& debugger_sp);
Todd Fialab8b49ec2014-01-28 00:34:23 +000050
Greg Clayton576d8832011-03-22 04:00:09 +000051 virtual
52 ~GDBRemoteCommunicationServer();
53
Todd Fialaaf245d12014-06-30 21:05:18 +000054 PacketResult
Greg Clayton73bf5db2011-06-17 01:22:15 +000055 GetPacketAndSendResponse (uint32_t timeout_usec,
Greg Clayton1cb64962011-03-24 04:28:38 +000056 lldb_private::Error &error,
Greg Claytond314e812011-03-23 00:09:55 +000057 bool &interrupt,
58 bool &quit);
Greg Clayton576d8832011-03-22 04:00:09 +000059
60 virtual bool
61 GetThreadSuffixSupported ()
62 {
63 return true;
64 }
65
Greg Clayton1cb64962011-03-24 04:28:38 +000066 // After connecting, do a little handshake with the client to make sure
67 // we are at least communicating
68 bool
69 HandshakeWithClient (lldb_private::Error *error_ptr);
Greg Clayton576d8832011-03-22 04:00:09 +000070
Greg Clayton8b82f082011-04-12 05:54:46 +000071 // Set both ports to zero to let the platform automatically bind to
72 // a port chosen by the OS.
73 void
Greg Clayton29b8fc42013-11-21 01:44:58 +000074 SetPortMap (PortMap &&port_map)
Greg Clayton8b82f082011-04-12 05:54:46 +000075 {
Greg Clayton29b8fc42013-11-21 01:44:58 +000076 m_port_map = port_map;
Daniel Maleae0f8f572013-08-26 23:57:52 +000077 }
78
Greg Clayton29b8fc42013-11-21 01:44:58 +000079 //----------------------------------------------------------------------
80 // If we are using a port map where we can only use certain ports,
81 // get the next available port.
82 //
83 // If we are using a port map and we are out of ports, return UINT16_MAX
84 //
85 // If we aren't using a port map, return 0 to indicate we should bind to
86 // port 0 and then figure out which port we used.
87 //----------------------------------------------------------------------
Daniel Maleae0f8f572013-08-26 23:57:52 +000088 uint16_t
Greg Clayton29b8fc42013-11-21 01:44:58 +000089 GetNextAvailablePort ()
Daniel Maleae0f8f572013-08-26 23:57:52 +000090 {
Greg Clayton29b8fc42013-11-21 01:44:58 +000091 if (m_port_map.empty())
92 return 0; // Bind to port zero and get a port, we didn't have any limitations
93
94 for (auto &pair : m_port_map)
95 {
96 if (pair.second == LLDB_INVALID_PROCESS_ID)
97 {
98 pair.second = ~(lldb::pid_t)LLDB_INVALID_PROCESS_ID;
99 return pair.first;
100 }
101 }
102 return UINT16_MAX;
103 }
104
105 bool
106 AssociatePortWithProcess (uint16_t port, lldb::pid_t pid)
107 {
108 PortMap::iterator pos = m_port_map.find(port);
109 if (pos != m_port_map.end())
110 {
111 pos->second = pid;
112 return true;
113 }
114 return false;
115 }
116
117 bool
118 FreePort (uint16_t port)
119 {
120 PortMap::iterator pos = m_port_map.find(port);
121 if (pos != m_port_map.end())
122 {
123 pos->second = LLDB_INVALID_PROCESS_ID;
124 return true;
125 }
126 return false;
127 }
128
129 bool
130 FreePortForProcess (lldb::pid_t pid)
131 {
132 if (!m_port_map.empty())
133 {
134 for (auto &pair : m_port_map)
135 {
136 if (pair.second == pid)
137 {
138 pair.second = LLDB_INVALID_PROCESS_ID;
139 return true;
140 }
141 }
142 }
143 return false;
Greg Clayton8b82f082011-04-12 05:54:46 +0000144 }
145
Greg Clayton2b98c562013-11-22 18:53:12 +0000146 void
147 SetPortOffset (uint16_t port_offset)
148 {
149 m_port_offset = port_offset;
150 }
151
Todd Fiala403edc52014-01-23 22:05:44 +0000152 //------------------------------------------------------------------
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000153 /// Specify the program to launch and its arguments.
Todd Fiala403edc52014-01-23 22:05:44 +0000154 ///
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000155 /// The LaunchProcess () command can be executed to do the lauching.
Todd Fiala403edc52014-01-23 22:05:44 +0000156 ///
157 /// @param[in] args
158 /// The command line to launch.
159 ///
160 /// @param[in] argc
161 /// The number of elements in the args array of cstring pointers.
162 ///
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000163 /// @return
164 /// An Error object indicating the success or failure of making
165 /// the setting.
166 //------------------------------------------------------------------
167 lldb_private::Error
168 SetLaunchArguments (const char *const args[], int argc);
169
170 //------------------------------------------------------------------
171 /// Specify the launch flags for the process.
172 ///
173 /// The LaunchProcess () command can be executed to do the lauching.
174 ///
Todd Fiala403edc52014-01-23 22:05:44 +0000175 /// @param[in] launch_flags
176 /// The launch flags to use when launching this process.
177 ///
178 /// @return
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000179 /// An Error object indicating the success or failure of making
180 /// the setting.
181 //------------------------------------------------------------------
182 lldb_private::Error
183 SetLaunchFlags (unsigned int launch_flags);
184
185 //------------------------------------------------------------------
186 /// Launch a process with the current launch settings.
187 ///
188 /// This method supports running an lldb-gdbserver or similar
189 /// server in a situation where the startup code has been provided
190 /// with all the information for a child process to be launched.
191 ///
192 /// @return
Todd Fiala403edc52014-01-23 22:05:44 +0000193 /// An Error object indicating the success or failure of the
194 /// launch.
195 //------------------------------------------------------------------
196 lldb_private::Error
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000197 LaunchProcess ();
Todd Fiala403edc52014-01-23 22:05:44 +0000198
Todd Fialaaf245d12014-06-30 21:05:18 +0000199 //------------------------------------------------------------------
200 /// Attach to a process.
201 ///
202 /// This method supports attaching llgs to a process accessible via the
203 /// configured Platform.
204 ///
205 /// @return
206 /// An Error object indicating the success or failure of the
207 /// attach operation.
208 //------------------------------------------------------------------
209 lldb_private::Error
210 AttachToProcess (lldb::pid_t pid);
211
212 //------------------------------------------------------------------
213 // NativeProcessProtocol::NativeDelegate overrides
214 //------------------------------------------------------------------
215 void
216 InitializeDelegate (lldb_private::NativeProcessProtocol *process) override;
217
218 void
219 ProcessStateChanged (lldb_private::NativeProcessProtocol *process, lldb::StateType state) override;
220
Greg Clayton576d8832011-03-22 04:00:09 +0000221protected:
Todd Fialab8b49ec2014-01-28 00:34:23 +0000222 lldb::PlatformSP m_platform_sp;
Greg Clayton576d8832011-03-22 04:00:09 +0000223 lldb::thread_t m_async_thread;
Greg Clayton8b82f082011-04-12 05:54:46 +0000224 lldb_private::ProcessLaunchInfo m_process_launch_info;
225 lldb_private::Error m_process_launch_error;
Daniel Maleae0f8f572013-08-26 23:57:52 +0000226 std::set<lldb::pid_t> m_spawned_pids;
227 lldb_private::Mutex m_spawned_pids_mutex;
Greg Clayton8b82f082011-04-12 05:54:46 +0000228 lldb_private::ProcessInstanceInfoList m_proc_infos;
Greg Clayton32e0a752011-03-30 18:16:51 +0000229 uint32_t m_proc_infos_index;
Greg Clayton29b8fc42013-11-21 01:44:58 +0000230 PortMap m_port_map;
Greg Clayton2b98c562013-11-22 18:53:12 +0000231 uint16_t m_port_offset;
Todd Fialaaf245d12014-06-30 21:05:18 +0000232 lldb::tid_t m_current_tid;
233 lldb::tid_t m_continue_tid;
234 lldb_private::Mutex m_debugged_process_mutex;
235 lldb_private::NativeProcessProtocolSP m_debugged_process_sp;
236 lldb::DebuggerSP m_debugger_sp;
237 Communication m_stdio_communication;
238 bool m_exit_now; // use in asynchronous handling to indicate process should exit.
239 lldb::StateType m_inferior_prev_state;
240 bool m_thread_suffix_supported;
241 bool m_list_threads_in_stop_reply;
242 lldb::DataBufferSP m_active_auxv_buffer_sp;
243 lldb_private::Mutex m_saved_registers_mutex;
244 std::unordered_map<uint32_t, lldb::DataBufferSP> m_saved_registers_map;
245 uint32_t m_next_saved_registers_id;
Greg Clayton576d8832011-03-22 04:00:09 +0000246
Greg Clayton3dedae12013-12-06 21:45:27 +0000247 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000248 SendUnimplementedResponse (const char *packet);
249
Greg Clayton3dedae12013-12-06 21:45:27 +0000250 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000251 SendErrorResponse (uint8_t error);
Greg Clayton576d8832011-03-22 04:00:09 +0000252
Greg Clayton3dedae12013-12-06 21:45:27 +0000253 PacketResult
Todd Fialaaf245d12014-06-30 21:05:18 +0000254 SendIllFormedResponse (const StringExtractorGDBRemote &packet, const char *error_message);
255
256 PacketResult
Greg Clayton1cb64962011-03-24 04:28:38 +0000257 SendOKResponse ();
Greg Clayton576d8832011-03-22 04:00:09 +0000258
Greg Clayton3dedae12013-12-06 21:45:27 +0000259 PacketResult
Todd Fialaaf245d12014-06-30 21:05:18 +0000260 SendONotification (const char *buffer, uint32_t len);
261
262 PacketResult
263 SendWResponse (lldb_private::NativeProcessProtocol *process);
264
265 PacketResult
266 SendStopReplyPacketForThread (lldb::tid_t tid);
267
268 PacketResult
269 SendStopReasonForState (lldb::StateType process_state, bool flush_on_exit);
270
271 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000272 Handle_A (StringExtractorGDBRemote &packet);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000273
Greg Clayton3dedae12013-12-06 21:45:27 +0000274 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000275 Handle_qLaunchSuccess (StringExtractorGDBRemote &packet);
276
Greg Clayton3dedae12013-12-06 21:45:27 +0000277 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000278 Handle_qHostInfo (StringExtractorGDBRemote &packet);
279
Greg Clayton3dedae12013-12-06 21:45:27 +0000280 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000281 Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000282
Greg Clayton3dedae12013-12-06 21:45:27 +0000283 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000284 Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet);
Greg Clayton8b82f082011-04-12 05:54:46 +0000285
Greg Clayton3dedae12013-12-06 21:45:27 +0000286 PacketResult
Todd Fiala403edc52014-01-23 22:05:44 +0000287 Handle_k (StringExtractorGDBRemote &packet);
288
289 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000290 Handle_qPlatform_mkdir (StringExtractorGDBRemote &packet);
291
Greg Clayton3dedae12013-12-06 21:45:27 +0000292 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000293 Handle_qPlatform_chmod (StringExtractorGDBRemote &packet);
Todd Fialaaf245d12014-06-30 21:05:18 +0000294
295 PacketResult
296 Handle_qProcessInfo (StringExtractorGDBRemote &packet);
297
Greg Clayton3dedae12013-12-06 21:45:27 +0000298 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000299 Handle_qProcessInfoPID (StringExtractorGDBRemote &packet);
300
Greg Clayton3dedae12013-12-06 21:45:27 +0000301 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000302 Handle_qfProcessInfo (StringExtractorGDBRemote &packet);
303
Greg Clayton3dedae12013-12-06 21:45:27 +0000304 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000305 Handle_qsProcessInfo (StringExtractorGDBRemote &packet);
306
Greg Clayton3dedae12013-12-06 21:45:27 +0000307 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000308 Handle_qC (StringExtractorGDBRemote &packet);
309
Greg Clayton3dedae12013-12-06 21:45:27 +0000310 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000311 Handle_qUserName (StringExtractorGDBRemote &packet);
312
Greg Clayton3dedae12013-12-06 21:45:27 +0000313 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000314 Handle_qGroupName (StringExtractorGDBRemote &packet);
Greg Clayton576d8832011-03-22 04:00:09 +0000315
Greg Clayton3dedae12013-12-06 21:45:27 +0000316 PacketResult
Greg Clayton9b1e1cd2011-04-04 18:18:57 +0000317 Handle_qSpeedTest (StringExtractorGDBRemote &packet);
318
Greg Clayton3dedae12013-12-06 21:45:27 +0000319 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000320 Handle_QEnvironment (StringExtractorGDBRemote &packet);
321
Greg Clayton3dedae12013-12-06 21:45:27 +0000322 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000323 Handle_QLaunchArch (StringExtractorGDBRemote &packet);
324
Greg Clayton3dedae12013-12-06 21:45:27 +0000325 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000326 Handle_QSetDisableASLR (StringExtractorGDBRemote &packet);
327
Greg Clayton3dedae12013-12-06 21:45:27 +0000328 PacketResult
Jim Ingham106d0282014-06-25 02:32:56 +0000329 Handle_QSetDetachOnError (StringExtractorGDBRemote &packet);
330
331 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000332 Handle_QSetWorkingDir (StringExtractorGDBRemote &packet);
Greg Claytonfbb76342013-11-20 21:07:01 +0000333
Greg Clayton3dedae12013-12-06 21:45:27 +0000334 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000335 Handle_qGetWorkingDir (StringExtractorGDBRemote &packet);
Greg Clayton8b82f082011-04-12 05:54:46 +0000336
Greg Clayton3dedae12013-12-06 21:45:27 +0000337 PacketResult
Greg Clayton32e0a752011-03-30 18:16:51 +0000338 Handle_QStartNoAckMode (StringExtractorGDBRemote &packet);
Greg Clayton1cb64962011-03-24 04:28:38 +0000339
Greg Clayton3dedae12013-12-06 21:45:27 +0000340 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000341 Handle_QSetSTDIN (StringExtractorGDBRemote &packet);
342
Greg Clayton3dedae12013-12-06 21:45:27 +0000343 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000344 Handle_QSetSTDOUT (StringExtractorGDBRemote &packet);
345
Greg Clayton3dedae12013-12-06 21:45:27 +0000346 PacketResult
Greg Clayton8b82f082011-04-12 05:54:46 +0000347 Handle_QSetSTDERR (StringExtractorGDBRemote &packet);
Todd Fialaaf245d12014-06-30 21:05:18 +0000348
349 PacketResult
350 Handle_C (StringExtractorGDBRemote &packet);
351
352 PacketResult
353 Handle_c (StringExtractorGDBRemote &packet, bool skip_file_pos_adjustment = false);
354
355 PacketResult
356 Handle_vCont (StringExtractorGDBRemote &packet);
357
358 PacketResult
359 Handle_vCont_actions (StringExtractorGDBRemote &packet);
360
361 PacketResult
362 Handle_stop_reason (StringExtractorGDBRemote &packet);
363
Greg Clayton3dedae12013-12-06 21:45:27 +0000364 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000365 Handle_vFile_Open (StringExtractorGDBRemote &packet);
366
Greg Clayton3dedae12013-12-06 21:45:27 +0000367 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000368 Handle_vFile_Close (StringExtractorGDBRemote &packet);
369
Greg Clayton3dedae12013-12-06 21:45:27 +0000370 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000371 Handle_vFile_pRead (StringExtractorGDBRemote &packet);
372
Greg Clayton3dedae12013-12-06 21:45:27 +0000373 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000374 Handle_vFile_pWrite (StringExtractorGDBRemote &packet);
375
Greg Clayton3dedae12013-12-06 21:45:27 +0000376 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000377 Handle_vFile_Size (StringExtractorGDBRemote &packet);
378
Greg Clayton3dedae12013-12-06 21:45:27 +0000379 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000380 Handle_vFile_Mode (StringExtractorGDBRemote &packet);
381
Greg Clayton3dedae12013-12-06 21:45:27 +0000382 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000383 Handle_vFile_Exists (StringExtractorGDBRemote &packet);
Greg Claytonfbb76342013-11-20 21:07:01 +0000384
Greg Clayton3dedae12013-12-06 21:45:27 +0000385 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000386 Handle_vFile_symlink (StringExtractorGDBRemote &packet);
387
Greg Clayton3dedae12013-12-06 21:45:27 +0000388 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000389 Handle_vFile_unlink (StringExtractorGDBRemote &packet);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000390
Greg Clayton3dedae12013-12-06 21:45:27 +0000391 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000392 Handle_vFile_Stat (StringExtractorGDBRemote &packet);
393
Greg Clayton3dedae12013-12-06 21:45:27 +0000394 PacketResult
Daniel Maleae0f8f572013-08-26 23:57:52 +0000395 Handle_vFile_MD5 (StringExtractorGDBRemote &packet);
396
Greg Clayton3dedae12013-12-06 21:45:27 +0000397 PacketResult
Greg Claytonfbb76342013-11-20 21:07:01 +0000398 Handle_qPlatform_shell (StringExtractorGDBRemote &packet);
Daniel Maleae0f8f572013-08-26 23:57:52 +0000399
Todd Fialaaf245d12014-06-30 21:05:18 +0000400 PacketResult
401 Handle_qRegisterInfo (StringExtractorGDBRemote &packet);
402
403 PacketResult
404 Handle_qfThreadInfo (StringExtractorGDBRemote &packet);
405
406 PacketResult
407 Handle_qsThreadInfo (StringExtractorGDBRemote &packet);
408
409 PacketResult
410 Handle_p (StringExtractorGDBRemote &packet);
411
412 PacketResult
413 Handle_P (StringExtractorGDBRemote &packet);
414
415 PacketResult
416 Handle_H (StringExtractorGDBRemote &packet);
417
418 PacketResult
419 Handle_interrupt (StringExtractorGDBRemote &packet);
420
421 PacketResult
422 Handle_m (StringExtractorGDBRemote &packet);
423
424 PacketResult
425 Handle_M (StringExtractorGDBRemote &packet);
426
427 PacketResult
428 Handle_qMemoryRegionInfoSupported (StringExtractorGDBRemote &packet);
429
430 PacketResult
431 Handle_qMemoryRegionInfo (StringExtractorGDBRemote &packet);
432
433 PacketResult
434 Handle_Z (StringExtractorGDBRemote &packet);
435
436 PacketResult
437 Handle_z (StringExtractorGDBRemote &packet);
438
439 PacketResult
440 Handle_s (StringExtractorGDBRemote &packet);
441
442 PacketResult
443 Handle_qSupported (StringExtractorGDBRemote &packet);
444
445 PacketResult
446 Handle_QThreadSuffixSupported (StringExtractorGDBRemote &packet);
447
448 PacketResult
449 Handle_QListThreadsInStopReply (StringExtractorGDBRemote &packet);
450
451 PacketResult
452 Handle_qXfer_auxv_read (StringExtractorGDBRemote &packet);
453
454 PacketResult
455 Handle_QSaveRegisterState (StringExtractorGDBRemote &packet);
456
457 PacketResult
458 Handle_QRestoreRegisterState (StringExtractorGDBRemote &packet);
459
Todd Fiala7306cf32014-07-29 22:30:01 +0000460 PacketResult
461 Handle_vAttach (StringExtractorGDBRemote &packet);
462
Todd Fialaaf245d12014-06-30 21:05:18 +0000463 void
464 SetCurrentThreadID (lldb::tid_t tid);
465
466 lldb::tid_t
467 GetCurrentThreadID () const;
468
469 void
470 SetContinueThreadID (lldb::tid_t tid);
471
472 lldb::tid_t
473 GetContinueThreadID () const { return m_continue_tid; }
474
475 lldb_private::Error
476 SetSTDIOFileDescriptor (int fd);
477
478 static void
479 STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
480
Greg Clayton576d8832011-03-22 04:00:09 +0000481private:
Daniel Maleae0f8f572013-08-26 23:57:52 +0000482 bool
483 DebugserverProcessReaped (lldb::pid_t pid);
484
485 static bool
486 ReapDebugserverProcess (void *callback_baton,
487 lldb::pid_t pid,
488 bool exited,
489 int signal,
490 int status);
491
Todd Fiala403edc52014-01-23 22:05:44 +0000492 bool
Todd Fiala3e92a2b2014-01-24 00:52:53 +0000493 DebuggedProcessReaped (lldb::pid_t pid);
494
495 static bool
496 ReapDebuggedProcess (void *callback_baton,
497 lldb::pid_t pid,
498 bool exited,
499 int signal,
500 int status);
501
502 bool
Todd Fiala403edc52014-01-23 22:05:44 +0000503 KillSpawnedProcess (lldb::pid_t pid);
504
Todd Fialaaf245d12014-06-30 21:05:18 +0000505 bool
506 IsGdbServer ()
507 {
508 return !m_is_platform;
509 }
510
511 /// Launch a process from lldb-gdbserver
512 lldb_private::Error
513 LaunchDebugServerProcess ();
514
515 /// Launch a process from lldb-platform
516 lldb_private::Error
517 LaunchPlatformProcess ();
518
519 void
520 HandleInferiorState_Exited (lldb_private::NativeProcessProtocol *process);
521
522 void
523 HandleInferiorState_Stopped (lldb_private::NativeProcessProtocol *process);
524
525 void
526 FlushInferiorOutput ();
527
528 lldb_private::NativeThreadProtocolSP
529 GetThreadFromSuffix (StringExtractorGDBRemote &packet);
530
531 uint32_t
532 GetNextSavedRegistersID ();
533
534 void
535 MaybeCloseInferiorTerminalConnection ();
536
Greg Clayton576d8832011-03-22 04:00:09 +0000537 //------------------------------------------------------------------
538 // For GDBRemoteCommunicationServer only
539 //------------------------------------------------------------------
540 DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer);
541};
542
543#endif // liblldb_GDBRemoteCommunicationServer_h_