blob: b55c1728c6a6f9d76122df4248f9962023363190 [file] [log] [blame]
Todd Fialae77fce02016-09-04 00:18:56 +00001//===-- NativeProcessDarwin.h --------------------------------- -*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Todd Fialae77fce02016-09-04 00:18:56 +00006//
7//===----------------------------------------------------------------------===//
8
9#ifndef NativeProcessDarwin_h
10#define NativeProcessDarwin_h
11
12// NOTE: this code should only be compiled on Apple Darwin systems. It is
13// not cross-platform code and is not intended to build on any other platform.
14// Therefore, platform-specific headers and code are okay here.
15
16// C includes
17#include <mach/mach_types.h>
18
19// C++ includes
20#include <mutex>
21#include <unordered_set>
22
Todd Fialae77fce02016-09-04 00:18:56 +000023#include "lldb/Host/Debug.h"
Todd Fialae77fce02016-09-04 00:18:56 +000024#include "lldb/Host/HostThread.h"
25#include "lldb/Host/Pipe.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000026#include "lldb/Host/common/NativeProcessProtocol.h"
Todd Fialae77fce02016-09-04 00:18:56 +000027#include "lldb/Target/MemoryRegionInfo.h"
Pavel Labath2da1b592017-11-13 16:47:37 +000028#include "lldb/Utility/ArchSpec.h"
Zachary Turner5713a052017-03-22 18:40:07 +000029#include "lldb/Utility/FileSpec.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000030#include "lldb/lldb-types.h"
Todd Fialae77fce02016-09-04 00:18:56 +000031
Todd Fialae77fce02016-09-04 00:18:56 +000032#include "LaunchFlavor.h"
33#include "MachException.h"
34#include "NativeThreadDarwin.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000035#include "NativeThreadListDarwin.h"
Todd Fialae77fce02016-09-04 00:18:56 +000036
37namespace lldb_private {
Zachary Turner97206d52017-05-12 04:51:55 +000038class Status;
Kate Stoneb9c1b512016-09-06 20:57:50 +000039class Scalar;
Todd Fialae77fce02016-09-04 00:18:56 +000040
Kate Stoneb9c1b512016-09-06 20:57:50 +000041namespace process_darwin {
Todd Fialae77fce02016-09-04 00:18:56 +000042
Kate Stoneb9c1b512016-09-06 20:57:50 +000043/// @class NativeProcessDarwin
Adrian Prantld8f460e2018-05-02 16:55:16 +000044/// Manages communication with the inferior (debugee) process.
Kate Stoneb9c1b512016-09-06 20:57:50 +000045///
Adrian Prantld8f460e2018-05-02 16:55:16 +000046/// Upon construction, this class prepares and launches an inferior process
47/// for debugging.
Kate Stoneb9c1b512016-09-06 20:57:50 +000048///
49/// Changes in the inferior process state are broadcasted.
50class NativeProcessDarwin : public NativeProcessProtocol {
Zachary Turner97206d52017-05-12 04:51:55 +000051 friend Status NativeProcessProtocol::Launch(
Kate Stoneb9c1b512016-09-06 20:57:50 +000052 ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
53 MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
Todd Fialae77fce02016-09-04 00:18:56 +000054
Zachary Turner97206d52017-05-12 04:51:55 +000055 friend Status NativeProcessProtocol::Attach(
Kate Stoneb9c1b512016-09-06 20:57:50 +000056 lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
57 MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
Todd Fialae77fce02016-09-04 00:18:56 +000058
Kate Stoneb9c1b512016-09-06 20:57:50 +000059public:
60 ~NativeProcessDarwin() override;
Todd Fialae77fce02016-09-04 00:18:56 +000061
Kate Stoneb9c1b512016-09-06 20:57:50 +000062 // -----------------------------------------------------------------
63 // NativeProcessProtocol Interface
64 // -----------------------------------------------------------------
Zachary Turner97206d52017-05-12 04:51:55 +000065 Status Resume(const ResumeActionList &resume_actions) override;
Todd Fialae77fce02016-09-04 00:18:56 +000066
Zachary Turner97206d52017-05-12 04:51:55 +000067 Status Halt() override;
Todd Fialae77fce02016-09-04 00:18:56 +000068
Zachary Turner97206d52017-05-12 04:51:55 +000069 Status Detach() override;
Todd Fialae77fce02016-09-04 00:18:56 +000070
Zachary Turner97206d52017-05-12 04:51:55 +000071 Status Signal(int signo) override;
Todd Fialae77fce02016-09-04 00:18:56 +000072
Zachary Turner97206d52017-05-12 04:51:55 +000073 Status Interrupt() override;
Todd Fialae77fce02016-09-04 00:18:56 +000074
Zachary Turner97206d52017-05-12 04:51:55 +000075 Status Kill() override;
Todd Fialae77fce02016-09-04 00:18:56 +000076
Zachary Turner97206d52017-05-12 04:51:55 +000077 Status GetMemoryRegionInfo(lldb::addr_t load_addr,
78 MemoryRegionInfo &range_info) override;
Todd Fialae77fce02016-09-04 00:18:56 +000079
Zachary Turner97206d52017-05-12 04:51:55 +000080 Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
81 size_t &bytes_read) override;
Todd Fialae77fce02016-09-04 00:18:56 +000082
Zachary Turner97206d52017-05-12 04:51:55 +000083 Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
84 size_t &bytes_read) override;
Todd Fialae77fce02016-09-04 00:18:56 +000085
Zachary Turner97206d52017-05-12 04:51:55 +000086 Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
87 size_t &bytes_written) override;
Todd Fialae77fce02016-09-04 00:18:56 +000088
Zachary Turner97206d52017-05-12 04:51:55 +000089 Status AllocateMemory(size_t size, uint32_t permissions,
90 lldb::addr_t &addr) override;
Todd Fialae77fce02016-09-04 00:18:56 +000091
Zachary Turner97206d52017-05-12 04:51:55 +000092 Status DeallocateMemory(lldb::addr_t addr) override;
Todd Fialae77fce02016-09-04 00:18:56 +000093
Kate Stoneb9c1b512016-09-06 20:57:50 +000094 lldb::addr_t GetSharedLibraryInfoAddress() override;
Todd Fialae77fce02016-09-04 00:18:56 +000095
Kate Stoneb9c1b512016-09-06 20:57:50 +000096 size_t UpdateThreads() override;
Todd Fialae77fce02016-09-04 00:18:56 +000097
Kate Stoneb9c1b512016-09-06 20:57:50 +000098 bool GetArchitecture(ArchSpec &arch) const override;
Todd Fialae77fce02016-09-04 00:18:56 +000099
Zachary Turner97206d52017-05-12 04:51:55 +0000100 Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
101 bool hardware) override;
Todd Fialae77fce02016-09-04 00:18:56 +0000102
Kate Stoneb9c1b512016-09-06 20:57:50 +0000103 void DoStopIDBumped(uint32_t newBumpId) override;
Todd Fialae77fce02016-09-04 00:18:56 +0000104
Zachary Turner97206d52017-05-12 04:51:55 +0000105 Status GetLoadedModuleFileSpec(const char *module_path,
106 FileSpec &file_spec) override;
Todd Fialae77fce02016-09-04 00:18:56 +0000107
Zachary Turner97206d52017-05-12 04:51:55 +0000108 Status GetFileLoadAddress(const llvm::StringRef &file_name,
109 lldb::addr_t &load_addr) override;
Todd Fialae77fce02016-09-04 00:18:56 +0000110
Kate Stoneb9c1b512016-09-06 20:57:50 +0000111 NativeThreadDarwinSP GetThreadByID(lldb::tid_t id);
Todd Fialae77fce02016-09-04 00:18:56 +0000112
Kate Stoneb9c1b512016-09-06 20:57:50 +0000113 task_t GetTask() const { return m_task; }
Todd Fialae77fce02016-09-04 00:18:56 +0000114
Kate Stoneb9c1b512016-09-06 20:57:50 +0000115 // -----------------------------------------------------------------
116 // Interface used by NativeRegisterContext-derived classes.
117 // -----------------------------------------------------------------
Zachary Turner97206d52017-05-12 04:51:55 +0000118 static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
119 void *data = nullptr, size_t data_size = 0,
120 long *result = nullptr);
Todd Fialae77fce02016-09-04 00:18:56 +0000121
Kate Stoneb9c1b512016-09-06 20:57:50 +0000122 bool SupportHardwareSingleStepping() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000123
Kate Stoneb9c1b512016-09-06 20:57:50 +0000124protected:
125 // -----------------------------------------------------------------
126 // NativeProcessProtocol protected interface
127 // -----------------------------------------------------------------
Zachary Turner97206d52017-05-12 04:51:55 +0000128 Status
Kate Stoneb9c1b512016-09-06 20:57:50 +0000129 GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
130 size_t &actual_opcode_size,
131 const uint8_t *&trap_opcode_bytes) override;
Todd Fialae77fce02016-09-04 00:18:56 +0000132
Kate Stoneb9c1b512016-09-06 20:57:50 +0000133private:
134 // -----------------------------------------------------------------
135 /// Mach task-related Member Variables
136 // -----------------------------------------------------------------
Todd Fialae77fce02016-09-04 00:18:56 +0000137
Kate Stoneb9c1b512016-09-06 20:57:50 +0000138 // The task port for the inferior process.
139 mutable task_t m_task;
Todd Fialae77fce02016-09-04 00:18:56 +0000140
Kate Stoneb9c1b512016-09-06 20:57:50 +0000141 // True if the inferior process did an exec since we started
142 // monitoring it.
143 bool m_did_exec;
Todd Fialae77fce02016-09-04 00:18:56 +0000144
Kate Stoneb9c1b512016-09-06 20:57:50 +0000145 // The CPU type of this process.
146 mutable cpu_type_t m_cpu_type;
Todd Fialae77fce02016-09-04 00:18:56 +0000147
Kate Stoneb9c1b512016-09-06 20:57:50 +0000148 // -----------------------------------------------------------------
149 /// Exception/Signal Handling Member Variables
150 // -----------------------------------------------------------------
Todd Fialae77fce02016-09-04 00:18:56 +0000151
Kate Stoneb9c1b512016-09-06 20:57:50 +0000152 // Exception port on which we will receive child exceptions
153 mach_port_t m_exception_port;
Todd Fialae77fce02016-09-04 00:18:56 +0000154
Kate Stoneb9c1b512016-09-06 20:57:50 +0000155 // Saved state of the child exception port prior to us installing
156 // our own intercepting port.
157 MachException::PortInfo m_exc_port_info;
Todd Fialae77fce02016-09-04 00:18:56 +0000158
Kate Stoneb9c1b512016-09-06 20:57:50 +0000159 // The thread that runs the Mach exception read and reply handler.
160 pthread_t m_exception_thread;
Todd Fialae77fce02016-09-04 00:18:56 +0000161
Kate Stoneb9c1b512016-09-06 20:57:50 +0000162 // TODO see if we can remove this if we get the exception collection
163 // and distribution to happen in a single-threaded fashion.
164 std::recursive_mutex m_exception_messages_mutex;
Todd Fialae77fce02016-09-04 00:18:56 +0000165
Kate Stoneb9c1b512016-09-06 20:57:50 +0000166 // A collection of exception messages caught when listening to the
167 // exception port.
168 MachException::Message::collection m_exception_messages;
Todd Fialae77fce02016-09-04 00:18:56 +0000169
Kate Stoneb9c1b512016-09-06 20:57:50 +0000170 // When we call MachProcess::Interrupt(), we want to send this
171 // signal (if non-zero).
172 int m_sent_interrupt_signo;
Todd Fialae77fce02016-09-04 00:18:56 +0000173
Kate Stoneb9c1b512016-09-06 20:57:50 +0000174 // If we resume the process and still haven't received our
175 // interrupt signal (if this is non-zero).
176 int m_auto_resume_signo;
Todd Fialae77fce02016-09-04 00:18:56 +0000177
Kate Stoneb9c1b512016-09-06 20:57:50 +0000178 // -----------------------------------------------------------------
179 /// Thread-related Member Variables
180 // -----------------------------------------------------------------
181 NativeThreadListDarwin m_thread_list;
182 ResumeActionList m_thread_actions;
Todd Fialae77fce02016-09-04 00:18:56 +0000183
Kate Stoneb9c1b512016-09-06 20:57:50 +0000184 // -----------------------------------------------------------------
185 /// Process Lifetime Member Variable
186 // -----------------------------------------------------------------
Todd Fialae77fce02016-09-04 00:18:56 +0000187
Kate Stoneb9c1b512016-09-06 20:57:50 +0000188 // The pipe over which the waitpid thread and the main loop will
189 // communicate.
190 Pipe m_waitpid_pipe;
Todd Fialae77fce02016-09-04 00:18:56 +0000191
Kate Stoneb9c1b512016-09-06 20:57:50 +0000192 // The thread that runs the waitpid handler.
193 pthread_t m_waitpid_thread;
Todd Fialae77fce02016-09-04 00:18:56 +0000194
Kate Stoneb9c1b512016-09-06 20:57:50 +0000195 // waitpid reader callback handle.
196 MainLoop::ReadHandleUP m_waitpid_reader_handle;
Todd Fialae77fce02016-09-04 00:18:56 +0000197
Kate Stoneb9c1b512016-09-06 20:57:50 +0000198 // -----------------------------------------------------------------
199 // Private Instance Methods
200 // -----------------------------------------------------------------
201 NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd);
Todd Fialae77fce02016-09-04 00:18:56 +0000202
Kate Stoneb9c1b512016-09-06 20:57:50 +0000203 // -----------------------------------------------------------------
204 /// Finalize the launch.
205 ///
Adrian Prantld8f460e2018-05-02 16:55:16 +0000206 /// This method associates the NativeProcessDarwin instance with the host
207 /// process that was just launched. It peforms actions like attaching a
208 /// listener to the inferior exception port, ptracing the process, and the
209 /// like.
Kate Stoneb9c1b512016-09-06 20:57:50 +0000210 ///
211 /// @param[in] launch_flavor
212 /// The launch flavor that was used to launch the process.
213 ///
214 /// @param[in] main_loop
215 /// The main loop that will run the process monitor. Work
216 /// that needs to be done (e.g. reading files) gets registered
217 /// here along with callbacks to process the work.
218 ///
219 /// @return
220 /// Any error that occurred during the aforementioned
221 /// operations. Failure here will force termination of the
222 /// launched process and debugging session.
223 // -----------------------------------------------------------------
Zachary Turner97206d52017-05-12 04:51:55 +0000224 Status FinalizeLaunch(LaunchFlavor launch_flavor, MainLoop &main_loop);
Todd Fialae77fce02016-09-04 00:18:56 +0000225
Zachary Turner97206d52017-05-12 04:51:55 +0000226 Status SaveExceptionPortInfo();
Todd Fialae77fce02016-09-04 00:18:56 +0000227
Kate Stoneb9c1b512016-09-06 20:57:50 +0000228 void ExceptionMessageReceived(const MachException::Message &message);
Todd Fialae77fce02016-09-04 00:18:56 +0000229
Kate Stoneb9c1b512016-09-06 20:57:50 +0000230 void MaybeRaiseThreadPriority();
Todd Fialae77fce02016-09-04 00:18:56 +0000231
Zachary Turner97206d52017-05-12 04:51:55 +0000232 Status StartExceptionThread();
Todd Fialae77fce02016-09-04 00:18:56 +0000233
Zachary Turner97206d52017-05-12 04:51:55 +0000234 Status SendInferiorExitStatusToMainLoop(::pid_t pid, int status);
Todd Fialae77fce02016-09-04 00:18:56 +0000235
Zachary Turner97206d52017-05-12 04:51:55 +0000236 Status HandleWaitpidResult();
Todd Fialae77fce02016-09-04 00:18:56 +0000237
Kate Stoneb9c1b512016-09-06 20:57:50 +0000238 bool ProcessUsingSpringBoard() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000239
Kate Stoneb9c1b512016-09-06 20:57:50 +0000240 bool ProcessUsingBackBoard() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000241
Kate Stoneb9c1b512016-09-06 20:57:50 +0000242 static void *ExceptionThread(void *arg);
Todd Fialae77fce02016-09-04 00:18:56 +0000243
Kate Stoneb9c1b512016-09-06 20:57:50 +0000244 void *DoExceptionThread();
Todd Fialae77fce02016-09-04 00:18:56 +0000245
Zachary Turner97206d52017-05-12 04:51:55 +0000246 lldb::addr_t GetDYLDAllImageInfosAddress(Status &error) const;
Todd Fialae77fce02016-09-04 00:18:56 +0000247
Kate Stoneb9c1b512016-09-06 20:57:50 +0000248 static uint32_t GetCPUTypeForLocalProcess(::pid_t pid);
Todd Fialae77fce02016-09-04 00:18:56 +0000249
Kate Stoneb9c1b512016-09-06 20:57:50 +0000250 uint32_t GetCPUType() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000251
Kate Stoneb9c1b512016-09-06 20:57:50 +0000252 task_t ExceptionMessageBundleComplete();
Todd Fialae77fce02016-09-04 00:18:56 +0000253
Kate Stoneb9c1b512016-09-06 20:57:50 +0000254 void StartSTDIOThread();
Todd Fialae77fce02016-09-04 00:18:56 +0000255
Zachary Turner97206d52017-05-12 04:51:55 +0000256 Status StartWaitpidThread(MainLoop &main_loop);
Todd Fialae77fce02016-09-04 00:18:56 +0000257
Kate Stoneb9c1b512016-09-06 20:57:50 +0000258 static void *WaitpidThread(void *arg);
Todd Fialae77fce02016-09-04 00:18:56 +0000259
Kate Stoneb9c1b512016-09-06 20:57:50 +0000260 void *DoWaitpidThread();
Todd Fialae77fce02016-09-04 00:18:56 +0000261
Zachary Turner97206d52017-05-12 04:51:55 +0000262 task_t TaskPortForProcessID(Status &error, bool force = false) const;
Todd Fialae77fce02016-09-04 00:18:56 +0000263
Adrian Prantld8f460e2018-05-02 16:55:16 +0000264 /// Attaches to an existing process. Forms the implementation of
265 /// Process::DoAttach.
Zachary Turner97206d52017-05-12 04:51:55 +0000266 void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error);
Todd Fialae77fce02016-09-04 00:18:56 +0000267
Zachary Turner97206d52017-05-12 04:51:55 +0000268 ::pid_t Attach(lldb::pid_t pid, Status &error);
Todd Fialae77fce02016-09-04 00:18:56 +0000269
Zachary Turner97206d52017-05-12 04:51:55 +0000270 Status PrivateResume();
Todd Fialae77fce02016-09-04 00:18:56 +0000271
Zachary Turner97206d52017-05-12 04:51:55 +0000272 Status ReplyToAllExceptions();
Todd Fialae77fce02016-09-04 00:18:56 +0000273
Zachary Turner97206d52017-05-12 04:51:55 +0000274 Status ResumeTask();
Todd Fialae77fce02016-09-04 00:18:56 +0000275
Kate Stoneb9c1b512016-09-06 20:57:50 +0000276 bool IsTaskValid() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000277
Kate Stoneb9c1b512016-09-06 20:57:50 +0000278 bool IsTaskValid(task_t task) const;
Todd Fialae77fce02016-09-04 00:18:56 +0000279
Kate Stoneb9c1b512016-09-06 20:57:50 +0000280 mach_port_t GetExceptionPort() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000281
Kate Stoneb9c1b512016-09-06 20:57:50 +0000282 bool IsExceptionPortValid() const;
Todd Fialae77fce02016-09-04 00:18:56 +0000283
Zachary Turner97206d52017-05-12 04:51:55 +0000284 Status GetTaskBasicInfo(task_t task, struct task_basic_info *info) const;
Todd Fialae77fce02016-09-04 00:18:56 +0000285
Zachary Turner97206d52017-05-12 04:51:55 +0000286 Status SuspendTask();
Todd Fialae77fce02016-09-04 00:18:56 +0000287
Zachary Turner97206d52017-05-12 04:51:55 +0000288 static Status SetDefaultPtraceOpts(const lldb::pid_t);
Todd Fialae77fce02016-09-04 00:18:56 +0000289
Kate Stoneb9c1b512016-09-06 20:57:50 +0000290 static void *MonitorThread(void *baton);
Todd Fialae77fce02016-09-04 00:18:56 +0000291
Kate Stoneb9c1b512016-09-06 20:57:50 +0000292 void MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status);
Todd Fialae77fce02016-09-04 00:18:56 +0000293
Kate Stoneb9c1b512016-09-06 20:57:50 +0000294 void WaitForNewThread(::pid_t tid);
Todd Fialae77fce02016-09-04 00:18:56 +0000295
Kate Stoneb9c1b512016-09-06 20:57:50 +0000296 void MonitorSIGTRAP(const siginfo_t &info, NativeThreadDarwin &thread);
Todd Fialae77fce02016-09-04 00:18:56 +0000297
Kate Stoneb9c1b512016-09-06 20:57:50 +0000298 void MonitorTrace(NativeThreadDarwin &thread);
Todd Fialae77fce02016-09-04 00:18:56 +0000299
Kate Stoneb9c1b512016-09-06 20:57:50 +0000300 void MonitorBreakpoint(NativeThreadDarwin &thread);
Todd Fialae77fce02016-09-04 00:18:56 +0000301
Kate Stoneb9c1b512016-09-06 20:57:50 +0000302 void MonitorWatchpoint(NativeThreadDarwin &thread, uint32_t wp_index);
Todd Fialae77fce02016-09-04 00:18:56 +0000303
Kate Stoneb9c1b512016-09-06 20:57:50 +0000304 void MonitorSignal(const siginfo_t &info, NativeThreadDarwin &thread,
305 bool exited);
Todd Fialae77fce02016-09-04 00:18:56 +0000306
Zachary Turner97206d52017-05-12 04:51:55 +0000307 Status SetupSoftwareSingleStepping(NativeThreadDarwin &thread);
Todd Fialae77fce02016-09-04 00:18:56 +0000308
Kate Stoneb9c1b512016-09-06 20:57:50 +0000309 bool HasThreadNoLock(lldb::tid_t thread_id);
Todd Fialae77fce02016-09-04 00:18:56 +0000310
Kate Stoneb9c1b512016-09-06 20:57:50 +0000311 bool StopTrackingThread(lldb::tid_t thread_id);
Todd Fialae77fce02016-09-04 00:18:56 +0000312
Kate Stoneb9c1b512016-09-06 20:57:50 +0000313 NativeThreadDarwinSP AddThread(lldb::tid_t thread_id);
Todd Fialae77fce02016-09-04 00:18:56 +0000314
Zachary Turner97206d52017-05-12 04:51:55 +0000315 Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
Todd Fialae77fce02016-09-04 00:18:56 +0000316
Zachary Turner97206d52017-05-12 04:51:55 +0000317 Status FixupBreakpointPCAsNeeded(NativeThreadDarwin &thread);
Todd Fialae77fce02016-09-04 00:18:56 +0000318
Kate Stoneb9c1b512016-09-06 20:57:50 +0000319 /// Writes a siginfo_t structure corresponding to the given thread
320 /// ID to the memory region pointed to by @p siginfo.
Zachary Turner97206d52017-05-12 04:51:55 +0000321 Status GetSignalInfo(lldb::tid_t tid, void *siginfo);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000322
323 /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
Adrian Prantld8f460e2018-05-02 16:55:16 +0000324 /// corresponding to the given thread ID to the memory pointed to by @p
325 /// message.
Zachary Turner97206d52017-05-12 04:51:55 +0000326 Status GetEventMessage(lldb::tid_t tid, unsigned long *message);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000327
328 void NotifyThreadDeath(lldb::tid_t tid);
329
Zachary Turner97206d52017-05-12 04:51:55 +0000330 Status Detach(lldb::tid_t tid);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000331
332 // This method is requests a stop on all threads which are still
333 // running. It sets up a deferred delegate notification, which will
334 // fire once threads report as stopped. The triggerring_tid will be
335 // set as the current thread (main stop reason).
336 void StopRunningThreads(lldb::tid_t triggering_tid);
337
338 // Notify the delegate if all threads have stopped.
339 void SignalIfAllThreadsStopped();
340
341 // Resume the given thread, optionally passing it the given signal.
342 // The type of resume operation (continue, single-step) depends on
343 // the state parameter.
Zachary Turner97206d52017-05-12 04:51:55 +0000344 Status ResumeThread(NativeThreadDarwin &thread, lldb::StateType state,
345 int signo);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000346
347 void ThreadWasCreated(NativeThreadDarwin &thread);
348
349 void SigchldHandler();
350};
351
352} // namespace process_darwin
Todd Fialae77fce02016-09-04 00:18:56 +0000353} // namespace lldb_private
354
355#endif /* NativeProcessDarwin_h */