blob: 4bccd6792736d02c4a8526944cdbd7ad4f8bb3e0 [file] [log] [blame]
Todd Fialaaf245d12014-06-30 21:05:18 +00001//===-- NativeProcessLinux.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_NativeProcessLinux_H_
11#define liblldb_NativeProcessLinux_H_
12
13// C Includes
14#include <semaphore.h>
15#include <signal.h>
16
17// C++ Includes
Pavel Labathc0765592015-05-06 10:46:34 +000018#include <mutex>
19#include <unordered_map>
Todd Fialaaf245d12014-06-30 21:05:18 +000020#include <unordered_set>
21
22// Other libraries and framework includes
23#include "lldb/Core/ArchSpec.h"
24#include "lldb/lldb-types.h"
25#include "lldb/Host/Debug.h"
Zachary Turner39de3112014-09-09 20:54:56 +000026#include "lldb/Host/HostThread.h"
Todd Fialaaf245d12014-06-30 21:05:18 +000027#include "lldb/Host/Mutex.h"
28#include "lldb/Target/MemoryRegionInfo.h"
29
Chaoren Lin2fe1d0a2015-02-03 01:51:38 +000030#include "lldb/Host/common/NativeProcessProtocol.h"
Pavel Labath8c8ff7a2015-05-11 10:03:10 +000031#include "NativeThreadLinux.h"
Todd Fialaaf245d12014-06-30 21:05:18 +000032
Tamas Berghammerdb264a62015-03-31 09:52:22 +000033namespace lldb_private {
Todd Fialaaf245d12014-06-30 21:05:18 +000034 class Error;
35 class Module;
36 class Scalar;
37
Tamas Berghammerdb264a62015-03-31 09:52:22 +000038namespace process_linux {
Todd Fialaaf245d12014-06-30 21:05:18 +000039 /// @class NativeProcessLinux
40 /// @brief Manages communication with the inferior (debugee) process.
41 ///
42 /// Upon construction, this class prepares and launches an inferior process for
43 /// debugging.
44 ///
45 /// Changes in the inferior process state are broadcasted.
46 class NativeProcessLinux: public NativeProcessProtocol
47 {
48 public:
49
Tamas Berghammerdb264a62015-03-31 09:52:22 +000050 static Error
Todd Fialaaf245d12014-06-30 21:05:18 +000051 LaunchProcess (
52 Module *exe_module,
53 ProcessLaunchInfo &launch_info,
Tamas Berghammerdb264a62015-03-31 09:52:22 +000054 NativeProcessProtocol::NativeDelegate &native_delegate,
Todd Fialaaf245d12014-06-30 21:05:18 +000055 NativeProcessProtocolSP &native_process_sp);
56
Tamas Berghammerdb264a62015-03-31 09:52:22 +000057 static Error
Todd Fialaaf245d12014-06-30 21:05:18 +000058 AttachToProcess (
59 lldb::pid_t pid,
Tamas Berghammerdb264a62015-03-31 09:52:22 +000060 NativeProcessProtocol::NativeDelegate &native_delegate,
Todd Fialaaf245d12014-06-30 21:05:18 +000061 NativeProcessProtocolSP &native_process_sp);
62
63 // ---------------------------------------------------------------------
Todd Fialaaf245d12014-06-30 21:05:18 +000064 // NativeProcessProtocol Interface
65 // ---------------------------------------------------------------------
66 Error
67 Resume (const ResumeActionList &resume_actions) override;
68
69 Error
70 Halt () override;
71
72 Error
73 Detach () override;
74
75 Error
76 Signal (int signo) override;
77
78 Error
Chaoren Line9547b82015-02-03 01:51:00 +000079 Interrupt () override;
80
81 Error
Todd Fialaaf245d12014-06-30 21:05:18 +000082 Kill () override;
83
84 Error
85 GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info) override;
86
87 Error
Chaoren Lin3eb4b452015-04-29 17:24:48 +000088 ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000089
90 Error
Chaoren Lin3eb4b452015-04-29 17:24:48 +000091 ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000092
93 Error
Chaoren Lin3eb4b452015-04-29 17:24:48 +000094 WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override;
95
96 Error
97 AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000098
99 Error
100 DeallocateMemory (lldb::addr_t addr) override;
101
102 lldb::addr_t
103 GetSharedLibraryInfoAddress () override;
104
105 size_t
106 UpdateThreads () override;
107
108 bool
109 GetArchitecture (ArchSpec &arch) const override;
110
111 Error
112 SetBreakpoint (lldb::addr_t addr, uint32_t size, bool hardware) override;
113
Pavel Labath45f5cb32015-05-05 15:05:50 +0000114 Error
115 SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
116
117 Error
118 RemoveWatchpoint (lldb::addr_t addr) override;
119
Todd Fialaaf245d12014-06-30 21:05:18 +0000120 void
121 DoStopIDBumped (uint32_t newBumpId) override;
122
Oleksiy Vyalov8bc34f42015-02-19 17:58:04 +0000123 void
124 Terminate () override;
125
Todd Fialaaf245d12014-06-30 21:05:18 +0000126 // ---------------------------------------------------------------------
127 // Interface used by NativeRegisterContext-derived classes.
128 // ---------------------------------------------------------------------
129
130 /// Reads the contents from the register identified by the given (architecture
131 /// dependent) offset.
132 ///
133 /// This method is provided for use by RegisterContextLinux derivatives.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000134 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000135 ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000136 unsigned size, RegisterValue &value);
Todd Fialaaf245d12014-06-30 21:05:18 +0000137
138 /// Writes the given value to the register identified by the given
139 /// (architecture dependent) offset.
140 ///
141 /// This method is provided for use by RegisterContextLinux derivatives.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000142 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000143 WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000144 const RegisterValue &value);
Todd Fialaaf245d12014-06-30 21:05:18 +0000145
146 /// Reads all general purpose registers into the specified buffer.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000147 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000148 ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size);
149
150 /// Reads generic floating point registers into the specified buffer.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000151 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000152 ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size);
153
154 /// Reads the specified register set into the specified buffer.
155 /// For instance, the extended floating-point register set.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000156 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000157 ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset);
158
159 /// Writes all general purpose registers into the specified buffer.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000160 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000161 WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size);
162
163 /// Writes generic floating point registers into the specified buffer.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000164 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000165 WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size);
166
167 /// Writes the specified register set into the specified buffer.
168 /// For instance, the extended floating-point register set.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000169 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000170 WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset);
Tamas Berghammer7cb18bf2015-03-24 11:15:23 +0000171
172 Error
173 GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override;
174
Todd Fialaaf245d12014-06-30 21:05:18 +0000175 protected:
176 // ---------------------------------------------------------------------
177 // NativeProcessProtocol protected interface
178 // ---------------------------------------------------------------------
179 Error
180 GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) override;
181
182 private:
183
Pavel Labath1107b5a2015-04-17 14:07:49 +0000184 class Monitor;
185
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000186 ArchSpec m_arch;
Todd Fialaaf245d12014-06-30 21:05:18 +0000187
Pavel Labath1107b5a2015-04-17 14:07:49 +0000188 std::unique_ptr<Monitor> m_monitor_up;
Todd Fialaaf245d12014-06-30 21:05:18 +0000189
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000190 LazyBool m_supports_mem_region;
Todd Fialaaf245d12014-06-30 21:05:18 +0000191 std::vector<MemoryRegionInfo> m_mem_region_cache;
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000192 Mutex m_mem_region_cache_mutex;
Todd Fialaaf245d12014-06-30 21:05:18 +0000193
Tamas Berghammerd8c338d2015-04-15 09:47:02 +0000194 // List of thread ids stepping with a breakpoint with the address of
195 // the relevan breakpoint
196 std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint;
197
Todd Fialaaf245d12014-06-30 21:05:18 +0000198 /// @class LauchArgs
199 ///
200 /// @brief Simple structure to pass data to the thread responsible for
201 /// launching a child process.
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000202 struct LaunchArgs
Todd Fialaaf245d12014-06-30 21:05:18 +0000203 {
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000204 LaunchArgs(Module *module,
Todd Fialaaf245d12014-06-30 21:05:18 +0000205 char const **argv,
206 char const **envp,
Todd Fiala75f47c32014-10-11 21:42:09 +0000207 const std::string &stdin_path,
208 const std::string &stdout_path,
209 const std::string &stderr_path,
Todd Fiala0bce1b62014-08-17 00:10:50 +0000210 const char *working_dir,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000211 const ProcessLaunchInfo &launch_info);
Todd Fialaaf245d12014-06-30 21:05:18 +0000212
213 ~LaunchArgs();
214
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000215 Module *m_module; // The executable image to launch.
216 char const **m_argv; // Process arguments.
217 char const **m_envp; // Process environment.
Todd Fiala75f47c32014-10-11 21:42:09 +0000218 const std::string &m_stdin_path; // Redirect stdin if not empty.
219 const std::string &m_stdout_path; // Redirect stdout if not empty.
220 const std::string &m_stderr_path; // Redirect stderr if not empty.
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000221 const char *m_working_dir; // Working directory or NULL.
222 const ProcessLaunchInfo &m_launch_info;
Todd Fialaaf245d12014-06-30 21:05:18 +0000223 };
224
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000225 typedef std::function<::pid_t(Error &)> InitialOperation;
Todd Fialaaf245d12014-06-30 21:05:18 +0000226
227 // ---------------------------------------------------------------------
228 // Private Instance Methods
229 // ---------------------------------------------------------------------
230 NativeProcessLinux ();
231
232 /// Launches an inferior process ready for debugging. Forms the
233 /// implementation of Process::DoLaunch.
234 void
235 LaunchInferior (
236 Module *module,
237 char const *argv[],
238 char const *envp[],
Todd Fiala75f47c32014-10-11 21:42:09 +0000239 const std::string &stdin_path,
240 const std::string &stdout_path,
241 const std::string &stderr_path,
Todd Fialaaf245d12014-06-30 21:05:18 +0000242 const char *working_dir,
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000243 const ProcessLaunchInfo &launch_info,
Todd Fialaaf245d12014-06-30 21:05:18 +0000244 Error &error);
245
246 /// Attaches to an existing process. Forms the
Tamas Berghammer0cbf0b12015-03-13 11:16:03 +0000247 /// implementation of Process::DoAttach
Todd Fialaaf245d12014-06-30 21:05:18 +0000248 void
249 AttachToInferior (lldb::pid_t pid, Error &error);
250
251 void
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000252 StartMonitorThread(const InitialOperation &operation, Error &error);
Pavel Labath1107b5a2015-04-17 14:07:49 +0000253
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000254 ::pid_t
255 Launch(LaunchArgs *args, Error &error);
Todd Fialaaf245d12014-06-30 21:05:18 +0000256
Pavel Labathbd7cbc52015-04-20 13:53:49 +0000257 ::pid_t
258 Attach(lldb::pid_t pid, Error &error);
Todd Fialaaf245d12014-06-30 21:05:18 +0000259
Chaoren Lin97ccc292015-02-03 01:51:12 +0000260 static Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000261 SetDefaultPtraceOpts(const lldb::pid_t);
262
Todd Fialaaf245d12014-06-30 21:05:18 +0000263 static bool
264 DupDescriptor(const char *path, int fd, int flags);
265
Pavel Labath1107b5a2015-04-17 14:07:49 +0000266 static void *
267 MonitorThread(void *baton);
268
269 void
270 MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status);
Todd Fialaaf245d12014-06-30 21:05:18 +0000271
272 void
Pavel Labath426bdf82015-04-28 07:51:52 +0000273 WaitForNewThread(::pid_t tid);
274
275 void
Todd Fialaaf245d12014-06-30 21:05:18 +0000276 MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid);
277
278 void
Chaoren Linc16f5dc2015-03-19 23:28:10 +0000279 MonitorTrace(lldb::pid_t pid, NativeThreadProtocolSP thread_sp);
280
281 void
282 MonitorBreakpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp);
283
284 void
285 MonitorWatchpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp, uint32_t wp_index);
286
287 void
Todd Fialaaf245d12014-06-30 21:05:18 +0000288 MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool exited);
289
Tamas Berghammere7708682015-04-22 10:00:23 +0000290 bool
291 SupportHardwareSingleStepping() const;
292
293 Error
294 SetupSoftwareSingleStepping(NativeThreadProtocolSP thread_sp);
295
Todd Fialaaf245d12014-06-30 21:05:18 +0000296#if 0
297 static ::ProcessMessage::CrashReason
298 GetCrashReasonForSIGSEGV(const siginfo_t *info);
299
300 static ::ProcessMessage::CrashReason
301 GetCrashReasonForSIGILL(const siginfo_t *info);
302
303 static ::ProcessMessage::CrashReason
304 GetCrashReasonForSIGFPE(const siginfo_t *info);
305
306 static ::ProcessMessage::CrashReason
307 GetCrashReasonForSIGBUS(const siginfo_t *info);
308#endif
309
Todd Fialaaf245d12014-06-30 21:05:18 +0000310 bool
311 HasThreadNoLock (lldb::tid_t thread_id);
312
313 NativeThreadProtocolSP
314 MaybeGetThreadNoLock (lldb::tid_t thread_id);
315
316 bool
317 StopTrackingThread (lldb::tid_t thread_id);
318
319 NativeThreadProtocolSP
320 AddThread (lldb::tid_t thread_id);
321
Todd Fialaaf245d12014-06-30 21:05:18 +0000322 Error
Tamas Berghammer63c8be92015-04-15 09:38:48 +0000323 GetSoftwareBreakpointPCOffset (NativeRegisterContextSP context_sp, uint32_t &actual_opcode_size);
Todd Fialaaf245d12014-06-30 21:05:18 +0000324
325 Error
326 FixupBreakpointPCAsNeeded (NativeThreadProtocolSP &thread_sp);
327
328 /// Writes a siginfo_t structure corresponding to the given thread ID to the
329 /// memory region pointed to by @p siginfo.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000330 Error
331 GetSignalInfo(lldb::tid_t tid, void *siginfo);
Todd Fialaaf245d12014-06-30 21:05:18 +0000332
333 /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
334 /// corresponding to the given thread ID to the memory pointed to by @p
335 /// message.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000336 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000337 GetEventMessage(lldb::tid_t tid, unsigned long *message);
338
339 /// Resumes the given thread. If @p signo is anything but
340 /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000341 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000342 Resume(lldb::tid_t tid, uint32_t signo);
343
344 /// Single steps the given thread. If @p signo is anything but
345 /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
Chaoren Lin97ccc292015-02-03 01:51:12 +0000346 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000347 SingleStep(lldb::tid_t tid, uint32_t signo);
348
Todd Fiala511e5cd2014-09-11 23:29:14 +0000349 void
Chaoren Linfa03ad22015-02-03 01:50:42 +0000350 NotifyThreadDeath (lldb::tid_t tid);
351
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000352 Error
Todd Fialaaf245d12014-06-30 21:05:18 +0000353 Detach(lldb::tid_t tid);
Chaoren Lin86fd8e42015-02-03 01:51:15 +0000354
Pavel Labathc0765592015-05-06 10:46:34 +0000355
Pavel Labathc0765592015-05-06 10:46:34 +0000356 // Typedefs.
357 typedef std::unordered_set<lldb::tid_t> ThreadIDSet;
358
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000359 // Notify that a thread is created and/or starting to be tracked.
Pavel Labathc0765592015-05-06 10:46:34 +0000360 void
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000361 NotifyThreadCreate(lldb::tid_t tid);
Pavel Labathc0765592015-05-06 10:46:34 +0000362
363
Pavel Labathed89c7f2015-05-06 12:22:37 +0000364 // Notify the delegate after a given set of threads stops. The triggering_tid will be set
365 // as the current thread. The error_function will be fired if either the triggering tid
366 // or any of the wait_for_stop_tids are unknown.
Pavel Labathc0765592015-05-06 10:46:34 +0000367 void
Pavel Labath337f3eb2015-05-08 08:57:45 +0000368 StopThreads(lldb::tid_t triggering_tid, const ThreadIDSet &wait_for_stop_tids);
Pavel Labathc0765592015-05-06 10:46:34 +0000369
Pavel Labathed89c7f2015-05-06 12:22:37 +0000370 // Notify the delegate after all non-stopped threads stop. The triggering_tid will be set
371 // as the current thread. The error_function will be fired if the triggering tid
372 // is unknown.
Pavel Labathc0765592015-05-06 10:46:34 +0000373 void
Pavel Labath337f3eb2015-05-08 08:57:45 +0000374 StopRunningThreads(lldb::tid_t triggering_tid);
Pavel Labathc0765592015-05-06 10:46:34 +0000375
Pavel Labathed89c7f2015-05-06 12:22:37 +0000376 // Notify the delegate after all non-stopped threads stop. The triggering_tid will be set
377 // as the current thread. The error_function will be fired if either the triggering tid
378 // or any of the wait_for_stop_tids are unknown. This variant will send stop requests to
Pavel Labath337f3eb2015-05-08 08:57:45 +0000379 // all non-stopped threads except skip_stop_request_tid.
Pavel Labathc0765592015-05-06 10:46:34 +0000380 void
Pavel Labath337f3eb2015-05-08 08:57:45 +0000381 StopRunningThreadsWithSkipTID(lldb::tid_t triggering_tid, lldb::tid_t skip_stop_request_tid);
Pavel Labathc0765592015-05-06 10:46:34 +0000382
383 // Notify the thread stopped. Will trigger error at time of execution if we
384 // already think it is stopped.
Pavel Labath5eb721e2015-05-07 08:30:31 +0000385 Error
386 NotifyThreadStop(lldb::tid_t tid, bool initiated_by_llgs);
Pavel Labathc0765592015-05-06 10:46:34 +0000387
388 // Request that the given thread id should have the request_thread_resume_function
Pavel Labath5eb721e2015-05-07 08:30:31 +0000389 // called. This call signals an error if the thread resume is for
Pavel Labathc0765592015-05-06 10:46:34 +0000390 // a thread that is already in a running state.
Pavel Labath5eb721e2015-05-07 08:30:31 +0000391 Error
Pavel Labathc0765592015-05-06 10:46:34 +0000392 RequestThreadResume (lldb::tid_t tid,
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000393 const NativeThreadLinux::ResumeThreadFunction &request_thread_resume_function);
Pavel Labathc0765592015-05-06 10:46:34 +0000394
395 // Request that the given thread id should have the request_thread_resume_function
Pavel Labath5eb721e2015-05-07 08:30:31 +0000396 // called. This call ignores threads that are already running and
Pavel Labathc0765592015-05-06 10:46:34 +0000397 // does not trigger an error in that case.
Pavel Labath5eb721e2015-05-07 08:30:31 +0000398 Error
Pavel Labathc0765592015-05-06 10:46:34 +0000399 RequestThreadResumeAsNeeded (lldb::tid_t tid,
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000400 const NativeThreadLinux::ResumeThreadFunction &request_thread_resume_function);
Pavel Labathc0765592015-05-06 10:46:34 +0000401
402 // Indicate the calling process did an exec and that the thread state
403 // should be 100% cleared.
404 void
405 ResetForExec ();
406
Pavel Labathc0765592015-05-06 10:46:34 +0000407 private:
Pavel Labathc0765592015-05-06 10:46:34 +0000408 struct PendingNotification
409 {
410 PendingNotification (lldb::tid_t triggering_tid,
Pavel Labath337f3eb2015-05-08 08:57:45 +0000411 const ThreadIDSet &wait_for_stop_tids,
412 const ThreadIDSet &skip_stop_request_tids):
413 triggering_tid (triggering_tid),
414 wait_for_stop_tids (wait_for_stop_tids),
415 original_wait_for_stop_tids (wait_for_stop_tids),
416 request_stop_on_all_unstopped_threads (false),
417 skip_stop_request_tids (skip_stop_request_tids)
Pavel Labathc0765592015-05-06 10:46:34 +0000418 {
419 }
420
Pavel Labath337f3eb2015-05-08 08:57:45 +0000421 PendingNotification (lldb::tid_t triggering_tid):
422 triggering_tid (triggering_tid),
423 wait_for_stop_tids (),
424 original_wait_for_stop_tids (),
425 request_stop_on_all_unstopped_threads (true),
426 skip_stop_request_tids ()
Pavel Labathc0765592015-05-06 10:46:34 +0000427 {
428 }
429
430 const lldb::tid_t triggering_tid;
431 ThreadIDSet wait_for_stop_tids;
432 const ThreadIDSet original_wait_for_stop_tids;
Pavel Labathc0765592015-05-06 10:46:34 +0000433 const bool request_stop_on_all_unstopped_threads;
434 ThreadIDSet skip_stop_request_tids;
435 };
436 typedef std::unique_ptr<PendingNotification> PendingNotificationUP;
437
438 // Fire pending notification if no pending thread stops remain.
439 void SignalIfRequirementsSatisfied();
440
441 bool
442 RequestStopOnAllSpecifiedThreads();
443
444 void
445 RequestStopOnAllRunningThreads();
446
Pavel Labathc0765592015-05-06 10:46:34 +0000447 std::mutex m_event_mutex; // Serializes execution of ProcessEvent. XXX
448
Pavel Labath5eb721e2015-05-07 08:30:31 +0000449 Error
450 ThreadDidStop(lldb::tid_t tid, bool initiated_by_llgs);
Pavel Labathc0765592015-05-06 10:46:34 +0000451
Pavel Labath5eb721e2015-05-07 08:30:31 +0000452 Error
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000453 DoResume(lldb::tid_t tid, NativeThreadLinux::ResumeThreadFunction request_thread_resume_function,
Pavel Labath5eb721e2015-05-07 08:30:31 +0000454 bool error_when_already_running);
Pavel Labathc0765592015-05-06 10:46:34 +0000455
456 void
Pavel Labathed89c7f2015-05-06 12:22:37 +0000457 DoStopThreads(PendingNotificationUP &&notification_up);
Pavel Labathc0765592015-05-06 10:46:34 +0000458
459 void
Pavel Labath8c8ff7a2015-05-11 10:03:10 +0000460 ThreadWasCreated (lldb::tid_t tid);
Pavel Labathc0765592015-05-06 10:46:34 +0000461
462 void
Pavel Labath5eb721e2015-05-07 08:30:31 +0000463 ThreadDidDie (lldb::tid_t tid);
Pavel Labathc0765592015-05-06 10:46:34 +0000464
Pavel Labathc0765592015-05-06 10:46:34 +0000465 // Member variables.
Pavel Labathc0765592015-05-06 10:46:34 +0000466 PendingNotificationUP m_pending_notification_up;
Todd Fialaaf245d12014-06-30 21:05:18 +0000467 };
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000468
469} // namespace process_linux
470} // namespace lldb_private
Todd Fialaaf245d12014-06-30 21:05:18 +0000471
472#endif // #ifndef liblldb_NativeProcessLinux_H_