blob: e31486cc39b6d00ed31be37e808c6ae145a0afc6 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- MachProcess.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
Chris Lattner30fdc8d2010-06-08 16:52:24 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Created by Greg Clayton on 6/15/07.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef __MachProcess_h__
14#define __MachProcess_h__
15
Kate Stoneb9c1b512016-09-06 20:57:50 +000016#include <CoreFoundation/CoreFoundation.h>
Jason Molendaa2992312016-07-07 01:09:23 +000017#include <mach-o/loader.h>
Kate Stoneb9c1b512016-09-06 20:57:50 +000018#include <mach/mach.h>
Jason Molendac611a742015-10-23 02:49:51 +000019#include <pthread.h>
Kate Stoneb9c1b512016-09-06 20:57:50 +000020#include <sys/signal.h>
Jason Molendaa2992312016-07-07 01:09:23 +000021#include <uuid/uuid.h>
Jason Molendac611a742015-10-23 02:49:51 +000022#include <vector>
Jason Molendac611a742015-10-23 02:49:51 +000023
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024#include "DNBBreakpoint.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000025#include "DNBDefs.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "DNBError.h"
Greg Claytonc4e411f2011-01-18 19:36:39 +000027#include "DNBThreadResumeActions.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000028#include "Genealogy.h"
29#include "JSONGenerator.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000030#include "MachException.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031#include "MachTask.h"
32#include "MachThreadList.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000033#include "MachVMMemory.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034#include "PThreadCondition.h"
35#include "PThreadEvent.h"
36#include "PThreadMutex.h"
Jason Molenda705b1802014-06-13 02:37:02 +000037#include "ThreadInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039class DNBThreadResumeActions;
40
Kate Stoneb9c1b512016-09-06 20:57:50 +000041class MachProcess {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000043 // Constructors and Destructors
Kate Stoneb9c1b512016-09-06 20:57:50 +000044 MachProcess();
45 ~MachProcess();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000046
Kate Stoneb9c1b512016-09-06 20:57:50 +000047 // A structure that can hold everything debugserver needs to know from
48 // a binary's Mach-O header / load commands.
Jason Molendaa2992312016-07-07 01:09:23 +000049
Kate Stoneb9c1b512016-09-06 20:57:50 +000050 struct mach_o_segment {
51 std::string name;
52 uint64_t vmaddr;
53 uint64_t vmsize;
54 uint64_t fileoff;
55 uint64_t filesize;
56 uint64_t maxprot;
57 uint64_t initprot;
58 uint64_t nsects;
59 uint64_t flags;
60 };
Jason Molendaa2992312016-07-07 01:09:23 +000061
Kate Stoneb9c1b512016-09-06 20:57:50 +000062 struct mach_o_information {
63 struct mach_header_64 mach_header;
64 std::vector<struct mach_o_segment> segments;
65 uuid_t uuid;
66 std::string min_version_os_name;
67 std::string min_version_os_version;
68 };
Jason Molendaa2992312016-07-07 01:09:23 +000069
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 struct binary_image_information {
71 std::string filename;
72 uint64_t load_address;
73 uint64_t mod_date; // may not be available - 0 if so
74 struct mach_o_information macho_info;
Jason Molendaa2992312016-07-07 01:09:23 +000075
Kate Stoneb9c1b512016-09-06 20:57:50 +000076 binary_image_information()
77 : filename(), load_address(INVALID_NUB_ADDRESS), mod_date(0) {}
78 };
Jason Molendaa2992312016-07-07 01:09:23 +000079
Kate Stoneb9c1b512016-09-06 20:57:50 +000080 // Child process control
Kate Stoneb9c1b512016-09-06 20:57:50 +000081 pid_t AttachForDebug(pid_t pid, char *err_str, size_t err_len);
82 pid_t LaunchForDebug(const char *path, char const *argv[], char const *envp[],
83 const char *working_directory, const char *stdin_path,
84 const char *stdout_path, const char *stderr_path,
85 bool no_stdio, nub_launch_flavor_t launch_flavor,
86 int disable_aslr, const char *event_data, DNBError &err);
Greg Clayton71337622011-02-24 22:24:29 +000087
Kate Stoneb9c1b512016-09-06 20:57:50 +000088 static uint32_t GetCPUTypeForLocalProcess(pid_t pid);
89 static pid_t ForkChildForPTraceDebugging(const char *path, char const *argv[],
90 char const *envp[],
91 MachProcess *process, DNBError &err);
92 static pid_t PosixSpawnChildForPTraceDebugging(
93 const char *path, cpu_type_t cpu_type, char const *argv[],
94 char const *envp[], const char *working_directory, const char *stdin_path,
95 const char *stdout_path, const char *stderr_path, bool no_stdio,
96 MachProcess *process, int disable_aslr, DNBError &err);
97 nub_addr_t GetDYLDAllImageInfosAddress();
98 static const void *PrepareForAttach(const char *path,
99 nub_launch_flavor_t launch_flavor,
100 bool waitfor, DNBError &err_str);
101 static void CleanupAfterAttach(const void *attach_token,
102 nub_launch_flavor_t launch_flavor,
103 bool success, DNBError &err_str);
104 static nub_process_t CheckForProcess(const void *attach_token,
105 nub_launch_flavor_t launch_flavor);
Jason Molendac611a742015-10-23 02:49:51 +0000106#if defined(WITH_BKS) || defined(WITH_FBS)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000107 pid_t BoardServiceLaunchForDebug(const char *app_bundle_path,
108 char const *argv[], char const *envp[],
109 bool no_stdio, bool disable_aslr,
110 const char *event_data,
111 DNBError &launch_err);
112 pid_t BoardServiceForkChildForPTraceDebugging(
113 const char *path, char const *argv[], char const *envp[], bool no_stdio,
114 bool disable_aslr, const char *event_data, DNBError &launch_err);
115 bool BoardServiceSendEvent(const char *event, DNBError &error);
Jason Molendac611a742015-10-23 02:49:51 +0000116#endif
Kate Stoneb9c1b512016-09-06 20:57:50 +0000117 static bool GetOSVersionNumbers(uint64_t *major, uint64_t *minor,
118 uint64_t *patch);
Jason Molenda6cebeaf2019-08-07 02:06:06 +0000119 static std::string GetMacCatalystVersionString();
Jason Molendaa3329782014-03-29 18:54:20 +0000120#ifdef WITH_BKS
Kate Stoneb9c1b512016-09-06 20:57:50 +0000121 static void BKSCleanupAfterAttach(const void *attach_token,
122 DNBError &err_str);
Jason Molendac611a742015-10-23 02:49:51 +0000123#endif // WITH_BKS
124#ifdef WITH_FBS
Kate Stoneb9c1b512016-09-06 20:57:50 +0000125 static void FBSCleanupAfterAttach(const void *attach_token,
126 DNBError &err_str);
127#endif // WITH_FBS
Jason Molenda42999a42012-02-22 02:18:59 +0000128#ifdef WITH_SPRINGBOARD
Kate Stoneb9c1b512016-09-06 20:57:50 +0000129 pid_t SBLaunchForDebug(const char *app_bundle_path, char const *argv[],
130 char const *envp[], bool no_stdio, bool disable_aslr,
131 DNBError &launch_err);
132 static pid_t SBForkChildForPTraceDebugging(const char *path,
133 char const *argv[],
134 char const *envp[], bool no_stdio,
135 MachProcess *process,
136 DNBError &launch_err);
137#endif // WITH_SPRINGBOARD
138 nub_addr_t LookupSymbol(const char *name, const char *shlib);
139 void SetNameToAddressCallback(DNBCallbackNameToAddress callback,
140 void *baton) {
141 m_name_to_addr_callback = callback;
142 m_name_to_addr_baton = baton;
143 }
144 void
145 SetSharedLibraryInfoCallback(DNBCallbackCopyExecutableImageInfos callback,
146 void *baton) {
147 m_image_infos_callback = callback;
148 m_image_infos_baton = baton;
149 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000150
Kate Stoneb9c1b512016-09-06 20:57:50 +0000151 bool Resume(const DNBThreadResumeActions &thread_actions);
152 bool Signal(int signal, const struct timespec *timeout_abstime = NULL);
153 bool Interrupt();
154 bool SendEvent(const char *event, DNBError &send_err);
155 bool Kill(const struct timespec *timeout_abstime = NULL);
156 bool Detach();
157 nub_size_t ReadMemory(nub_addr_t addr, nub_size_t size, void *buf);
158 nub_size_t WriteMemory(nub_addr_t addr, nub_size_t size, const void *buf);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000159
Kate Stoneb9c1b512016-09-06 20:57:50 +0000160 // Path and arg accessors
Kate Stoneb9c1b512016-09-06 20:57:50 +0000161 const char *Path() const { return m_path.c_str(); }
162 size_t ArgumentCount() const { return m_args.size(); }
163 const char *ArgumentAtIndex(size_t arg_idx) const {
164 if (arg_idx < m_args.size())
165 return m_args[arg_idx].c_str();
166 return NULL;
167 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000168
Kate Stoneb9c1b512016-09-06 20:57:50 +0000169 // Breakpoint functions
Kate Stoneb9c1b512016-09-06 20:57:50 +0000170 DNBBreakpoint *CreateBreakpoint(nub_addr_t addr, nub_size_t length,
171 bool hardware);
172 bool DisableBreakpoint(nub_addr_t addr, bool remove);
173 void DisableAllBreakpoints(bool remove);
174 bool EnableBreakpoint(nub_addr_t addr);
175 DNBBreakpointList &Breakpoints() { return m_breakpoints; }
176 const DNBBreakpointList &Breakpoints() const { return m_breakpoints; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000177
Kate Stoneb9c1b512016-09-06 20:57:50 +0000178 // Watchpoint functions
Kate Stoneb9c1b512016-09-06 20:57:50 +0000179 DNBBreakpoint *CreateWatchpoint(nub_addr_t addr, nub_size_t length,
180 uint32_t watch_type, bool hardware);
181 bool DisableWatchpoint(nub_addr_t addr, bool remove);
182 void DisableAllWatchpoints(bool remove);
183 bool EnableWatchpoint(nub_addr_t addr);
184 uint32_t GetNumSupportedHardwareWatchpoints() const;
185 DNBBreakpointList &Watchpoints() { return m_watchpoints; }
186 const DNBBreakpointList &Watchpoints() const { return m_watchpoints; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000187
Kate Stoneb9c1b512016-09-06 20:57:50 +0000188 // Exception thread functions
Kate Stoneb9c1b512016-09-06 20:57:50 +0000189 bool StartSTDIOThread();
190 static void *STDIOThread(void *arg);
191 void ExceptionMessageReceived(const MachException::Message &exceptionMessage);
192 task_t ExceptionMessageBundleComplete();
193 void SharedLibrariesUpdated();
194 nub_size_t CopyImageInfos(struct DNBExecutableImageInfo **image_infos,
195 bool only_changed);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000196
Kate Stoneb9c1b512016-09-06 20:57:50 +0000197 // Profile functions
Kate Stoneb9c1b512016-09-06 20:57:50 +0000198 void SetEnableAsyncProfiling(bool enable, uint64_t internal_usec,
199 DNBProfileDataScanType scan_type);
200 bool IsProfilingEnabled() { return m_profile_enabled; }
201 useconds_t ProfileInterval() { return m_profile_interval_usec; }
202 bool StartProfileThread();
203 static void *ProfileThread(void *arg);
204 void SignalAsyncProfileData(const char *info);
205 size_t GetAsyncProfileData(char *buf, size_t buf_size);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000206
Kate Stoneb9c1b512016-09-06 20:57:50 +0000207 // Accessors
Kate Stoneb9c1b512016-09-06 20:57:50 +0000208 pid_t ProcessID() const { return m_pid; }
209 bool ProcessIDIsValid() const { return m_pid > 0; }
210 pid_t SetProcessID(pid_t pid);
211 MachTask &Task() { return m_task; }
212 const MachTask &Task() const { return m_task; }
Jason Molendaa2992312016-07-07 01:09:23 +0000213
Kate Stoneb9c1b512016-09-06 20:57:50 +0000214 PThreadEvent &Events() { return m_events; }
215 const DNBRegisterSetInfo *GetRegisterSetInfo(nub_thread_t tid,
216 nub_size_t *num_reg_sets) const;
217 bool GetRegisterValue(nub_thread_t tid, uint32_t set, uint32_t reg,
218 DNBRegisterValue *reg_value) const;
219 bool SetRegisterValue(nub_thread_t tid, uint32_t set, uint32_t reg,
220 const DNBRegisterValue *value) const;
221 nub_bool_t SyncThreadState(nub_thread_t tid);
222 const char *ThreadGetName(nub_thread_t tid);
223 nub_state_t ThreadGetState(nub_thread_t tid);
224 ThreadInfo::QoS GetRequestedQoS(nub_thread_t tid, nub_addr_t tsd,
225 uint64_t dti_qos_class_index);
226 nub_addr_t GetPThreadT(nub_thread_t tid);
227 nub_addr_t GetDispatchQueueT(nub_thread_t tid);
228 nub_addr_t
229 GetTSDAddressForThread(nub_thread_t tid,
230 uint64_t plo_pthread_tsd_base_address_offset,
231 uint64_t plo_pthread_tsd_base_offset,
232 uint64_t plo_pthread_tsd_entry_size);
Frederic Risscd90f872018-04-06 04:28:12 +0000233 const char *
234 GetDeploymentInfo(const struct load_command&, uint64_t load_command_address,
235 uint32_t& major_version, uint32_t& minor_version,
236 uint32_t& patch_version);
Jason Molenda6cebeaf2019-08-07 02:06:06 +0000237 bool GetMachOInformationFromMemory(uint32_t platform,
238 nub_addr_t mach_o_header_addr,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000239 int wordsize,
240 struct mach_o_information &inf);
241 JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
242 const std::vector<struct binary_image_information> &image_infos);
Jason Molenda6cebeaf2019-08-07 02:06:06 +0000243 uint32_t GetAllLoadedBinariesViaDYLDSPI(
Kate Stoneb9c1b512016-09-06 20:57:50 +0000244 std::vector<struct binary_image_information> &image_infos);
245 JSONGenerator::ObjectSP GetLoadedDynamicLibrariesInfos(
246 nub_process_t pid, nub_addr_t image_list_address, nub_addr_t image_count);
247 JSONGenerator::ObjectSP
248 GetLibrariesInfoForAddresses(nub_process_t pid,
249 std::vector<uint64_t> &macho_addresses);
250 JSONGenerator::ObjectSP GetAllLoadedLibrariesInfos(nub_process_t pid);
251 JSONGenerator::ObjectSP GetSharedCacheInfo(nub_process_t pid);
Jason Molenda705b1802014-06-13 02:37:02 +0000252
Kate Stoneb9c1b512016-09-06 20:57:50 +0000253 nub_size_t GetNumThreads() const;
254 nub_thread_t GetThreadAtIndex(nub_size_t thread_idx) const;
255 nub_thread_t GetCurrentThread();
256 nub_thread_t GetCurrentThreadMachPort();
257 nub_thread_t SetCurrentThread(nub_thread_t tid);
258 MachThreadList &GetThreadList() { return m_thread_list; }
259 bool GetThreadStoppedReason(nub_thread_t tid,
260 struct DNBThreadStopInfo *stop_info);
261 void DumpThreadStoppedReason(nub_thread_t tid) const;
262 const char *GetThreadInfo(nub_thread_t tid) const;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000263
Kate Stoneb9c1b512016-09-06 20:57:50 +0000264 nub_thread_t GetThreadIDForMachPortNumber(thread_t mach_port_number) const;
Jason Molenda1c739112013-02-22 07:27:08 +0000265
Kate Stoneb9c1b512016-09-06 20:57:50 +0000266 uint32_t GetCPUType();
267 nub_state_t GetState();
268 void SetState(nub_state_t state);
269 bool IsRunning(nub_state_t state) {
270 return state == eStateRunning || IsStepping(state);
271 }
272 bool IsStepping(nub_state_t state) { return state == eStateStepping; }
273 bool CanResume(nub_state_t state) { return state == eStateStopped; }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000274
Kate Stoneb9c1b512016-09-06 20:57:50 +0000275 bool GetExitStatus(int *status) {
276 if (GetState() == eStateExited) {
277 if (status)
278 *status = m_exit_status;
279 return true;
280 }
281 return false;
282 }
283 void SetExitStatus(int status) {
284 m_exit_status = status;
285 SetState(eStateExited);
286 }
287 const char *GetExitInfo() { return m_exit_info.c_str(); }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000288
Kate Stoneb9c1b512016-09-06 20:57:50 +0000289 void SetExitInfo(const char *info);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000290
Kate Stoneb9c1b512016-09-06 20:57:50 +0000291 uint32_t StopCount() const { return m_stop_count; }
292 void SetChildFileDescriptors(int stdin_fileno, int stdout_fileno,
293 int stderr_fileno) {
294 m_child_stdin = stdin_fileno;
295 m_child_stdout = stdout_fileno;
296 m_child_stderr = stderr_fileno;
297 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000298
Kate Stoneb9c1b512016-09-06 20:57:50 +0000299 int GetStdinFileDescriptor() const { return m_child_stdin; }
300 int GetStdoutFileDescriptor() const { return m_child_stdout; }
301 int GetStderrFileDescriptor() const { return m_child_stderr; }
302 void AppendSTDOUT(char *s, size_t len);
303 size_t GetAvailableSTDOUT(char *buf, size_t buf_size);
304 size_t GetAvailableSTDERR(char *buf, size_t buf_size);
305 void CloseChildFileDescriptors() {
306 if (m_child_stdin >= 0) {
307 ::close(m_child_stdin);
308 m_child_stdin = -1;
309 }
310 if (m_child_stdout >= 0) {
311 ::close(m_child_stdout);
312 m_child_stdout = -1;
313 }
314 if (m_child_stderr >= 0) {
315 ::close(m_child_stderr);
316 m_child_stderr = -1;
317 }
318 }
Jason Molenda567b1542014-06-13 02:44:21 +0000319
Jason Molenda3bf883e2019-02-15 22:39:30 +0000320 void CalculateBoardStatus();
321
322 bool ProcessUsingBackBoard();
323
324 bool ProcessUsingFrontBoard();
Jason Molenda705b1802014-06-13 02:37:02 +0000325
Kate Stoneb9c1b512016-09-06 20:57:50 +0000326 Genealogy::ThreadActivitySP GetGenealogyInfoForThread(nub_thread_t tid,
327 bool &timed_out);
Jason Molenda567b1542014-06-13 02:44:21 +0000328
Kate Stoneb9c1b512016-09-06 20:57:50 +0000329 Genealogy::ProcessExecutableInfoSP GetGenealogyImageInfo(size_t idx);
330
331 DNBProfileDataScanType GetProfileScanType() { return m_profile_scan_type; }
Jason Molenda567b1542014-06-13 02:44:21 +0000332
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000333private:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000334 enum {
335 eMachProcessFlagsNone = 0,
336 eMachProcessFlagsAttached = (1 << 0),
Jason Molenda3bf883e2019-02-15 22:39:30 +0000337 eMachProcessFlagsUsingBKS = (1 << 2), // only read via ProcessUsingBackBoard()
338 eMachProcessFlagsUsingFBS = (1 << 3), // only read via ProcessUsingFrontBoard()
339 eMachProcessFlagsBoardCalculated = (1 << 4)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000340 };
341 void Clear(bool detaching = false);
342 void ReplyToAllExceptions();
343 void PrivateResume();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000344
Kate Stoneb9c1b512016-09-06 20:57:50 +0000345 uint32_t Flags() const { return m_flags; }
346 nub_state_t DoSIGSTOP(bool clear_bps_and_wps, bool allow_running,
347 uint32_t *thread_idx_ptr);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000348
Kate Stoneb9c1b512016-09-06 20:57:50 +0000349 pid_t m_pid; // Process ID of child process
350 cpu_type_t m_cpu_type; // The CPU type of this process
351 int m_child_stdin;
352 int m_child_stdout;
353 int m_child_stderr;
354 std::string m_path; // A path to the executable if we have one
355 std::vector<std::string>
356 m_args; // The arguments with which the process was lauched
357 int m_exit_status; // The exit status for the process
358 std::string m_exit_info; // Any extra info that we may have about the exit
359 MachTask m_task; // The mach task for this process
360 uint32_t m_flags; // Process specific flags (see eMachProcessFlags enums)
361 uint32_t m_stop_count; // A count of many times have we stopped
362 pthread_t m_stdio_thread; // Thread ID for the thread that watches for child
363 // process stdio
364 PThreadMutex m_stdio_mutex; // Multithreaded protection for stdio
365 std::string m_stdout_data;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000366
Kate Stoneb9c1b512016-09-06 20:57:50 +0000367 bool m_profile_enabled; // A flag to indicate if profiling is enabled
368 useconds_t m_profile_interval_usec; // If enable, the profiling interval in
369 // microseconds
370 DNBProfileDataScanType
371 m_profile_scan_type; // Indicates what needs to be profiled
372 pthread_t
373 m_profile_thread; // Thread ID for the thread that profiles the inferior
374 PThreadMutex
375 m_profile_data_mutex; // Multithreaded protection for profile info data
376 std::vector<std::string>
377 m_profile_data; // Profile data, must be protected by m_profile_data_mutex
Jason Molendaa2992312016-07-07 01:09:23 +0000378
Kate Stoneb9c1b512016-09-06 20:57:50 +0000379 DNBThreadResumeActions m_thread_actions; // The thread actions for the current
380 // MachProcess::Resume() call
381 MachException::Message::collection m_exception_messages; // A collection of
382 // exception messages
383 // caught when
384 // listening to the
385 // exception port
386 PThreadMutex m_exception_messages_mutex; // Multithreaded protection for
387 // m_exception_messages
388
389 MachThreadList m_thread_list; // A list of threads that is maintained/updated
390 // after each stop
391 Genealogy m_activities; // A list of activities that is updated after every
392 // stop lazily
393 nub_state_t m_state; // The state of our process
394 PThreadMutex m_state_mutex; // Multithreaded protection for m_state
395 PThreadEvent m_events; // Process related events in the child processes
396 // lifetime can be waited upon
397 PThreadEvent m_private_events; // Used to coordinate running and stopping the
398 // process without affecting m_events
399 DNBBreakpointList m_breakpoints; // Breakpoint list for this process
400 DNBBreakpointList m_watchpoints; // Watchpoint list for this process
401 DNBCallbackNameToAddress m_name_to_addr_callback;
402 void *m_name_to_addr_baton;
403 DNBCallbackCopyExecutableImageInfos m_image_infos_callback;
404 void *m_image_infos_baton;
405 std::string
406 m_bundle_id; // If we are a SB or BKS process, this will be our bundle ID.
407 int m_sent_interrupt_signo; // When we call MachProcess::Interrupt(), we want
408 // to send a single signal
409 // to the inferior and only send the signal if we aren't already stopped.
410 // If we end up sending a signal to stop the process we store it until we
411 // receive an exception with this signal. This helps us to verify we got
412 // the signal that interrupted the process. We might stop due to another
413 // reason after an interrupt signal is sent, so this helps us ensure that
414 // we don't report a spurious stop on the next resume.
415 int m_auto_resume_signo; // If we resume the process and still haven't
416 // received our interrupt signal
417 // acknownledgement, we will shortly after the next resume. We store the
418 // interrupt signal in this variable so when we get the interrupt signal
419 // as the sole reason for the process being stopped, we can auto resume
420 // the process.
421 bool m_did_exec;
422
423 void *(*m_dyld_process_info_create)(task_t task, uint64_t timestamp,
424 kern_return_t *kernelError);
425 void (*m_dyld_process_info_for_each_image)(
426 void *info, void (^callback)(uint64_t machHeaderAddress,
427 const uuid_t uuid, const char *path));
428 void (*m_dyld_process_info_release)(void *info);
429 void (*m_dyld_process_info_get_cache)(void *info, void *cacheInfo);
Jason Molenda6cebeaf2019-08-07 02:06:06 +0000430 uint32_t (*m_dyld_process_info_get_platform)(void *info);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000431};
432
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000433#endif // __MachProcess_h__