blob: 815435c0f746a5daac640e97488d74276712bf54 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ProcessGDBRemote.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_ProcessGDBRemote_h_
11#define liblldb_ProcessGDBRemote_h_
12
13// C Includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000014// C++ Includes
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000015#include <atomic>
16#include <map>
17#include <string>
Greg Clayton71fc2a32011-02-12 06:28:37 +000018#include <vector>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019
20// Other libraries and framework includes
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000021// Project includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/Core/ArchSpec.h"
23#include "lldb/Core/Broadcaster.h"
Jason Molenda2e56a252013-05-11 03:09:05 +000024#include "lldb/Core/ConstString.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000025#include "lldb/Core/Error.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Core/StreamString.h"
Jim Ingham5aee1622010-08-09 23:31:02 +000027#include "lldb/Core/StringList.h"
Jason Molenda705b1802014-06-13 02:37:02 +000028#include "lldb/Core/StructuredData.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029#include "lldb/Core/ThreadSafeValue.h"
Stephane Sezer87b0fe02016-01-12 19:02:41 +000030#include "lldb/Core/LoadedModuleInfoList.h"
Zachary Turner39de3112014-09-09 20:54:56 +000031#include "lldb/Host/HostThread.h"
Todd Fiala4ceced32014-08-29 17:35:57 +000032#include "lldb/lldb-private-forward.h"
Pavel Labathf805e192015-07-07 10:08:41 +000033#include "lldb/Utility/StringExtractor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034#include "lldb/Target/Process.h"
35#include "lldb/Target/Thread.h"
36
Greg Clayton576d8832011-03-22 04:00:09 +000037#include "GDBRemoteCommunicationClient.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038#include "GDBRemoteRegisterContext.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039
Tamas Berghammerdb264a62015-03-31 09:52:22 +000040namespace lldb_private {
41namespace process_gdb_remote {
42
Chris Lattner30fdc8d2010-06-08 16:52:24 +000043class ThreadGDBRemote;
44
Tamas Berghammerdb264a62015-03-31 09:52:22 +000045class ProcessGDBRemote : public Process
Chris Lattner30fdc8d2010-06-08 16:52:24 +000046{
47public:
Jim Ingham583bbb12016-03-07 21:50:25 +000048 ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000049
50 ~ProcessGDBRemote() override;
51
Greg Claytonc3776bf2012-02-09 06:16:32 +000052 static lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +000053 CreateInstance (lldb::TargetSP target_sp,
Jim Ingham583bbb12016-03-07 21:50:25 +000054 lldb::ListenerSP listener_sp,
Tamas Berghammerdb264a62015-03-31 09:52:22 +000055 const FileSpec *crash_file_path);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000056
57 static void
58 Initialize();
59
60 static void
Tamas Berghammerdb264a62015-03-31 09:52:22 +000061 DebuggerInitialize (Debugger &debugger);
Greg Clayton7f982402013-07-15 22:54:20 +000062
63 static void
Chris Lattner30fdc8d2010-06-08 16:52:24 +000064 Terminate();
65
Tamas Berghammerdb264a62015-03-31 09:52:22 +000066 static ConstString
Chris Lattner30fdc8d2010-06-08 16:52:24 +000067 GetPluginNameStatic();
68
69 static const char *
70 GetPluginDescriptionStatic();
71
72 //------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073 // Check if a given Process
74 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000075 bool
Zachary Turner7529df92015-09-01 20:02:29 +000076 CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000077
Tamas Berghammerdb264a62015-03-31 09:52:22 +000078 CommandObject *
Eric Christopher7ab81b92014-11-04 03:13:17 +000079 GetPluginCommandObject() override;
Jim Ingham5aee1622010-08-09 23:31:02 +000080
Chris Lattner30fdc8d2010-06-08 16:52:24 +000081 //------------------------------------------------------------------
82 // Creating a new process, or attaching to an existing one
83 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +000084 Error
85 WillLaunch (Module* module) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000086
Tamas Berghammerdb264a62015-03-31 09:52:22 +000087 Error
88 DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000089
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000090 void
Eric Christopher7ab81b92014-11-04 03:13:17 +000091 DidLaunch () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000092
Tamas Berghammerdb264a62015-03-31 09:52:22 +000093 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000094 WillAttachToProcessWithID (lldb::pid_t pid) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095
Tamas Berghammerdb264a62015-03-31 09:52:22 +000096 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000097 WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000098
Tamas Berghammerdb264a62015-03-31 09:52:22 +000099 Error
100 DoConnectRemote (Stream *strm, const char *remote_url) override;
Greg Claytonb766a732011-02-04 01:58:07 +0000101
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000102 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000103 WillLaunchOrAttach ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000104
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000105 Error
106 DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) override;
Han Ming Ong84647042012-02-25 01:07:38 +0000107
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000108 Error
Han Ming Ong84647042012-02-25 01:07:38 +0000109 DoAttachToProcessWithName (const char *process_name,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000110 const ProcessAttachInfo &attach_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000111
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000112 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000113 DidAttach (ArchSpec &process_arch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000114
115 //------------------------------------------------------------------
116 // PluginInterface protocol
117 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000118 ConstString
Eric Christopher7ab81b92014-11-04 03:13:17 +0000119 GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000120
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000121 uint32_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000122 GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000124 //------------------------------------------------------------------
125 // Process Control
126 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000127 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000128 WillResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000129
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000130 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000131 DoResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000132
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000133 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000134 DoHalt (bool &caused_stop) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000135
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000136 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000137 DoDetach (bool keep_stopped) override;
Jim Ingham8af3b9c2013-03-29 01:18:12 +0000138
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000139 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000140 DetachRequiresHalt() override { return true; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000141
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000142 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000143 DoSignal (int signal) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000144
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000145 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000146 DoDestroy () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000147
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000148 void
Eric Christopher7ab81b92014-11-04 03:13:17 +0000149 RefreshStateAfterStop() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000150
Chaoren Linc963a222015-09-01 16:58:45 +0000151 void
152 SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
153
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000154 //------------------------------------------------------------------
155 // Process Queries
156 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000157 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000158 IsAlive () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000159
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000160 lldb::addr_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000161 GetImageInfoAddress() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000162
Greg Clayton2e309072015-07-17 23:42:28 +0000163 void
164 WillPublicStop () override;
165
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000166 //------------------------------------------------------------------
167 // Process Memory
168 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000169 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000170 DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000171
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000172 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000173 DoWriteMemory (lldb::addr_t addr, const void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000174
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000175 lldb::addr_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000176 DoAllocateMemory (size_t size, uint32_t permissions, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000177
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000178 Error
179 GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &region_info) override;
Greg Clayton46fb5582011-11-18 07:03:08 +0000180
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000181 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000182 DoDeallocateMemory (lldb::addr_t ptr) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000183
184 //------------------------------------------------------------------
185 // Process STDIO
186 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000187 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000188 PutSTDIN (const char *buf, size_t buf_size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000189
190 //----------------------------------------------------------------------
191 // Process Breakpoints
192 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000193 Error
194 EnableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000195
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000196 Error
197 DisableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000198
199 //----------------------------------------------------------------------
200 // Process Watchpoints
201 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000202 Error
203 EnableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000204
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000205 Error
206 DisableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000207
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000208 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000209 GetWatchpointSupportInfo (uint32_t &num) override;
Johnny Chen64637202012-05-23 21:09:52 +0000210
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000211 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000212 GetWatchpointSupportInfo (uint32_t &num, bool& after) override;
Enrico Granataf04a2192012-07-13 23:18:48 +0000213
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000214 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000215 StartNoticingNewThreads() override;
Jim Ingham1c823b42011-01-22 01:33:44 +0000216
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000217 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000218 StopNoticingNewThreads() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000219
Greg Claytonc1422c12012-04-09 22:46:21 +0000220 GDBRemoteCommunicationClient &
221 GetGDBRemote()
222 {
223 return m_gdb_comm;
224 }
Greg Claytonfbb76342013-11-20 21:07:01 +0000225
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000226 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000227 SendEventData(const char *data) override;
Jason Molendaa3329782014-03-29 18:54:20 +0000228
Greg Claytonfbb76342013-11-20 21:07:01 +0000229 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000230 // Override DidExit so we can disconnect from the remote GDB server
Greg Claytonfbb76342013-11-20 21:07:01 +0000231 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000232 void
233 DidExit () override;
Greg Claytonfbb76342013-11-20 21:07:01 +0000234
Jason Molenda6076bf42014-05-06 04:34:52 +0000235 void
236 SetUserSpecifiedMaxMemoryTransferSize (uint64_t user_specified_max);
237
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000238 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000239 GetModuleSpec(const FileSpec& module_file_spec,
240 const ArchSpec& arch,
241 ModuleSpec &module_spec) override;
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000242
Jim Ingham13c30d22015-11-05 22:33:17 +0000243 bool
244 GetHostOSVersion(uint32_t &major,
245 uint32_t &minor,
246 uint32_t &update) override;
247
Tamas Berghammer783bfc82015-06-18 20:43:56 +0000248 size_t
Stephane Sezer87b0fe02016-01-12 19:02:41 +0000249 LoadModules(LoadedModuleInfoList &module_list) override;
250
251 size_t
Tamas Berghammer783bfc82015-06-18 20:43:56 +0000252 LoadModules() override;
253
254 Error
255 GetFileLoadAddress(const FileSpec& file, bool& is_loaded, lldb::addr_t& load_addr) override;
Colin Rileyc3c95b22015-04-16 15:51:33 +0000256
Greg Clayton0b90be12015-06-23 21:27:50 +0000257 void
258 ModulesDidLoad (ModuleList &module_list) override;
259
Jason Molenda20ee21b2015-07-10 23:15:22 +0000260 StructuredData::ObjectSP
261 GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_address, lldb::addr_t image_count) override;
262
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000263protected:
264 friend class ThreadGDBRemote;
Greg Clayton576d8832011-03-22 04:00:09 +0000265 friend class GDBRemoteCommunicationClient;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000266 friend class GDBRemoteRegisterContext;
267
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000268 //------------------------------------------------------------------
269 /// Broadcaster event bits definitions.
270 //------------------------------------------------------------------
271 enum
272 {
273 eBroadcastBitAsyncContinue = (1 << 0),
274 eBroadcastBitAsyncThreadShouldExit = (1 << 1),
275 eBroadcastBitAsyncThreadDidExit = (1 << 2)
276 };
277
278 Flags m_flags; // Process specific flags (see eFlags enums)
279 GDBRemoteCommunicationClient m_gdb_comm;
280 std::atomic<lldb::pid_t> m_debugserver_pid;
281 std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable
282 Mutex m_last_stop_packet_mutex;
283 GDBRemoteDynamicRegisterInfo m_register_info;
284 Broadcaster m_async_broadcaster;
Jim Ingham583bbb12016-03-07 21:50:25 +0000285 lldb::ListenerSP m_async_listener_sp;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000286 HostThread m_async_thread;
287 Mutex m_async_thread_state_mutex;
288 typedef std::vector<lldb::tid_t> tid_collection;
289 typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection;
290 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
291 typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
292 tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping
Jason Molenda545304d2015-12-18 00:45:35 +0000293 std::vector<lldb::addr_t> m_thread_pcs; // PC values for all the threads.
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000294 StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos
295 StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported
296 tid_collection m_continue_c_tids; // 'c' for continue
297 tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
298 tid_collection m_continue_s_tids; // 's' for step
299 tid_sig_collection m_continue_S_tids; // 'S' for step with signal
300 uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory
301 uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle
302 MMapMap m_addr_to_mmap_size;
303 lldb::BreakpointSP m_thread_create_bp_sp;
304 bool m_waiting_for_attach;
305 bool m_destroy_tried_resuming;
306 lldb::CommandObjectSP m_command_sp;
307 int64_t m_breakpoint_pc_offset;
308 lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
309
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000310 //----------------------------------------------------------------------
311 // Accessors
312 //----------------------------------------------------------------------
313 bool
314 IsRunning ( lldb::StateType state )
315 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000316 return state == lldb::eStateRunning || IsStepping(state);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000317 }
318
319 bool
320 IsStepping ( lldb::StateType state)
321 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000322 return state == lldb::eStateStepping;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000323 }
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000324
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000325 bool
326 CanResume ( lldb::StateType state)
327 {
328 return state == lldb::eStateStopped;
329 }
330
331 bool
332 HasExited (lldb::StateType state)
333 {
334 return state == lldb::eStateExited;
335 }
336
337 bool
338 ProcessIDIsValid ( ) const;
339
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000340 void
341 Clear ( );
342
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000343 Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000344 GetFlags ()
345 {
346 return m_flags;
347 }
348
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000349 const Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000350 GetFlags () const
351 {
352 return m_flags;
353 }
354
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000355 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000356 UpdateThreadList (ThreadList &old_thread_list,
357 ThreadList &new_thread_list) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000358
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000359 Error
Oleksiy Vyalovafd6ce42015-11-23 19:32:24 +0000360 EstablishConnectionIfNeeded (const ProcessInfo &process_info);
361
362 Error
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000363 LaunchAndConnectToDebugserver (const ProcessInfo &process_info);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000364
365 void
366 KillDebugserverProcess ();
367
368 void
Greg Clayton513c26c2011-01-29 07:10:55 +0000369 BuildDynamicRegisterInfo (bool force);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000370
Greg Clayton09c3e3d2011-12-06 04:51:14 +0000371 void
Greg Clayton8cda7f02013-05-21 21:55:59 +0000372 SetLastStopPacket (const StringExtractorGDBRemote &response);
Jason Molendad1fae142012-09-29 08:03:33 +0000373
Greg Claytonef8180a2013-10-15 00:14:28 +0000374 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000375 ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
Greg Claytonef8180a2013-10-15 00:14:28 +0000376
Todd Fialaaf245d12014-06-30 21:05:18 +0000377 const lldb::DataBufferSP
378 GetAuxvData() override;
Steve Pucci03904ac2014-03-04 23:18:46 +0000379
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000380 StructuredData::ObjectSP
Jason Molenda705b1802014-06-13 02:37:02 +0000381 GetExtendedInfoForThread (lldb::tid_t tid);
382
Jason Molenda6076bf42014-05-06 04:34:52 +0000383 void
384 GetMaxMemorySize();
385
Greg Clayton358cf1e2015-06-25 21:46:34 +0000386 bool
387 CalculateThreadStopInfo (ThreadGDBRemote *thread);
388
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000389 size_t
Jason Molenda545304d2015-12-18 00:45:35 +0000390 UpdateThreadPCsFromStopReplyThreadsValue (std::string &value);
391
392 size_t
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000393 UpdateThreadIDsFromStopReplyThreadsValue (std::string &value);
394
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000395 bool
Ewan Crawford76df2882015-06-23 12:32:06 +0000396 HandleNotifyPacket(StringExtractorGDBRemote &packet);
397
398 bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000399 StartAsyncThread ();
400
401 void
402 StopAsyncThread ();
403
Virgile Bellob2f1fb22013-08-23 12:44:05 +0000404 static lldb::thread_result_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000405 AsyncThread (void *arg);
406
407 static bool
Pavel Labath194357c2016-05-12 11:10:01 +0000408 MonitorDebugserverProcess(std::weak_ptr<ProcessGDBRemote> process_wp, lldb::pid_t pid, bool exited, int signo,
409 int exit_status);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000410
411 lldb::StateType
412 SetThreadStopInfo (StringExtractor& stop_packet);
413
Greg Clayton2e309072015-07-17 23:42:28 +0000414 bool
415 GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp);
416
417 lldb::ThreadSP
Greg Clayton358cf1e2015-06-25 21:46:34 +0000418 SetThreadStopInfo (StructuredData::Dictionary *thread_dict);
419
420 lldb::ThreadSP
421 SetThreadStopInfo (lldb::tid_t tid,
422 ExpeditedRegisterMap &expedited_register_map,
423 uint8_t signo,
424 const std::string &thread_name,
425 const std::string &reason,
426 const std::string &description,
427 uint32_t exc_type,
428 const std::vector<lldb::addr_t> &exc_data,
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000429 lldb::addr_t thread_dispatch_qaddr,
430 bool queue_vars_valid,
Jason Molenda77f89352016-01-12 07:09:16 +0000431 lldb_private::LazyBool associated_with_libdispatch_queue,
432 lldb::addr_t dispatch_queue_t,
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000433 std::string &queue_name,
434 lldb::QueueKind queue_kind,
435 uint64_t queue_serial);
Greg Clayton358cf1e2015-06-25 21:46:34 +0000436
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000437 void
Ewan Crawford78baa192015-05-13 09:18:18 +0000438 HandleStopReplySequence ();
439
440 void
Greg Clayton9e920902012-04-10 02:25:43 +0000441 ClearThreadIDList ();
442
443 bool
444 UpdateThreadIDList ();
445
446 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000447 DidLaunchOrAttach (ArchSpec& process_arch);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000448
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000449 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000450 ConnectToDebugserver (const char *host_port);
451
452 const char *
453 GetDispatchQueueNameForThread (lldb::addr_t thread_dispatch_qaddr,
454 std::string &dispatch_queue_name);
455
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000456 DynamicLoader *
Eric Christopher7ab81b92014-11-04 03:13:17 +0000457 GetDynamicLoader () override;
Jason Molenda5e8534e2012-10-03 01:29:34 +0000458
Aidan Doddsc0c83852015-05-08 09:36:31 +0000459 // Query remote GDBServer for register information
460 bool
Jim Ingham7b71c0b2016-02-18 23:58:45 +0000461 GetGDBServerRegisterInfo (ArchSpec &arch);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000462
463 // Query remote GDBServer for a detailed loaded library list
464 Error
Stephane Sezer87b0fe02016-01-12 19:02:41 +0000465 GetLoadedModuleList (LoadedModuleInfoList &);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000466
467 lldb::ModuleSP
Stephane Sezer3553c0e2016-04-05 17:25:32 +0000468 LoadModuleAtAddress (const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr,
469 bool value_is_offset);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000470
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000471private:
472 //------------------------------------------------------------------
473 // For ProcessGDBRemote only
474 //------------------------------------------------------------------
Jim Ingham1c823b42011-01-22 01:33:44 +0000475 static bool
476 NewThreadNotifyBreakpointHit (void *baton,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000477 StoppointCallbackContext *context,
Jim Ingham1c823b42011-01-22 01:33:44 +0000478 lldb::user_id_t break_id,
479 lldb::user_id_t break_loc_id);
480
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000481 DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000482};
483
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000484} // namespace process_gdb_remote
485} // namespace lldb_private
486
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000487#endif // liblldb_ProcessGDBRemote_h_