summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachProcess.cpp26
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachProcess.h3
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThread.cpp67
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThread.h12
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp33
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.h2
-rw-r--r--lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h1
-rw-r--r--lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp50
-rw-r--r--lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h23
-rw-r--r--lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h1
-rw-r--r--lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp52
-rw-r--r--lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h23
12 files changed, 188 insertions, 105 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index c5c1e7f6f0c..3ca7fe8abeb 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -115,6 +115,7 @@ MachProcess::MachProcess() :
m_image_infos_baton(NULL)
{
DNBLogThreadedIf(LOG_PROCESS | LOG_VERBOSE, "%s", __PRETTY_FUNCTION__);
+ bzero(&m_arch_plugin_info, sizeof(m_arch_plugin_info));
}
MachProcess::~MachProcess()
@@ -208,7 +209,15 @@ MachProcess::GetThreadInfo(nub_thread_t tid) const
const DNBRegisterSetInfo *
MachProcess::GetRegisterSetInfo(nub_thread_t tid, nub_size_t *num_reg_sets ) const
{
- return DNBArch::GetRegisterSetInfo (num_reg_sets);
+ MachThread *thread = m_thread_list.GetThreadByID (tid);
+ if (thread)
+ {
+ DNBArchProtocol *arch = thread->GetArchProtocol();
+ if (arch)
+ return arch->GetRegisterSetInfo (num_reg_sets);
+ }
+ *num_reg_sets = 0;
+ return NULL;
}
bool
@@ -766,7 +775,7 @@ MachProcess::DisableBreakpoint(nub_break_t breakID, bool remove)
const nub_size_t break_op_size = bp->ByteSize();
assert (break_op_size > 0);
- const uint8_t * const break_op = DNBArch::SoftwareBreakpointOpcode(bp->ByteSize());
+ const uint8_t * const break_op = DNBArchProtocol::GetBreakpointOpcode (bp->ByteSize());
if (break_op_size > 0)
{
// Clear a software breakoint instruction
@@ -954,7 +963,7 @@ MachProcess::EnableBreakpoint(nub_break_t breakID)
const nub_size_t break_op_size = bp->ByteSize();
assert (break_op_size != 0);
- const uint8_t * const break_op = DNBArch::SoftwareBreakpointOpcode(break_op_size);
+ const uint8_t * const break_op = DNBArchProtocol::GetBreakpointOpcode (break_op_size);
if (break_op_size > 0)
{
// Save the original opcode by reading it
@@ -1507,7 +1516,14 @@ MachProcess::LaunchForDebug
break;
case eLaunchFlavorPosixSpawn:
- m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path, argv, envp, stdio_path, this, disable_aslr, launch_err);
+ m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path,
+ m_arch_plugin_info.cpu_type,
+ argv,
+ envp,
+ stdio_path,
+ this,
+ disable_aslr,
+ launch_err);
break;
#if defined (__arm__)
@@ -1590,6 +1606,7 @@ pid_t
MachProcess::PosixSpawnChildForPTraceDebugging
(
const char *path,
+ cpu_type_t cpu_type,
char const *argv[],
char const *envp[],
const char *stdio_path,
@@ -1628,7 +1645,6 @@ MachProcess::PosixSpawnChildForPTraceDebugging
// We don't need to do this for ARM, and we really shouldn't now that we
// have multiple CPU subtypes and no posix_spawnattr call that allows us
// to set which CPU subtype to launch...
- cpu_type_t cpu_type = DNBArch::GetCPUType();
size_t ocount = 0;
err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu_type, &ocount), DNBError::POSIX);
if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
index fa0979d7e20..cff08bb4d68 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -48,7 +48,7 @@ public:
pid_t AttachForDebug (pid_t pid, char *err_str, size_t err_len);
pid_t LaunchForDebug (const char *path, char const *argv[], char const *envp[], const char *stdio_path, nub_launch_flavor_t launch_flavor, int disable_aslr, DNBError &err);
static pid_t ForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], MachProcess* process, DNBError &err);
- static pid_t PosixSpawnChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], const char *stdio_path, MachProcess* process, int disable_aslr, DNBError& err);
+ static pid_t PosixSpawnChildForPTraceDebugging (const char *path, cpu_type_t cpu_type, char const *argv[], char const *envp[], const char *stdio_path, MachProcess* process, int disable_aslr, DNBError& err);
nub_addr_t GetDYLDAllImageInfosAddress ();
static const void * PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str);
static void CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str);
@@ -254,6 +254,7 @@ private:
DNBCallbackCopyExecutableImageInfos
m_image_infos_callback;
void * m_image_infos_baton;
+ DNBArchPluginInfo m_arch_plugin_info;
};
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index ca2bf9b3b3a..ddd7746dad4 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,14 +31,9 @@ MachThread::MachThread (MachProcess *process, thread_t thread) :
m_state_mutex (PTHREAD_MUTEX_RECURSIVE),
m_breakID (INVALID_NUB_BREAK_ID),
m_suspendCount (0),
- m_arch (this),
- m_regSets ()
+ m_arch_ap (DNBArchProtocol::Create (this)),
+ m_reg_sets (m_arch_ap->GetRegisterSetInfo (&n_num_reg_sets))
{
- nub_size_t num_reg_sets = 0;
- const DNBRegisterSetInfo *regSetInfo = m_arch.GetRegisterSetInfo(&num_reg_sets);
- if (num_reg_sets > 0)
- m_regSets.assign(regSetInfo, regSetInfo + num_reg_sets);
-
// Get the thread state so we know if a thread is in a state where we can't
// muck with it and also so we get the suspend count correct in case it was
// already suspended
@@ -251,34 +246,34 @@ MachThread::ThreadIDIsValid(thread_t thread)
bool
MachThread::GetRegisterState(int flavor, bool force)
{
- return m_arch.GetRegisterState(flavor, force) == KERN_SUCCESS;
+ return m_arch_ap->GetRegisterState(flavor, force) == KERN_SUCCESS;
}
bool
MachThread::SetRegisterState(int flavor)
{
- return m_arch.SetRegisterState(flavor) == KERN_SUCCESS;
+ return m_arch_ap->SetRegisterState(flavor) == KERN_SUCCESS;
}
uint64_t
MachThread::GetPC(uint64_t failValue)
{
// Get program counter
- return m_arch.GetPC(failValue);
+ return m_arch_ap->GetPC(failValue);
}
bool
MachThread::SetPC(uint64_t value)
{
// Set program counter
- return m_arch.SetPC(value);
+ return m_arch_ap->SetPC(value);
}
uint64_t
MachThread::GetSP(uint64_t failValue)
{
// Get stack pointer
- return m_arch.GetSP(failValue);
+ return m_arch_ap->GetSP(failValue);
}
nub_process_t
@@ -342,7 +337,7 @@ MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action)
Resume();
break;
}
- m_arch.ThreadWillResume();
+ m_arch_ap->ThreadWillResume();
m_stop_exception.Clear();
}
@@ -372,7 +367,7 @@ MachThread::ShouldStop(bool &step_more)
}
else
{
- if (m_arch.StepNotComplete())
+ if (m_arch_ap->StepNotComplete())
{
step_more = true;
return false;
@@ -426,7 +421,7 @@ MachThread::ThreadDidStop()
// When this method gets called, the process state is still in the
// state it was in while running so we can act accordingly.
- m_arch.ThreadDidStop();
+ m_arch_ap->ThreadDidStop();
// We may have suspended this thread so the primary thread could step
@@ -499,7 +494,7 @@ MachThread::NotifyException(MachException::Data& exc)
{
m_stop_exception = exc;
}
- bool handled = m_arch.NotifyException(exc);
+ bool handled = m_arch_ap->NotifyException(exc);
if (!handled)
{
handled = true;
@@ -551,25 +546,25 @@ MachThread::SetState(nub_state_t state)
uint32_t
MachThread::GetNumRegistersInSet(int regSet) const
{
- if (regSet < m_regSets.size())
- return m_regSets[regSet].num_registers;
+ if (regSet < n_num_reg_sets)
+ return m_reg_sets[regSet].num_registers;
return 0;
}
const char *
MachThread::GetRegisterSetName(int regSet) const
{
- if (regSet < m_regSets.size())
- return m_regSets[regSet].name;
+ if (regSet < n_num_reg_sets)
+ return m_reg_sets[regSet].name;
return NULL;
}
const DNBRegisterInfo *
MachThread::GetRegisterInfo(int regSet, int regIndex) const
{
- if (regSet < m_regSets.size())
- if (regIndex < m_regSets[regSet].num_registers)
- return &m_regSets[regSet].registers[regIndex];
+ if (regSet < n_num_reg_sets)
+ if (regIndex < m_reg_sets[regSet].num_registers)
+ return &m_reg_sets[regSet].registers[regIndex];
return NULL;
}
void
@@ -577,19 +572,19 @@ MachThread::DumpRegisterState(int regSet)
{
if (regSet == REGISTER_SET_ALL)
{
- for (regSet = 1; regSet < m_regSets.size(); regSet++)
+ for (regSet = 1; regSet < n_num_reg_sets; regSet++)
DumpRegisterState(regSet);
}
else
{
- if (m_arch.RegisterSetStateIsValid(regSet))
+ if (m_arch_ap->RegisterSetStateIsValid(regSet))
{
const size_t numRegisters = GetNumRegistersInSet(regSet);
size_t regIndex = 0;
DNBRegisterValueClass reg;
for (regIndex = 0; regIndex < numRegisters; ++regIndex)
{
- if (m_arch.GetRegisterValue(regSet, regIndex, &reg))
+ if (m_arch_ap->GetRegisterValue(regSet, regIndex, &reg))
{
reg.Dump(NULL, NULL);
}
@@ -605,39 +600,39 @@ MachThread::DumpRegisterState(int regSet)
const DNBRegisterSetInfo *
MachThread::GetRegisterSetInfo(nub_size_t *num_reg_sets ) const
{
- *num_reg_sets = m_regSets.size();
- return &m_regSets[0];
+ *num_reg_sets = n_num_reg_sets;
+ return &m_reg_sets[0];
}
bool
MachThread::GetRegisterValue ( uint32_t set, uint32_t reg, DNBRegisterValue *value )
{
- return m_arch.GetRegisterValue(set, reg, value);
+ return m_arch_ap->GetRegisterValue(set, reg, value);
}
bool
MachThread::SetRegisterValue ( uint32_t set, uint32_t reg, const DNBRegisterValue *value )
{
- return m_arch.SetRegisterValue(set, reg, value);
+ return m_arch_ap->SetRegisterValue(set, reg, value);
}
nub_size_t
MachThread::GetRegisterContext (void *buf, nub_size_t buf_len)
{
- return m_arch.GetRegisterContext(buf, buf_len);
+ return m_arch_ap->GetRegisterContext(buf, buf_len);
}
nub_size_t
MachThread::SetRegisterContext (const void *buf, nub_size_t buf_len)
{
- return m_arch.SetRegisterContext(buf, buf_len);
+ return m_arch_ap->SetRegisterContext(buf, buf_len);
}
uint32_t
MachThread::EnableHardwareBreakpoint (const DNBBreakpoint *bp)
{
if (bp != NULL && bp->IsBreakpoint())
- return m_arch.EnableHardwareBreakpoint(bp->Address(), bp->ByteSize());
+ return m_arch_ap->EnableHardwareBreakpoint(bp->Address(), bp->ByteSize());
return INVALID_NUB_HW_INDEX;
}
@@ -645,7 +640,7 @@ uint32_t
MachThread::EnableHardwareWatchpoint (const DNBBreakpoint *wp)
{
if (wp != NULL && wp->IsWatchpoint())
- return m_arch.EnableHardwareWatchpoint(wp->Address(), wp->ByteSize(), wp->WatchpointRead(), wp->WatchpointWrite());
+ return m_arch_ap->EnableHardwareWatchpoint(wp->Address(), wp->ByteSize(), wp->WatchpointRead(), wp->WatchpointWrite());
return INVALID_NUB_HW_INDEX;
}
@@ -653,7 +648,7 @@ bool
MachThread::DisableHardwareBreakpoint (const DNBBreakpoint *bp)
{
if (bp != NULL && bp->IsHardware())
- return m_arch.DisableHardwareBreakpoint(bp->GetHardwareIndex());
+ return m_arch_ap->DisableHardwareBreakpoint(bp->GetHardwareIndex());
return false;
}
@@ -661,7 +656,7 @@ bool
MachThread::DisableHardwareWatchpoint (const DNBBreakpoint *wp)
{
if (wp != NULL && wp->IsHardware())
- return m_arch.DisableHardwareWatchpoint(wp->GetHardwareIndex());
+ return m_arch_ap->DisableHardwareWatchpoint(wp->GetHardwareIndex());
return false;
}
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index f7f2ce8b1ab..0b2a8bf1ff9 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -95,6 +95,13 @@ public:
GetBasicInfo ();
const char * GetBasicInfoAsString () const;
const char * GetName ();
+
+ DNBArchProtocol*
+ GetArchProtocol()
+ {
+ return m_arch_ap.get();
+ }
+
protected:
static bool GetBasicInfo(thread_t threadID, struct thread_basic_info *basic_info);
@@ -113,8 +120,9 @@ protected:
struct thread_basic_info m_basicInfo; // Basic information for a thread used to see if a thread is valid
uint32_t m_suspendCount; // The current suspend count
MachException::Data m_stop_exception; // The best exception that describes why this thread is stopped
- DNBArch m_arch; // Arch specific information for register state and more
- std::vector<DNBRegisterSetInfo> m_regSets; // Register set information for this thread
+ std::auto_ptr<DNBArchProtocol> m_arch_ap; // Arch specific information for register state and more
+ const DNBRegisterSetInfo *const m_reg_sets; // Register set information for this thread
+ nub_size_t n_num_reg_sets;
#ifdef THREAD_IDENTIFIER_INFO_COUNT
thread_identifier_info_data_t m_ident_info;
struct proc_threadinfo m_proc_threadinfo;
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index db2a00a304a..7a5e9bb8588 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -12,6 +12,9 @@
//===----------------------------------------------------------------------===//
#include "MachThreadList.h"
+
+#include <sys/sysctl.h>
+
#include "DNBLog.h"
#include "DNBThreadResumeActions.h"
#include "MachProcess.h"
@@ -104,6 +107,15 @@ MachThreadList::GetThreadInfo(nub_thread_t tid) const
return NULL;
}
+MachThread *
+MachThreadList::GetThreadByID (nub_thread_t tid) const
+{
+ uint32_t idx = GetThreadIndexByID(tid);
+ if (idx < m_threads.size())
+ return m_threads[idx].get();
+ return NULL;
+}
+
bool
MachThreadList::GetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const
{
@@ -202,9 +214,28 @@ uint32_t
MachThreadList::UpdateThreadList(MachProcess *process, bool update)
{
// locker will keep a mutex locked until it goes out of scope
- DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThreadList::UpdateThreadList (pid = %4.4x, update = %u )", process->ProcessID(), update);
+ DNBLogThreadedIf (LOG_THREAD, "MachThreadList::UpdateThreadList (pid = %4.4x, update = %u) process stop count = %u", process->ProcessID(), update, process->StopCount());
PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+#if defined (__i386__) || defined (__x86_64__)
+ if (process->StopCount() == 0)
+ {
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process->ProcessID() };
+ struct kinfo_proc processInfo;
+ size_t bufsize = sizeof(processInfo);
+ bool is_64_bit = false;
+ if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo, &bufsize, NULL, 0) == 0 && bufsize > 0)
+ {
+ if (processInfo.kp_proc.p_flag & P_LP64)
+ is_64_bit = true;
+ }
+ if (is_64_bit)
+ DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_X86_64);
+ else
+ DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_I386);
+ }
+#endif
+
if (m_threads.empty() || update)
{
thread_array_t thread_list = NULL;
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
index 5c813886569..1a17618a7e3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
@@ -55,6 +55,8 @@ public:
bool DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
uint32_t GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
+ MachThread * GetThreadByID (nub_thread_t tid) const;
+
protected:
typedef std::vector<MachThreadSP> collection;
typedef collection::iterator iterator;
diff --git a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h
index f012caa1828..9aff44e5dbc 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h
+++ b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h
@@ -235,6 +235,5 @@ protected:
};
-typedef DNBArchMachARM DNBArch;
#endif // #if defined (__arm__)
#endif // #ifndef __DebugNubArchMachARM_h__
diff --git a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
index 0a0601f6378..1222b809904 100644
--- a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined (__i386__)
+#if defined (__i386__) || defined (__x86_64__)
#include <sys/cdefs.h>
@@ -20,8 +20,6 @@
#include "MachThread.h"
#include "MachProcess.h"
-static const uint8_t g_breakpoint_opcode[] = { 0xCC };
-
enum
{
gpr_eax = 0,
@@ -187,21 +185,6 @@ enum
gdb_mm7 = 48
};
-
-const uint8_t * const
-DNBArchImplI386::SoftwareBreakpointOpcode (nub_size_t byte_size)
-{
- if (byte_size == 1)
- return g_breakpoint_opcode;
- return NULL;
-}
-
-uint32_t
-DNBArchImplI386::GetCPUType()
-{
- return CPU_TYPE_I386;
-}
-
uint64_t
DNBArchImplI386::GetPC(uint64_t failValue)
{
@@ -589,6 +572,21 @@ DNBArchImplI386::g_reg_sets[] =
const size_t DNBArchImplI386::k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo);
+DNBArchProtocol *
+DNBArchImplI386::Create (MachThread *thread)
+{
+ return new DNBArchImplI386 (thread);
+}
+
+const uint8_t * const
+DNBArchImplI386::SoftwareBreakpointOpcode (nub_size_t byte_size)
+{
+ static const uint8_t g_breakpoint_opcode[] = { 0xCC };
+ if (byte_size == 1)
+ return g_breakpoint_opcode;
+ return NULL;
+}
+
const DNBRegisterSetInfo *
DNBArchImplI386::GetRegisterSetInfo(nub_size_t *num_reg_sets)
{
@@ -596,6 +594,22 @@ DNBArchImplI386::GetRegisterSetInfo(nub_size_t *num_reg_sets)
return g_reg_sets;
}
+
+void
+DNBArchImplI386::Initialize()
+{
+ DNBArchPluginInfo arch_plugin_info =
+ {
+ CPU_TYPE_I386,
+ DNBArchImplI386::Create,
+ DNBArchImplI386::GetRegisterSetInfo,
+ DNBArchImplI386::SoftwareBreakpointOpcode
+ };
+
+ // Register this arch plug-in with the main protocol class
+ DNBArchProtocol::RegisterArchPlugin (arch_plugin_info);
+}
+
bool
DNBArchImplI386::GetRegisterValue(int set, int reg, DNBRegisterValue *value)
{
diff --git a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
index 2b47e09cdf3..e0fcc199b5e 100644
--- a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
+++ b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
@@ -14,7 +14,7 @@
#ifndef __DNBArchImplI386_h__
#define __DNBArchImplI386_h__
-#if defined (__i386__)
+#if defined (__i386__) || defined (__x86_64__)
#include "DNBArch.h"
#include <mach/mach_types.h>
@@ -34,9 +34,8 @@ public:
virtual ~DNBArchImplI386()
{
}
-
- static const DNBRegisterSetInfo *
- GetRegisterSetInfo(nub_size_t *num_reg_sets);
+
+ static void Initialize();
virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value);
virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value);
@@ -53,9 +52,6 @@ public:
virtual bool ThreadDidStop();
virtual bool NotifyException(MachException::Data& exc);
- static const uint8_t * const SoftwareBreakpointOpcode (nub_size_t byte_size);
- static uint32_t GetCPUType();
-
protected:
kern_return_t EnableHardwareSingleStep (bool enable);
@@ -186,11 +182,18 @@ protected:
kern_return_t SetFPUState ();
kern_return_t SetEXCState ();
+ static DNBArchProtocol *
+ Create (MachThread *thread);
+
+ static const uint8_t * const
+ SoftwareBreakpointOpcode (nub_size_t byte_size);
+
+ static const DNBRegisterSetInfo *
+ GetRegisterSetInfo(nub_size_t *num_reg_sets);
+
MachThread *m_thread;
State m_state;
};
-typedef DNBArchImplI386 DNBArch;
-
-#endif // #if defined (__i386__)
+#endif // #if defined (__i386__) || defined (__x86_64__)
#endif // #ifndef __DNBArchImplI386_h__
diff --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h
index 6263407460a..a787d14d8d4 100644
--- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h
+++ b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h
@@ -175,6 +175,5 @@ protected:
State m_state;
};
-typedef DNBArchMachPPC DNBArch;
#endif // #if defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
#endif // #ifndef __DebugNubArchMachPPC_h__
diff --git a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
index 1f18156650c..fde3be6ab5d 100644
--- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined (__x86_64__)
+#if defined (__i386__) || defined (__x86_64__)
#include <sys/cdefs.h>
@@ -20,22 +20,6 @@
#include "MachThread.h"
#include "MachProcess.h"
-static const uint8_t g_breakpoint_opcode[] = { 0xCC };
-
-const uint8_t * const
-DNBArchImplX86_64::SoftwareBreakpointOpcode (nub_size_t byte_size)
-{
- if (byte_size == 1)
- return g_breakpoint_opcode;
- return NULL;
-}
-
-uint32_t
-DNBArchImplX86_64::GetCPUType()
-{
- return CPU_TYPE_X86_64;
-}
-
uint64_t
DNBArchImplX86_64::GetPC(uint64_t failValue)
{
@@ -718,13 +702,43 @@ DNBArchImplX86_64::g_reg_sets[] =
const size_t DNBArchImplX86_64::k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo);
+DNBArchProtocol *
+DNBArchImplX86_64::Create (MachThread *thread)
+{
+ return new DNBArchImplX86_64 (thread);
+}
+
+const uint8_t * const
+DNBArchImplX86_64::SoftwareBreakpointOpcode (nub_size_t byte_size)
+{
+ static const uint8_t g_breakpoint_opcode[] = { 0xCC };
+ if (byte_size == 1)
+ return g_breakpoint_opcode;
+ return NULL;
+}
+
const DNBRegisterSetInfo *
-DNBArchImplX86_64::GetRegisterSetInfo (nub_size_t *num_reg_sets)
+DNBArchImplX86_64::GetRegisterSetInfo(nub_size_t *num_reg_sets)
{
*num_reg_sets = k_num_register_sets;
return g_reg_sets;
}
+void
+DNBArchImplX86_64::Initialize()
+{
+ DNBArchPluginInfo arch_plugin_info =
+ {
+ CPU_TYPE_X86_64,
+ DNBArchImplX86_64::Create,
+ DNBArchImplX86_64::GetRegisterSetInfo,
+ DNBArchImplX86_64::SoftwareBreakpointOpcode
+ };
+
+ // Register this arch plug-in with the main protocol class
+ DNBArchProtocol::RegisterArchPlugin (arch_plugin_info);
+}
+
bool
DNBArchImplX86_64::GetRegisterValue(int set, int reg, DNBRegisterValue *value)
{
@@ -1032,4 +1046,4 @@ DNBArchImplX86_64::RegisterSetStateIsValid (int set) const
-#endif // #if defined (__i386__)
+#endif // #if defined (__i386__) || defined (__x86_64__)
diff --git a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
index def263fec5e..584943c85c7 100644
--- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
+++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
@@ -14,8 +14,7 @@
#ifndef __DNBArchImplX86_64_h__
#define __DNBArchImplX86_64_h__
-//#if defined (__i386__)
-#if defined(__x86_64__)
+#if defined (__i386__) || defined (__x86_64__)
#include "DNBArch.h"
#include <mach/mach_types.h>
#include <mach/thread_status.h>
@@ -35,9 +34,7 @@ public:
{
}
- static const DNBRegisterSetInfo *
- GetRegisterSetInfo(nub_size_t *num_reg_sets);
-
+ static void Initialize();
virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value);
virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value);
virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len);
@@ -54,9 +51,6 @@ public:
virtual bool ThreadDidStop();
virtual bool NotifyException(MachException::Data& exc);
- static const uint8_t * const SoftwareBreakpointOpcode (nub_size_t byte_size);
- static uint32_t GetCPUType();
-
protected:
kern_return_t EnableHardwareSingleStep (bool enable);
@@ -189,11 +183,18 @@ protected:
kern_return_t SetFPUState ();
kern_return_t SetEXCState ();
+ static DNBArchProtocol *
+ Create (MachThread *thread);
+
+ static const uint8_t * const
+ SoftwareBreakpointOpcode (nub_size_t byte_size);
+
+ static const DNBRegisterSetInfo *
+ GetRegisterSetInfo(nub_size_t *num_reg_sets);
+
MachThread *m_thread;
State m_state;
};
-typedef DNBArchImplX86_64 DNBArch;
-
-#endif // #if defined (__x86_64__)
+#endif // #if defined (__i386__) || defined (__x86_64__)
#endif // #ifndef __DNBArchImplX86_64_h__
OpenPOWER on IntegriCloud