summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachTask.h
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX/MachTask.h')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachTask.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.h b/lldb/tools/debugserver/source/MacOSX/MachTask.h
new file mode 100644
index 00000000000..3bf40e13457
--- /dev/null
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.h
@@ -0,0 +1,91 @@
+//===-- MachTask.h ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//----------------------------------------------------------------------
+//
+// MachTask.h
+// debugserver
+//
+// Created by Greg Clayton on 12/5/08.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __MachTask_h__
+#define __MachTask_h__
+
+// C Includes
+#include <mach/mach.h>
+#include <sys/socket.h>
+// C++ Includes
+#include <map>
+// Other libraries and framework includes
+// Project includes
+#include "MachException.h"
+#include "MachVMMemory.h"
+#include "PThreadMutex.h"
+
+class MachProcess;
+
+class MachTask
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ MachTask (MachProcess *process);
+ virtual ~MachTask ();
+
+ void Clear ();
+
+ kern_return_t Suspend ();
+ kern_return_t Resume ();
+
+ nub_size_t ReadMemory (nub_addr_t addr, nub_size_t size, void *buf);
+ nub_size_t WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf);
+
+ nub_addr_t AllocateMemory (nub_size_t size, uint32_t permissions);
+ nub_bool_t DeallocateMemory (nub_addr_t addr);
+
+ mach_port_t ExceptionPort () const;
+ bool ExceptionPortIsValid () const;
+ kern_return_t SaveExceptionPortInfo ();
+ kern_return_t RestoreExceptionPortInfo ();
+ kern_return_t ShutDownExcecptionThread ();
+
+ bool StartExceptionThread (DNBError &err);
+ nub_addr_t GetDYLDAllImageInfosAddress (DNBError& err);
+ kern_return_t BasicInfo (struct task_basic_info *info);
+ static kern_return_t BasicInfo (task_t task, struct task_basic_info *info);
+ bool IsValid () const;
+ static bool IsValid (task_t task);
+ static void * ExceptionThread (void *arg);
+ task_t TaskPort () const { return m_task; }
+ task_t TaskPortForProcessID (DNBError &err);
+ static task_t TaskPortForProcessID (pid_t pid, DNBError &err);
+
+ MachProcess * Process () { return m_process; }
+ const MachProcess * Process () const { return m_process; }
+
+protected:
+ MachProcess * m_process; // The mach process that owns this MachTask
+ task_t m_task;
+ MachVMMemory m_vm_memory; // Special mach memory reading class that will take care of watching for page and region boundaries
+ MachException::PortInfo
+ m_exc_port_info; // Saved settings for all exception ports
+ pthread_t m_exception_thread; // Thread ID for the exception thread in case we need it
+ mach_port_t m_exception_port; // Exception port on which we will receive child exceptions
+
+ typedef std::map <mach_vm_address_t, size_t> allocation_collection;
+ allocation_collection m_allocations;
+
+private:
+ MachTask(const MachTask&); // Outlaw
+ MachTask& operator=(const MachTask& rhs);// Outlaw
+};
+
+#endif // __MachTask_h__
OpenPOWER on IntegriCloud