blob: 12094e7861284e021a75d4159624e9be464f410c [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"
Zachary Turner39de3112014-09-09 20:54:56 +000030#include "lldb/Host/HostThread.h"
Todd Fiala4ceced32014-08-29 17:35:57 +000031#include "lldb/lldb-private-forward.h"
Pavel Labathf805e192015-07-07 10:08:41 +000032#include "lldb/Utility/StringExtractor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033#include "lldb/Target/Process.h"
34#include "lldb/Target/Thread.h"
35
Greg Clayton576d8832011-03-22 04:00:09 +000036#include "GDBRemoteCommunicationClient.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000037#include "GDBRemoteRegisterContext.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038
Tamas Berghammerdb264a62015-03-31 09:52:22 +000039namespace lldb_private {
40namespace process_gdb_remote {
41
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042class ThreadGDBRemote;
43
Tamas Berghammerdb264a62015-03-31 09:52:22 +000044class ProcessGDBRemote : public Process
Chris Lattner30fdc8d2010-06-08 16:52:24 +000045{
46public:
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000047 ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener);
48
49 ~ProcessGDBRemote() override;
50
Greg Claytonc3776bf2012-02-09 06:16:32 +000051 static lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +000052 CreateInstance (lldb::TargetSP target_sp,
Tamas Berghammerdb264a62015-03-31 09:52:22 +000053 Listener &listener,
54 const FileSpec *crash_file_path);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000055
56 static void
57 Initialize();
58
59 static void
Tamas Berghammerdb264a62015-03-31 09:52:22 +000060 DebuggerInitialize (Debugger &debugger);
Greg Clayton7f982402013-07-15 22:54:20 +000061
62 static void
Chris Lattner30fdc8d2010-06-08 16:52:24 +000063 Terminate();
64
Tamas Berghammerdb264a62015-03-31 09:52:22 +000065 static ConstString
Chris Lattner30fdc8d2010-06-08 16:52:24 +000066 GetPluginNameStatic();
67
68 static const char *
69 GetPluginDescriptionStatic();
70
71 //------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072 // Check if a given Process
73 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000074 bool
Zachary Turner7529df92015-09-01 20:02:29 +000075 CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076
Tamas Berghammerdb264a62015-03-31 09:52:22 +000077 CommandObject *
Eric Christopher7ab81b92014-11-04 03:13:17 +000078 GetPluginCommandObject() override;
Jim Ingham5aee1622010-08-09 23:31:02 +000079
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080 //------------------------------------------------------------------
81 // Creating a new process, or attaching to an existing one
82 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +000083 Error
84 WillLaunch (Module* module) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085
Tamas Berghammerdb264a62015-03-31 09:52:22 +000086 Error
87 DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000088
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000089 void
Eric Christopher7ab81b92014-11-04 03:13:17 +000090 DidLaunch () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091
Tamas Berghammerdb264a62015-03-31 09:52:22 +000092 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000093 WillAttachToProcessWithID (lldb::pid_t pid) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000094
Tamas Berghammerdb264a62015-03-31 09:52:22 +000095 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +000096 WillAttachToProcessWithName (const char *process_name, bool wait_for_launch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000097
Tamas Berghammerdb264a62015-03-31 09:52:22 +000098 Error
99 DoConnectRemote (Stream *strm, const char *remote_url) override;
Greg Claytonb766a732011-02-04 01:58:07 +0000100
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000101 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000102 WillLaunchOrAttach ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000103
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000104 Error
105 DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) override;
Han Ming Ong84647042012-02-25 01:07:38 +0000106
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000107 Error
Han Ming Ong84647042012-02-25 01:07:38 +0000108 DoAttachToProcessWithName (const char *process_name,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000109 const ProcessAttachInfo &attach_info) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000110
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000111 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000112 DidAttach (ArchSpec &process_arch) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113
114 //------------------------------------------------------------------
115 // PluginInterface protocol
116 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000117 ConstString
Eric Christopher7ab81b92014-11-04 03:13:17 +0000118 GetPluginName() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000119
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000120 uint32_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000121 GetPluginVersion() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000122
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123 //------------------------------------------------------------------
124 // Process Control
125 //------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000126 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000127 WillResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000128
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000129 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000130 DoResume () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000131
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000132 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000133 DoHalt (bool &caused_stop) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000134
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000135 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000136 DoDetach (bool keep_stopped) override;
Jim Ingham8af3b9c2013-03-29 01:18:12 +0000137
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000138 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000139 DetachRequiresHalt() override { return true; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000140
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000141 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000142 DoSignal (int signal) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000143
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000144 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000145 DoDestroy () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000146
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000147 void
Eric Christopher7ab81b92014-11-04 03:13:17 +0000148 RefreshStateAfterStop() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000149
Chaoren Linc963a222015-09-01 16:58:45 +0000150 void
151 SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
152
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000153 //------------------------------------------------------------------
154 // Process Queries
155 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000156 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000157 IsAlive () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000158
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000159 lldb::addr_t
Eric Christopher7ab81b92014-11-04 03:13:17 +0000160 GetImageInfoAddress() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000161
Greg Clayton2e309072015-07-17 23:42:28 +0000162 void
163 WillPublicStop () override;
164
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000165 //------------------------------------------------------------------
166 // Process Memory
167 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000168 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000169 DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000170
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000171 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000172 DoWriteMemory (lldb::addr_t addr, const void *buf, size_t size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000173
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000174 lldb::addr_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000175 DoAllocateMemory (size_t size, uint32_t permissions, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000176
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000177 Error
178 GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &region_info) override;
Greg Clayton46fb5582011-11-18 07:03:08 +0000179
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000180 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000181 DoDeallocateMemory (lldb::addr_t ptr) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000182
183 //------------------------------------------------------------------
184 // Process STDIO
185 //------------------------------------------------------------------
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000186 size_t
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000187 PutSTDIN (const char *buf, size_t buf_size, Error &error) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000188
189 //----------------------------------------------------------------------
190 // Process Breakpoints
191 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000192 Error
193 EnableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000194
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000195 Error
196 DisableBreakpointSite (BreakpointSite *bp_site) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000197
198 //----------------------------------------------------------------------
199 // Process Watchpoints
200 //----------------------------------------------------------------------
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000201 Error
202 EnableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000203
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000204 Error
205 DisableWatchpoint (Watchpoint *wp, bool notify = true) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000206
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000207 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000208 GetWatchpointSupportInfo (uint32_t &num) override;
Johnny Chen64637202012-05-23 21:09:52 +0000209
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000210 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000211 GetWatchpointSupportInfo (uint32_t &num, bool& after) override;
Enrico Granataf04a2192012-07-13 23:18:48 +0000212
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000213 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000214 StartNoticingNewThreads() override;
Jim Ingham1c823b42011-01-22 01:33:44 +0000215
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000216 bool
Eric Christopher7ab81b92014-11-04 03:13:17 +0000217 StopNoticingNewThreads() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000218
Greg Claytonc1422c12012-04-09 22:46:21 +0000219 GDBRemoteCommunicationClient &
220 GetGDBRemote()
221 {
222 return m_gdb_comm;
223 }
Greg Claytonfbb76342013-11-20 21:07:01 +0000224
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000225 Error
Eric Christopher7ab81b92014-11-04 03:13:17 +0000226 SendEventData(const char *data) override;
Jason Molendaa3329782014-03-29 18:54:20 +0000227
Greg Claytonfbb76342013-11-20 21:07:01 +0000228 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000229 // Override DidExit so we can disconnect from the remote GDB server
Greg Claytonfbb76342013-11-20 21:07:01 +0000230 //----------------------------------------------------------------------
Greg Clayton5df78fa2015-05-23 03:54:53 +0000231 void
232 DidExit () override;
Greg Claytonfbb76342013-11-20 21:07:01 +0000233
Jason Molenda6076bf42014-05-06 04:34:52 +0000234 void
235 SetUserSpecifiedMaxMemoryTransferSize (uint64_t user_specified_max);
236
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000237 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000238 GetModuleSpec(const FileSpec& module_file_spec,
239 const ArchSpec& arch,
240 ModuleSpec &module_spec) override;
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000241
Jim Ingham13c30d22015-11-05 22:33:17 +0000242 bool
243 GetHostOSVersion(uint32_t &major,
244 uint32_t &minor,
245 uint32_t &update) override;
246
Tamas Berghammer783bfc82015-06-18 20:43:56 +0000247 size_t
248 LoadModules() override;
249
250 Error
251 GetFileLoadAddress(const FileSpec& file, bool& is_loaded, lldb::addr_t& load_addr) override;
Colin Rileyc3c95b22015-04-16 15:51:33 +0000252
Greg Clayton0b90be12015-06-23 21:27:50 +0000253 void
254 ModulesDidLoad (ModuleList &module_list) override;
255
Jason Molenda20ee21b2015-07-10 23:15:22 +0000256 StructuredData::ObjectSP
257 GetLoadedDynamicLibrariesInfos (lldb::addr_t image_list_address, lldb::addr_t image_count) override;
258
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000259protected:
260 friend class ThreadGDBRemote;
Greg Clayton576d8832011-03-22 04:00:09 +0000261 friend class GDBRemoteCommunicationClient;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000262 friend class GDBRemoteRegisterContext;
263
Aidan Doddsc0c83852015-05-08 09:36:31 +0000264 class GDBLoadedModuleInfoList;
265
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000266 //------------------------------------------------------------------
267 /// Broadcaster event bits definitions.
268 //------------------------------------------------------------------
269 enum
270 {
271 eBroadcastBitAsyncContinue = (1 << 0),
272 eBroadcastBitAsyncThreadShouldExit = (1 << 1),
273 eBroadcastBitAsyncThreadDidExit = (1 << 2)
274 };
275
276 Flags m_flags; // Process specific flags (see eFlags enums)
277 GDBRemoteCommunicationClient m_gdb_comm;
278 std::atomic<lldb::pid_t> m_debugserver_pid;
279 std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable
280 Mutex m_last_stop_packet_mutex;
281 GDBRemoteDynamicRegisterInfo m_register_info;
282 Broadcaster m_async_broadcaster;
283 Listener m_async_listener;
284 HostThread m_async_thread;
285 Mutex m_async_thread_state_mutex;
286 typedef std::vector<lldb::tid_t> tid_collection;
287 typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection;
288 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
289 typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
290 tid_collection m_thread_ids; // Thread IDs for all threads. This list gets updated after stopping
291 StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads that have valid stop infos
292 StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited registers and memory for all threads if "jThreadsInfo" packet is supported
293 tid_collection m_continue_c_tids; // 'c' for continue
294 tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
295 tid_collection m_continue_s_tids; // 's' for step
296 tid_sig_collection m_continue_S_tids; // 'S' for step with signal
297 uint64_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory
298 uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote gdb stub can handle
299 MMapMap m_addr_to_mmap_size;
300 lldb::BreakpointSP m_thread_create_bp_sp;
301 bool m_waiting_for_attach;
302 bool m_destroy_tried_resuming;
303 lldb::CommandObjectSP m_command_sp;
304 int64_t m_breakpoint_pc_offset;
305 lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
306
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000307 //----------------------------------------------------------------------
308 // Accessors
309 //----------------------------------------------------------------------
310 bool
311 IsRunning ( lldb::StateType state )
312 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000313 return state == lldb::eStateRunning || IsStepping(state);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000314 }
315
316 bool
317 IsStepping ( lldb::StateType state)
318 {
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000319 return state == lldb::eStateStepping;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000320 }
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000321
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000322 bool
323 CanResume ( lldb::StateType state)
324 {
325 return state == lldb::eStateStopped;
326 }
327
328 bool
329 HasExited (lldb::StateType state)
330 {
331 return state == lldb::eStateExited;
332 }
333
334 bool
335 ProcessIDIsValid ( ) const;
336
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000337 void
338 Clear ( );
339
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000340 Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000341 GetFlags ()
342 {
343 return m_flags;
344 }
345
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000346 const Flags &
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000347 GetFlags () const
348 {
349 return m_flags;
350 }
351
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000352 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000353 UpdateThreadList (ThreadList &old_thread_list,
354 ThreadList &new_thread_list) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000355
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000356 Error
Oleksiy Vyalovafd6ce42015-11-23 19:32:24 +0000357 EstablishConnectionIfNeeded (const ProcessInfo &process_info);
358
359 Error
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000360 LaunchAndConnectToDebugserver (const ProcessInfo &process_info);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000361
362 void
363 KillDebugserverProcess ();
364
365 void
Greg Clayton513c26c2011-01-29 07:10:55 +0000366 BuildDynamicRegisterInfo (bool force);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000367
Greg Clayton09c3e3d2011-12-06 04:51:14 +0000368 void
Greg Clayton8cda7f02013-05-21 21:55:59 +0000369 SetLastStopPacket (const StringExtractorGDBRemote &response);
Jason Molendad1fae142012-09-29 08:03:33 +0000370
Greg Claytonef8180a2013-10-15 00:14:28 +0000371 bool
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000372 ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
Greg Claytonef8180a2013-10-15 00:14:28 +0000373
Todd Fialaaf245d12014-06-30 21:05:18 +0000374 const lldb::DataBufferSP
375 GetAuxvData() override;
Steve Pucci03904ac2014-03-04 23:18:46 +0000376
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000377 StructuredData::ObjectSP
Jason Molenda705b1802014-06-13 02:37:02 +0000378 GetExtendedInfoForThread (lldb::tid_t tid);
379
Jason Molenda6076bf42014-05-06 04:34:52 +0000380 void
381 GetMaxMemorySize();
382
Greg Clayton358cf1e2015-06-25 21:46:34 +0000383 bool
384 CalculateThreadStopInfo (ThreadGDBRemote *thread);
385
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000386 size_t
387 UpdateThreadIDsFromStopReplyThreadsValue (std::string &value);
388
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000389 bool
Ewan Crawford76df2882015-06-23 12:32:06 +0000390 HandleNotifyPacket(StringExtractorGDBRemote &packet);
391
392 bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000393 StartAsyncThread ();
394
395 void
396 StopAsyncThread ();
397
Virgile Bellob2f1fb22013-08-23 12:44:05 +0000398 static lldb::thread_result_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000399 AsyncThread (void *arg);
400
401 static bool
402 MonitorDebugserverProcess (void *callback_baton,
403 lldb::pid_t pid,
Greg Claytone4e45922011-11-16 05:37:56 +0000404 bool exited,
405 int signo,
406 int exit_status);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000407
408 lldb::StateType
409 SetThreadStopInfo (StringExtractor& stop_packet);
410
Greg Clayton2e309072015-07-17 23:42:28 +0000411 bool
412 GetThreadStopInfoFromJSON (ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp);
413
414 lldb::ThreadSP
Greg Clayton358cf1e2015-06-25 21:46:34 +0000415 SetThreadStopInfo (StructuredData::Dictionary *thread_dict);
416
417 lldb::ThreadSP
418 SetThreadStopInfo (lldb::tid_t tid,
419 ExpeditedRegisterMap &expedited_register_map,
420 uint8_t signo,
421 const std::string &thread_name,
422 const std::string &reason,
423 const std::string &description,
424 uint32_t exc_type,
425 const std::vector<lldb::addr_t> &exc_data,
Greg Clayton2e59d4f2015-06-29 20:08:51 +0000426 lldb::addr_t thread_dispatch_qaddr,
427 bool queue_vars_valid,
428 std::string &queue_name,
429 lldb::QueueKind queue_kind,
430 uint64_t queue_serial);
Greg Clayton358cf1e2015-06-25 21:46:34 +0000431
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000432 void
Ewan Crawford78baa192015-05-13 09:18:18 +0000433 HandleStopReplySequence ();
434
435 void
Greg Clayton9e920902012-04-10 02:25:43 +0000436 ClearThreadIDList ();
437
438 bool
439 UpdateThreadIDList ();
440
441 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000442 DidLaunchOrAttach (ArchSpec& process_arch);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000443
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000444 Error
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000445 ConnectToDebugserver (const char *host_port);
446
447 const char *
448 GetDispatchQueueNameForThread (lldb::addr_t thread_dispatch_qaddr,
449 std::string &dispatch_queue_name);
450
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000451 DynamicLoader *
Eric Christopher7ab81b92014-11-04 03:13:17 +0000452 GetDynamicLoader () override;
Jason Molenda5e8534e2012-10-03 01:29:34 +0000453
Aidan Doddsc0c83852015-05-08 09:36:31 +0000454 // Query remote GDBServer for register information
455 bool
456 GetGDBServerRegisterInfo ();
457
458 // Query remote GDBServer for a detailed loaded library list
459 Error
460 GetLoadedModuleList (GDBLoadedModuleInfoList &);
461
462 lldb::ModuleSP
Stephane Sezerc6845a02015-08-20 22:07:48 +0000463 LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset);
Aidan Doddsc0c83852015-05-08 09:36:31 +0000464
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000465private:
466 //------------------------------------------------------------------
467 // For ProcessGDBRemote only
468 //------------------------------------------------------------------
Jim Ingham1c823b42011-01-22 01:33:44 +0000469 static bool
470 NewThreadNotifyBreakpointHit (void *baton,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000471 StoppointCallbackContext *context,
Jim Ingham1c823b42011-01-22 01:33:44 +0000472 lldb::user_id_t break_id,
473 lldb::user_id_t break_loc_id);
474
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000475 DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000476};
477
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000478} // namespace process_gdb_remote
479} // namespace lldb_private
480
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000481#endif // liblldb_ProcessGDBRemote_h_