blob: b974db684f63f209f98ea96368c0909c64cfaf55 [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>
Saleem Abdulrasool16ff8602016-05-18 01:59:10 +000017#include <mutex>
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000018#include <string>
Greg Clayton71fc2a32011-02-12 06:28:37 +000019#include <vector>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020
21// Other libraries and framework includes
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000022// Project includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023#include "lldb/Core/ArchSpec.h"
24#include "lldb/Core/Broadcaster.h"
Jason Molenda2e56a252013-05-11 03:09:05 +000025#include "lldb/Core/ConstString.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Core/Error.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027#include "lldb/Core/StreamString.h"
Jim Ingham5aee1622010-08-09 23:31:02 +000028#include "lldb/Core/StringList.h"
Jason Molenda705b1802014-06-13 02:37:02 +000029#include "lldb/Core/StructuredData.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000030#include "lldb/Core/ThreadSafeValue.h"
Stephane Sezer87b0fe02016-01-12 19:02:41 +000031#include "lldb/Core/LoadedModuleInfoList.h"
Zachary Turner39de3112014-09-09 20:54:56 +000032#include "lldb/Host/HostThread.h"
Todd Fiala4ceced32014-08-29 17:35:57 +000033#include "lldb/lldb-private-forward.h"
Pavel Labathf805e192015-07-07 10:08:41 +000034#include "lldb/Utility/StringExtractor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000035#include "lldb/Target/Process.h"
36#include "lldb/Target/Thread.h"
37
Greg Clayton576d8832011-03-22 04:00:09 +000038#include "GDBRemoteCommunicationClient.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039#include "GDBRemoteRegisterContext.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000040
Tamas Berghammerdb264a62015-03-31 09:52:22 +000041namespace lldb_private {
42namespace process_gdb_remote {
43
Chris Lattner30fdc8d2010-06-08 16:52:24 +000044class ThreadGDBRemote;
45
Pavel Labath4cb69922016-07-29 15:41:52 +000046class ProcessGDBRemote : public Process
Chris Lattner30fdc8d2010-06-08 16:52:24 +000047{
48public:
Jim Ingham583bbb12016-03-07 21:50:25 +000049 ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000050
51 ~ProcessGDBRemote() override;
52
Greg Claytonc3776bf2012-02-09 06:16:32 +000053 static lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +000054 CreateInstance (lldb::TargetSP target_sp,
Jim Ingham583bbb12016-03-07 21:50:25 +000055 lldb::ListenerSP listener_sp,
Tamas Berghammerdb264a62015-03-31 09:52:22 +000056 const FileSpec *crash_file_path);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000057
58 static void
59 Initialize();
60
61 static void
Tamas Berghammerdb264a62015-03-31 09:52:22 +000062 DebuggerInitialize (Debugger &debugger);
Greg Clayton7f982402013-07-15 22:54:20 +000063
64 static void
Chris Lattner30fdc8d2010-06-08 16:52:24 +000065 Terminate();
66
Tamas Berghammerdb264a62015-03-31 09:52:22 +000067 static ConstString
Chris Lattner30fdc8d2010-06-08 16:52:24 +000068 GetPluginNameStatic();
69
70 static const char *
71 GetPluginDescriptionStatic();
72
73 //------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +000074 // Check if a given Process
75 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000076 bool
Zachary Turner7529df92015-09-01 20:02:29 +000077 CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000078
Tamas Berghammerdb264a62015-03-31 09:52:22 +000079 CommandObject *
Eric Christopher7ab81b92014-11-04 03:13:17 +000080 GetPluginCommandObject() override;
Jim Ingham5aee1622010-08-09 23:31:02 +000081
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082 //------------------------------------------------------------------
83 // Creating a new process, or attaching to an existing one
84 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +000085 Error
86 WillLaunch (Module* module) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000087
Tamas Berghammerdb264a62015-03-31 09:52:22 +000088 Error
89 DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000090
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000091 void
Eric Christopher7ab81b92014-11-04 03:13:17 +000092 DidLaunch () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000093
Tamas Berghammerdb264a62015-03-31 09:52:22 +000094 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000095 WillAttachToProcessWithID (lldb::pid_t pid) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000096
Tamas Berghammerdb264a62015-03-31 09:52:22 +000097 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000098 WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000100 Error
101 DoConnectRemote (Stream *strm, const char *remote_url) override;
Greg Claytonb766a732011-02-04 01:58:07 +0000102
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000103 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000104 WillLaunchOrAttach ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000105
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000106 Error
107 DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) override;
Han Ming Ong84647042012-02-25 01:07:38 +0000108
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000109 Error
Han Ming Ong84647042012-02-25 01:07:38 +0000110 DoAttachToProcessWithName (const char *process_name,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000111 const ProcessAttachInfo &attach_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000112
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000113 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000114 DidAttach (ArchSpec &process_arch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115
116 //------------------------------------------------------------------
117 // PluginInterface protocol
118 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000119 ConstString
Eric Christopher7ab81b92014-11-04 03:13:17 +0000120 GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000121
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000122 uint32_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000123 GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000124
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000125 //------------------------------------------------------------------
126 // Process Control
127 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000128 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000129 WillResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000130
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000131 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000132 DoResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000133
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000134 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000135 DoHalt (bool &caused_stop) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000136
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000137 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000138 DoDetach (bool keep_stopped) override;
Jim Ingham8af3b9c2013-03-29 01:18:12 +0000139
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000140 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000141 DetachRequiresHalt() override { return true; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000142
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000143 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000144 DoSignal (int signal) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000145
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000146 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000147 DoDestroy () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000148
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000149 void
Eric Christopher7ab81b92014-11-04 03:13:17 +0000150 RefreshStateAfterStop() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000151
Chaoren Linc963a222015-09-01 16:58:45 +0000152 void
153 SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
154
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000155 //------------------------------------------------------------------
156 // Process Queries
157 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000158 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000159 IsAlive () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000160
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000161 lldb::addr_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000162 GetImageInfoAddress() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000163
Greg Clayton2e309072015-07-17 23:42:28 +0000164 void
165 WillPublicStop () override;
166
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000167 //------------------------------------------------------------------
168 // Process Memory
169 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000170 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000171 DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000172
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000173 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000174 DoWriteMemory (lldb::addr_t addr, const void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000175
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000176 lldb::addr_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000177 DoAllocateMemory (size_t size, uint32_t permissions, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000178
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000179 Error
180 GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &region_info) override;
Greg Clayton46fb5582011-11-18 07:03:08 +0000181
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000182 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000183 DoDeallocateMemory (lldb::addr_t ptr) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000184
185 //------------------------------------------------------------------
186 // Process STDIO
187 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000188 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000189 PutSTDIN (const char *buf, size_t buf_size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000190
191 //----------------------------------------------------------------------
192 // Process Breakpoints
193 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000194 Error
195 EnableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000196
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000197 Error
198 DisableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000199
200 //----------------------------------------------------------------------
201 // Process Watchpoints
202 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000203 Error
204 EnableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000205
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000206 Error
207 DisableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000208
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000209 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000210 GetWatchpointSupportInfo (uint32_t &num) override;
Johnny Chen64637202012-05-23 21:09:52 +0000211
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000212 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000213 GetWatchpointSupportInfo (uint32_t &num, bool& after) override;
Enrico Granataf04a2192012-07-13 23:18:48 +0000214
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000215 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000216 StartNoticingNewThreads() override;
Jim Ingham1c823b42011-01-22 01:33:44 +0000217
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000218 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000219 StopNoticingNewThreads() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000220
Greg Claytonc1422c12012-04-09 22:46:21 +0000221 GDBRemoteCommunicationClient &
222 GetGDBRemote()
223 {
224 return m_gdb_comm;
225 }
Greg Claytonfbb76342013-11-20 21:07:01 +0000226
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000227 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000228 SendEventData(const char *data) override;
Jason Molendaa3329782014-03-29 18:54:20 +0000229
Greg Claytonfbb76342013-11-20 21:07:01 +0000230 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000231 // Override DidExit so we can disconnect from the remote GDB server
Greg Claytonfbb76342013-11-20 21:07:01 +0000232 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000233 void
234 DidExit () override;
Greg Claytonfbb76342013-11-20 21:07:01 +0000235
Jason Molenda6076bf42014-05-06 04:34:52 +0000236 void
237 SetUserSpecifiedMaxMemoryTransferSize (uint64_t user_specified_max);
238
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000239 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000240 GetModuleSpec(const FileSpec& module_file_spec,
241 const ArchSpec& arch,
242 ModuleSpec &module_spec) override;
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000243
Jim Ingham13c30d22015-11-05 22:33:17 +0000244 bool
245 GetHostOSVersion(uint32_t &major,
246 uint32_t &minor,
247 uint32_t &update) override;
248
Tamas Berghammer783bfc82015-06-18 20:43:56 +0000249 size_t
Stephane Sezer87b0fe02016-01-12 19:02:41 +0000250 LoadModules(LoadedModuleInfoList &module_list) override;
251
252 size_t
Tamas Berghammer783bfc82015-06-18 20:43:56 +0000253 LoadModules() override;
254
255 Error
256 GetFileLoadAddress(const FileSpec& file, bool& is_loaded, lldb::addr_t& load_addr) override;
Colin Rileyc3c95b22015-04-16 15:51:33 +0000257
Greg Clayton0b90be12015-06-23 21:27:50 +0000258 void
259 ModulesDidLoad (ModuleList &module_list) override;
260
Jason Molenda20ee21b2015-07-10 23:15:22 +0000261 StructuredData::ObjectSP
262 GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_address, lldb::addr_t image_count) override;
263
Jason Molenda9ab5dc22016-07-21 08:30:55 +0000264 StructuredData::ObjectSP
265 GetLoadedDynamicLibrariesInfos () override;
266
267 StructuredData::ObjectSP
268 GetLoadedDynamicLibrariesInfos (const std::vector<lldb::addr_t> &load_addresses) override;
269
270 StructuredData::ObjectSP
271 GetLoadedDynamicLibrariesInfos_sender (StructuredData::ObjectSP args);
272
Jason Molenda37397352016-07-22 00:17:55 +0000273 StructuredData::ObjectSP
274 GetSharedCacheInfo () override;
275
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000276protected:
277 friend class ThreadGDBRemote;
Greg Clayton576d8832011-03-22 04:00:09 +0000278 friend class GDBRemoteCommunicationClient;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000279 friend class GDBRemoteRegisterContext;
280
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000281 //------------------------------------------------------------------
282 /// Broadcaster event bits definitions.
283 //------------------------------------------------------------------
284 enum
285 {
286 eBroadcastBitAsyncContinue = (1 << 0),
287 eBroadcastBitAsyncThreadShouldExit = (1 << 1),
288 eBroadcastBitAsyncThreadDidExit = (1 << 2)
289 };
290
291 Flags m_flags; // Process specific flags (see eFlags enums)
292 GDBRemoteCommunicationClient m_gdb_comm;
293 std::atomic<lldb::pid_t> m_debugserver_pid;
294 std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable
Saleem Abdulrasool16ff8602016-05-18 01:59:10 +0000295 std::recursive_mutex m_last_stop_packet_mutex;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000296 GDBRemoteDynamicRegisterInfo m_register_info;
297 Broadcaster m_async_broadcaster;
Jim Ingham583bbb12016-03-07 21:50:25 +0000298 lldb::ListenerSP m_async_listener_sp;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000299 HostThread m_async_thread;
Saleem Abdulrasool16ff8602016-05-18 01:59:10 +0000300 std::recursive_mutex m_async_thread_state_mutex;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000301 typedef std::vector<lldb::tid_t> tid_collection;
302 typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection;
303 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
304 typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
305 tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping
Jason Molenda545304d2015-12-18 00:45:35 +0000306 std::vector<lldb::addr_t> m_thread_pcs; // PC values for all the threads.
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000307 StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos
308 StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported
309 tid_collection m_continue_c_tids; // 'c' for continue
310 tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
311 tid_collection m_continue_s_tids; // 's' for step
312 tid_sig_collection m_continue_S_tids; // 'S' for step with signal
313 uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory
314 uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle
315 MMapMap m_addr_to_mmap_size;
316 lldb::BreakpointSP m_thread_create_bp_sp;
317 bool m_waiting_for_attach;
318 bool m_destroy_tried_resuming;
319 lldb::CommandObjectSP m_command_sp;
320 int64_t m_breakpoint_pc_offset;
321 lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
322
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000323 //----------------------------------------------------------------------
324 // Accessors
325 //----------------------------------------------------------------------
326 bool
327 IsRunning ( lldb::StateType state )
328 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000329 return state == lldb::eStateRunning || IsStepping(state);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000330 }
331
332 bool
333 IsStepping ( lldb::StateType state)
334 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000335 return state == lldb::eStateStepping;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000336 }
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000337
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000338 bool
339 CanResume ( lldb::StateType state)
340 {
341 return state == lldb::eStateStopped;
342 }
343
344 bool
345 HasExited (lldb::StateType state)
346 {
347 return state == lldb::eStateExited;
348 }
349
350 bool
351 ProcessIDIsValid ( ) const;
352
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000353 void
354 Clear ( );
355
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000356 Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000357 GetFlags ()
358 {
359 return m_flags;
360 }
361
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000362 const Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000363 GetFlags () const
364 {
365 return m_flags;
366 }
367
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000368 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000369 UpdateThreadList (ThreadList &old_thread_list,
370 ThreadList &new_thread_list) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000371
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000372 Error
Oleksiy Vyalovafd6ce42015-11-23 19:32:24 +0000373 EstablishConnectionIfNeeded (const ProcessInfo &process_info);
374
375 Error
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000376 LaunchAndConnectToDebugserver (const ProcessInfo &process_info);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377
378 void
379 KillDebugserverProcess ();
380
381 void
Greg Clayton513c26c2011-01-29 07:10:55 +0000382 BuildDynamicRegisterInfo (bool force);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000383
Greg Clayton09c3e3d2011-12-06 04:51:14 +0000384 void
Greg Clayton8cda7f02013-05-21 21:55:59 +0000385 SetLastStopPacket (const StringExtractorGDBRemote &response);
Jason Molendad1fae142012-09-29 08:03:33 +0000386
Greg Claytonef8180a2013-10-15 00:14:28 +0000387 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000388 ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
Greg Claytonef8180a2013-10-15 00:14:28 +0000389
Todd Fialaaf245d12014-06-30 21:05:18 +0000390 const lldb::DataBufferSP
391 GetAuxvData() override;
Steve Pucci03904ac2014-03-04 23:18:46 +0000392
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000393 StructuredData::ObjectSP
Jason Molenda705b1802014-06-13 02:37:02 +0000394 GetExtendedInfoForThread (lldb::tid_t tid);
395
Jason Molenda6076bf42014-05-06 04:34:52 +0000396 void
397 GetMaxMemorySize();
398
Greg Clayton358cf1e2015-06-25 21:46:34 +0000399 bool
400 CalculateThreadStopInfo (ThreadGDBRemote *thread);
401
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000402 size_t
Jason Molenda545304d2015-12-18 00:45:35 +0000403 UpdateThreadPCsFromStopReplyThreadsValue (std::string &value);
404
405 size_t
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000406 UpdateThreadIDsFromStopReplyThreadsValue (std::string &value);
407
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000408 bool
Ewan Crawford76df2882015-06-23 12:32:06 +0000409 HandleNotifyPacket(StringExtractorGDBRemote &packet);
410
411 bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000412 StartAsyncThread ();
413
414 void
415 StopAsyncThread ();
416
Virgile Bellob2f1fb22013-08-23 12:44:05 +0000417 static lldb::thread_result_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000418 AsyncThread (void *arg);
419
420 static bool
Pavel Labath194357c2016-05-12 11:10:01 +0000421 MonitorDebugserverProcess(std::weak_ptr<ProcessGDBRemote> process_wp, lldb::pid_t pid, bool exited, int signo,
422 int exit_status);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000423
424 lldb::StateType
425 SetThreadStopInfo (StringExtractor& stop_packet);
426
Greg Clayton2e309072015-07-17 23:42:28 +0000427 bool
428 GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp);
429
430 lldb::ThreadSP
Greg Clayton358cf1e2015-06-25 21:46:34 +0000431 SetThreadStopInfo (StructuredData::Dictionary *thread_dict);
432
433 lldb::ThreadSP
434 SetThreadStopInfo (lldb::tid_t tid,
435 ExpeditedRegisterMap &expedited_register_map,
436 uint8_t signo,
437 const std::string &thread_name,
438 const std::string &reason,
439 const std::string &description,
440 uint32_t exc_type,
441 const std::vector<lldb::addr_t> &exc_data,
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000442 lldb::addr_t thread_dispatch_qaddr,
443 bool queue_vars_valid,
Jason Molenda77f89352016-01-12 07:09:16 +0000444 lldb_private::LazyBool associated_with_libdispatch_queue,
445 lldb::addr_t dispatch_queue_t,
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000446 std::string &queue_name,
447 lldb::QueueKind queue_kind,
448 uint64_t queue_serial);
Greg Clayton358cf1e2015-06-25 21:46:34 +0000449
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000450 void
Ewan Crawford78baa192015-05-13 09:18:18 +0000451 HandleStopReplySequence ();
452
453 void
Greg Clayton9e920902012-04-10 02:25:43 +0000454 ClearThreadIDList ();
455
456 bool
457 UpdateThreadIDList ();
458
459 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000460 DidLaunchOrAttach (ArchSpec& process_arch);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000461
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000462 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000463 ConnectToDebugserver (const char *host_port);
464
465 const char *
466 GetDispatchQueueNameForThread (lldb::addr_t thread_dispatch_qaddr,
467 std::string &dispatch_queue_name);
468
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000469 DynamicLoader *
Eric Christopher7ab81b92014-11-04 03:13:17 +0000470 GetDynamicLoader () override;
Jason Molenda5e8534e2012-10-03 01:29:34 +0000471
Aidan Doddsc0c83852015-05-08 09:36:31 +0000472 // Query remote GDBServer for register information
473 bool
Jim Ingham7b71c0b2016-02-18 23:58:45 +0000474 GetGDBServerRegisterInfo (ArchSpec &arch);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000475
476 // Query remote GDBServer for a detailed loaded library list
477 Error
Stephane Sezer87b0fe02016-01-12 19:02:41 +0000478 GetLoadedModuleList (LoadedModuleInfoList &);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000479
480 lldb::ModuleSP
Stephane Sezer3553c0e2016-04-05 17:25:32 +0000481 LoadModuleAtAddress (const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr,
482 bool value_is_offset);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000483
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000484private:
485 //------------------------------------------------------------------
486 // For ProcessGDBRemote only
487 //------------------------------------------------------------------
Jim Ingham1c823b42011-01-22 01:33:44 +0000488 static bool
489 NewThreadNotifyBreakpointHit (void *baton,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000490 StoppointCallbackContext *context,
Jim Ingham1c823b42011-01-22 01:33:44 +0000491 lldb::user_id_t break_id,
492 lldb::user_id_t break_loc_id);
493
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000494 DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000495};
496
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000497} // namespace process_gdb_remote
498} // namespace lldb_private
499
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000500#endif // liblldb_ProcessGDBRemote_h_