[Lldb-commits] [lldb] r175870 - Change debugserver from using the mach port number (in debugserver's
Jason Molenda
jmolenda at apple.com
Thu Feb 21 23:27:08 PST 2013
Author: jmolenda
Date: Fri Feb 22 01:27:08 2013
New Revision: 175870
URL: http://llvm.org/viewvc/llvm-project?rev=175870&view=rev
Log:
Change debugserver from using the mach port number (in debugserver's
own port namepsace) as the thread identifier to using the system-wide
globally unique thread id as the thread identifier number.
MachThread.cpp keeps both the unique id and the mach port number
for each thread. All layers outside MachThread class use the unique
id with three exceptions: (1) Mach exceptions come in with the port
number (thread_port) which needs to be translated, (2) any calls to
low-level thread_get_state/thread_set_state/thread_suspend etc need
to use the mach port number, (3) MachThreadList::UpdateThreadList
which creates the MachThread objects gets the unique id and passes
it to the MachThread ctor as an argument.
In general, any time nub_thread_t is used, it is now referring to a
unique thread id. Any time a thread_t is used, it is now referring
to a mach port number. There was some interchangability of these
types previously. nub_thread_t has also been changed to a 64-bit
type which necessitated some printf specification string changes.
I haven't been able to test these changes extensively yet but want
to checkpoint the work. The scenarios I've been testing are all
working correctly so while there may be some corner cases I haven't
hit yet, I think it is substantially correct.
<rdar://problem/12931414>
Modified:
lldb/trunk/tools/debugserver/source/DNB.cpp
lldb/trunk/tools/debugserver/source/DNBBreakpoint.cpp
lldb/trunk/tools/debugserver/source/DNBDefs.h
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.h
lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
Modified: lldb/trunk/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNB.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNB.cpp Fri Feb 22 01:27:08 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "DNB.h"
+#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1385,7 +1386,7 @@ DNBPrintf (nub_process_t pid, nub_thread
}
else
{
- fprintf(file, "error: unable to read register '%s' for process %#.4x and thread %#.4x\n", register_name.c_str(), pid, tid);
+ fprintf(file, "error: unable to read register '%s' for process %#.4x and thread %#.8" PRIx64 "\n", register_name.c_str(), pid, tid);
return total_bytes_read;
}
}
Modified: lldb/trunk/tools/debugserver/source/DNBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBBreakpoint.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBBreakpoint.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNBBreakpoint.cpp Fri Feb 22 01:27:08 2013
@@ -13,6 +13,7 @@
#include "DNBBreakpoint.h"
#include <algorithm>
+#include <inttypes.h>
#include "DNBLog.h"
@@ -77,7 +78,7 @@ DNBBreakpoint::Dump() const
{
if (IsBreakpoint())
{
- DNBLog ("DNBBreakpoint %u: tid = %4.4x addr = 0x%llx state = %s type = %s breakpoint hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %p baton = %p",
+ DNBLog ("DNBBreakpoint %u: tid = %8.8" PRIx64 " addr = 0x%llx state = %s type = %s breakpoint hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %p baton = %p",
m_breakID,
m_tid,
(uint64_t)m_addr,
@@ -91,7 +92,7 @@ DNBBreakpoint::Dump() const
}
else
{
- DNBLog ("DNBBreakpoint %u: tid = %4.4x addr = 0x%llx size = %llu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %p baton = %p",
+ DNBLog ("DNBBreakpoint %u: tid = %8.8" PRIx64 " addr = 0x%llx size = %llu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %p baton = %p",
m_breakID,
m_tid,
(uint64_t)m_addr,
Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBDefs.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBDefs.h Fri Feb 22 01:27:08 2013
@@ -73,7 +73,7 @@ typedef uint32_t nub_break_t;
typedef uint32_t nub_watch_t;
typedef uint32_t nub_index_t;
typedef pid_t nub_process_t;
-typedef unsigned int nub_thread_t;
+typedef uint64_t nub_thread_t;
typedef uint32_t nub_event_t;
typedef uint32_t nub_bool_t;
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Fri Feb 22 01:27:08 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "DNB.h"
+#include <inttypes.h>
#include <mach/mach.h>
#include <signal.h>
#include <spawn.h>
@@ -156,14 +157,20 @@ MachProcess::GetThreadAtIndex (nub_size_
return m_thread_list.ThreadIDAtIndex(thread_idx);
}
+nub_thread_t
+MachProcess::GetThreadIDForMachPortNumber (thread_t mach_port_number) const
+{
+ return m_thread_list.GetThreadIDByMachPortNumber (mach_port_number);
+}
+
nub_bool_t
MachProcess::SyncThreadState (nub_thread_t tid)
{
MachThreadSP thread_sp(m_thread_list.GetThreadByID(tid));
if (!thread_sp)
return false;
- kern_return_t kret = ::thread_abort_safely(thread_sp->ThreadID());
- DNBLogThreadedIf (LOG_THREAD, "thread = 0x%4.4x calling thread_abort_safely (tid) => %u (GetGPRState() for stop_count = %u)", thread_sp->ThreadID(), kret, thread_sp->Process()->StopCount());
+ kern_return_t kret = ::thread_abort_safely(thread_sp->MachPortNumber());
+ DNBLogThreadedIf (LOG_THREAD, "thread = 0x%8.8" PRIx32 " calling thread_abort_safely (tid) => %u (GetGPRState() for stop_count = %u)", thread_sp->MachPortNumber(), kret, thread_sp->Process()->StopCount());
if (kret == KERN_SUCCESS)
return true;
@@ -650,13 +657,18 @@ MachProcess::ReplyToAllExceptions ()
DNBLogThreadedIf(LOG_EXCEPTIONS, "Replying to exception %u...", (uint32_t)std::distance(begin, pos));
int thread_reply_signal = 0;
- const DNBThreadResumeAction *action = m_thread_actions.GetActionForThread (pos->state.thread_port, false);
+ nub_thread_t tid = m_thread_list.GetThreadIDByMachPortNumber (pos->state.thread_port);
+ const DNBThreadResumeAction *action = NULL;
+ if (tid != INVALID_NUB_THREAD)
+ {
+ action = m_thread_actions.GetActionForThread (tid, false);
+ }
if (action)
{
thread_reply_signal = action->signal;
if (thread_reply_signal)
- m_thread_actions.SetSignalHandledForThread (pos->state.thread_port);
+ m_thread_actions.SetSignalHandledForThread (tid);
}
DNBError err (pos->Reply(this, thread_reply_signal));
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Fri Feb 22 01:27:08 2013
@@ -182,6 +182,8 @@ public:
void DumpThreadStoppedReason(nub_thread_t tid) const;
const char * GetThreadInfo (nub_thread_t tid) const;
+ nub_thread_t GetThreadIDForMachPortNumber (thread_t mach_port_number) const;
+
uint32_t GetCPUType ();
nub_state_t GetState ();
void SetState (nub_state_t state);
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Fri Feb 22 01:27:08 2013
@@ -254,8 +254,12 @@ static void get_threads_profile_data(tas
if (kr != KERN_SUCCESS) continue;
if ((basic_info.flags & TH_FLAGS_IDLE) == 0) {
- threads_id.push_back(threads[i]);
+ nub_thread_t tid = MachThread::GetGloballyUniqueThreadIDForMachPortID (threads[i]);
+
+ threads_id.push_back(tid);
+ // process->GetName (tid) should get the same thing - but this looks like it will save one
+ // duplicated thread_info call so leave it be.
if (identifier_info.thread_handle != 0) {
struct proc_threadinfo proc_threadinfo;
int len = ::proc_pidinfo(pid, PROC_PIDTHREADINFO, identifier_info.thread_handle, &proc_threadinfo, PROC_PIDTHREADINFO_SIZE);
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Fri Feb 22 01:27:08 2013
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include <inttypes.h>
#include "MachThread.h"
#include "MachProcess.h"
#include "DNBLog.h"
@@ -23,9 +24,10 @@ GetSequenceID()
return ++g_nextID;
}
-MachThread::MachThread (MachProcess *process, thread_t tid) :
+MachThread::MachThread (MachProcess *process, uint64_t unique_thread_id, thread_t mach_port_num) :
m_process (process),
- m_tid (tid),
+ m_unique_id (unique_thread_id),
+ m_mach_port_number (mach_port_num),
m_seq_id (GetSequenceID()),
m_state (eStateUnloaded),
m_state_mutex (PTHREAD_MUTEX_RECURSIVE),
@@ -34,12 +36,10 @@ MachThread::MachThread (MachProcess *pro
m_stop_exception (),
m_arch_ap (DNBArchProtocol::Create (this)),
m_reg_sets (NULL),
- m_num_reg_sets (0)
-#ifdef THREAD_IDENTIFIER_INFO_COUNT
- , m_ident_info(),
+ m_num_reg_sets (0),
+ m_ident_info(),
m_proc_threadinfo(),
m_dispatch_queue_name()
-#endif
{
nub_size_t num_reg_sets = 0;
m_reg_sets = m_arch_ap->GetRegisterSetInfo (&num_reg_sets);
@@ -49,12 +49,12 @@ MachThread::MachThread (MachProcess *pro
// muck with it and also so we get the suspend count correct in case it was
// already suspended
GetBasicInfo();
- DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::MachThread ( process = %p, tid = 0x%4.4x, seq_id = %u )", &m_process, m_tid, m_seq_id);
+ DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::MachThread ( process = %p, tid = 0x%8.8" PRIx64 ", seq_id = %u )", &m_process, m_unique_id, m_seq_id);
}
MachThread::~MachThread()
{
- DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::~MachThread() for tid = 0x%4.4x (%u)", m_tid, m_seq_id);
+ DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::~MachThread() for tid = 0x%8.8" PRIx64 " (%u)", m_unique_id, m_seq_id);
}
@@ -63,13 +63,13 @@ void
MachThread::Suspend()
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
- if (ThreadIDIsValid(m_tid))
+ if (MachPortNumberIsValid(m_mach_port_number))
{
- DNBError err(::thread_suspend (m_tid), DNBError::MachKernel);
+ DNBError err(::thread_suspend (m_mach_port_number), DNBError::MachKernel);
if (err.Success())
m_suspend_count++;
if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
- err.LogThreaded("::thread_suspend (%4.4x)", m_tid);
+ err.LogThreaded("::thread_suspend (%4.4" PRIx32 ")", m_mach_port_number);
}
}
@@ -77,7 +77,7 @@ void
MachThread::Resume(bool others_stopped)
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
- if (ThreadIDIsValid(m_tid))
+ if (MachPortNumberIsValid(m_mach_port_number))
{
SetSuspendCountBeforeResume(others_stopped);
}
@@ -88,7 +88,7 @@ MachThread::SetSuspendCountBeforeResume(
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
DNBError err;
- if (ThreadIDIsValid(m_tid) == false)
+ if (MachPortNumberIsValid(m_mach_port_number) == false)
return false;
size_t times_to_resume;
@@ -113,9 +113,9 @@ MachThread::SetSuspendCountBeforeResume(
{
while (times_to_resume > 0)
{
- err = ::thread_resume (m_tid);
+ err = ::thread_resume (m_mach_port_number);
if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
- err.LogThreaded("::thread_resume (%4.4x)", m_tid);
+ err.LogThreaded("::thread_resume (%4.4" PRIx32 ")", m_mach_port_number);
if (err.Success())
--times_to_resume;
else
@@ -135,16 +135,16 @@ MachThread::RestoreSuspendCountAfterStop
{
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__);
DNBError err;
- if (ThreadIDIsValid(m_tid) == false)
+ if (MachPortNumberIsValid(m_mach_port_number) == false)
return false;
if (m_suspend_count > 0)
{
while (m_suspend_count > 0)
{
- err = ::thread_resume (m_tid);
+ err = ::thread_resume (m_mach_port_number);
if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
- err.LogThreaded("::thread_resume (%4.4x)", m_tid);
+ err.LogThreaded("::thread_resume (%4.4" PRIx32 ")", m_mach_port_number);
if (err.Success())
--m_suspend_count;
else
@@ -161,12 +161,12 @@ MachThread::RestoreSuspendCountAfterStop
{
while (m_suspend_count < 0)
{
- err = ::thread_suspend (m_tid);
+ err = ::thread_suspend (m_mach_port_number);
if (err.Success())
++m_suspend_count;
if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
{
- err.LogThreaded("::thread_suspend (%4.4x)", m_tid);
+ err.LogThreaded("::thread_suspend (%4.4" PRIx32 ")", m_mach_port_number);
return false;
}
}
@@ -181,7 +181,7 @@ MachThread::GetBasicInfoAsString () cons
static char g_basic_info_string[1024];
struct thread_basic_info basicInfo;
- if (GetBasicInfo(m_tid, &basicInfo))
+ if (GetBasicInfo(m_mach_port_number, &basicInfo))
{
// char run_state_str[32];
@@ -197,8 +197,8 @@ MachThread::GetBasicInfoAsString () cons
// }
float user = (float)basicInfo.user_time.seconds + (float)basicInfo.user_time.microseconds / 1000000.0f;
float system = (float)basicInfo.user_time.seconds + (float)basicInfo.user_time.microseconds / 1000000.0f;
- snprintf(g_basic_info_string, sizeof(g_basic_info_string), "Thread 0x%4.4x: user=%f system=%f cpu=%d sleep_time=%d",
- InferiorThreadID(),
+ snprintf(g_basic_info_string, sizeof(g_basic_info_string), "Thread 0x%8.8" PRIx64 ": user=%f system=%f cpu=%d sleep_time=%d",
+ m_unique_id,
user,
system,
basicInfo.cpu_usage,
@@ -209,6 +209,7 @@ MachThread::GetBasicInfoAsString () cons
return NULL;
}
+// Finds the Mach port number for a given thread in the inferior process' port namespace.
thread_t
MachThread::InferiorThreadID() const
{
@@ -233,7 +234,7 @@ MachThread::InferiorThreadID() const
if (kret == KERN_SUCCESS)
{
::mach_port_deallocate (my_task, my_name);
- if (my_name == m_tid)
+ if (my_name == m_mach_port_number)
{
inferior_tid = names[i];
break;
@@ -271,7 +272,7 @@ MachThread::IsUserReady()
struct thread_basic_info *
MachThread::GetBasicInfo ()
{
- if (MachThread::GetBasicInfo(m_tid, &m_basic_info))
+ if (MachThread::GetBasicInfo(m_mach_port_number, &m_basic_info))
return &m_basic_info;
return NULL;
}
@@ -280,7 +281,7 @@ MachThread::GetBasicInfo ()
bool
MachThread::GetBasicInfo(thread_t thread, struct thread_basic_info *basicInfoPtr)
{
- if (ThreadIDIsValid(thread))
+ if (MachPortNumberIsValid(thread))
{
unsigned int info_count = THREAD_BASIC_INFO_COUNT;
kern_return_t err = ::thread_info (thread, THREAD_BASIC_INFO, (thread_info_t) basicInfoPtr, &info_count);
@@ -293,7 +294,13 @@ MachThread::GetBasicInfo(thread_t thread
bool
-MachThread::ThreadIDIsValid(thread_t thread)
+MachThread::ThreadIDIsValid(uint64_t thread)
+{
+ return thread != 0;
+}
+
+bool
+MachThread::MachPortNumberIsValid(thread_t thread)
{
return thread != THREAD_NULL;
}
@@ -354,10 +361,10 @@ MachThread::Dump(uint32_t index)
default: thread_run_state = "???"; break;
}
- DNBLogThreaded("[%3u] #%3u tid: 0x%4.4x, pc: 0x%16.16llx, sp: 0x%16.16llx, breakID: %3d, user: %d.%6.6d, system: %d.%6.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
+ DNBLogThreaded("[%3u] #%3u tid: 0x%8.8" PRIx64 ", pc: 0x%16.16" PRIx64 ", sp: 0x%16.16" PRIx64 ", breakID: %3d, user: %d.%6.6d, system: %d.%6.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
index,
m_seq_id,
- m_tid,
+ m_unique_id,
GetPC(INVALID_NUB_ADDRESS),
GetSP(INVALID_NUB_ADDRESS),
m_break_id,
@@ -498,7 +505,7 @@ MachThread::ThreadDidStop()
RestoreSuspendCountAfterStop();
// Update the basic information for a thread
- MachThread::GetBasicInfo(m_tid, &m_basic_info);
+ MachThread::GetBasicInfo(m_mach_port_number, &m_basic_info);
#if ENABLE_AUTO_STEPPING_OVER_BP
// See if we were at a breakpoint when we last resumed that we disabled,
@@ -588,7 +595,7 @@ MachThread::SetState(nub_state_t state)
{
PTHREAD_MUTEX_LOCKER (locker, m_state_mutex);
m_state = state;
- DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%4.4x", DNBStateAsString(state), m_tid);
+ DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "", DNBStateAsString(state), m_unique_id);
}
uint32_t
@@ -736,13 +743,11 @@ MachThread::NumSupportedHardwareWatchpoi
bool
MachThread::GetIdentifierInfo ()
{
-#ifdef THREAD_IDENTIFIER_INFO_COUNT
// Don't try to get the thread info once and cache it for the life of the thread. It changes over time, for instance
// if the thread name changes, then the thread_handle also changes... So you have to refetch it every time.
mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
- kern_return_t kret = ::thread_info (ThreadID(), THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count);
+ kern_return_t kret = ::thread_info (m_mach_port_number, THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count);
return kret == KERN_SUCCESS;
-#endif
return false;
}
@@ -761,3 +766,18 @@ MachThread::GetName ()
return NULL;
}
+
+uint64_t
+MachThread::GetGloballyUniqueThreadIDForMachPortID (thread_t mach_port_id)
+{
+ kern_return_t kr;
+ thread_identifier_info_data_t tident;
+ mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
+ kr = thread_info (mach_port_id, THREAD_IDENTIFIER_INFO,
+ (thread_info_t) &tident, &tident_count);
+ if (kr != KERN_SUCCESS)
+ {
+ return mach_port_id;
+ }
+ return tident.thread_id;
+}
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Fri Feb 22 01:27:08 2013
@@ -36,7 +36,7 @@ class MachThread
{
public:
- MachThread (MachProcess *process, thread_t thread = 0);
+ MachThread (MachProcess *process, uint64_t unique_thread_id = 0, thread_t mach_port_number = 0);
~MachThread ();
MachProcess * Process() { return m_process; }
@@ -44,11 +44,13 @@ public:
Process() const { return m_process; }
nub_process_t ProcessID() const;
void Dump(uint32_t index);
- thread_t ThreadID() const { return m_tid; }
+ uint64_t ThreadID() const { return m_unique_id; }
+ thread_t MachPortNumber() const { return m_mach_port_number; }
thread_t InferiorThreadID() const;
uint32_t SequenceID() const { return m_seq_id; }
- static bool ThreadIDIsValid(thread_t thread);
+ static bool ThreadIDIsValid(uint64_t thread); // The 64-bit system-wide unique thread identifier
+ static bool MachPortNumberIsValid(thread_t thread); // The mach port # for this thread in debugserver namespace
void Resume(bool others_stopped);
void Suspend();
bool SetSuspendCountBeforeResume(bool others_stopped);
@@ -106,6 +108,8 @@ public:
return m_arch_ap.get();
}
+ static uint64_t GetGloballyUniqueThreadIDForMachPortID (thread_t mach_port_id);
+
protected:
static bool GetBasicInfo(thread_t threadID, struct thread_basic_info *basic_info);
@@ -116,7 +120,8 @@ protected:
// GetDispatchQueueName();
//
MachProcess * m_process; // The process that owns this thread
- thread_t m_tid; // The thread port for this thread
+ uint64_t m_unique_id; // The globally unique ID for this thread (nub_thread_t)
+ thread_t m_mach_port_number; // The mach port # for this thread in debugserver namesp.
uint32_t m_seq_id; // A Sequential ID that increments with each new thread
nub_state_t m_state; // The state of our process
PThreadMutex m_state_mutex; // Multithreaded protection for m_state
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Fri Feb 22 01:27:08 2013
@@ -13,6 +13,7 @@
#include "MachThreadList.h"
+#include <inttypes.h>
#include <sys/sysctl.h>
#include "DNBLog.h"
@@ -30,7 +31,7 @@ MachThreadList::~MachThreadList()
}
nub_state_t
-MachThreadList::GetState(thread_t tid)
+MachThreadList::GetState(nub_thread_t tid)
{
MachThreadSP thread_sp (GetThreadByID (tid));
if (thread_sp)
@@ -39,7 +40,7 @@ MachThreadList::GetState(thread_t tid)
}
const char *
-MachThreadList::GetName (thread_t tid)
+MachThreadList::GetName (nub_thread_t tid)
{
MachThreadSP thread_sp (GetThreadByID (tid));
if (thread_sp)
@@ -48,7 +49,7 @@ MachThreadList::GetName (thread_t tid)
}
nub_thread_t
-MachThreadList::SetCurrentThread(thread_t tid)
+MachThreadList::SetCurrentThread(nub_thread_t tid)
{
MachThreadSP thread_sp (GetThreadByID (tid));
if (thread_sp)
@@ -110,8 +111,41 @@ MachThreadList::GetThreadByID (nub_threa
return thread_sp;
}
+MachThreadSP
+MachThreadList::GetThreadByMachPortNumber (thread_t mach_port_number) const
+{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+ MachThreadSP thread_sp;
+ const size_t num_threads = m_threads.size();
+ for (size_t idx = 0; idx < num_threads; ++idx)
+ {
+ if (m_threads[idx]->MachPortNumber() == mach_port_number)
+ {
+ thread_sp = m_threads[idx];
+ break;
+ }
+ }
+ return thread_sp;
+}
+
+nub_thread_t
+MachThreadList::GetThreadIDByMachPortNumber (thread_t mach_port_number) const
+{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+ MachThreadSP thread_sp;
+ const size_t num_threads = m_threads.size();
+ for (size_t idx = 0; idx < num_threads; ++idx)
+ {
+ if (m_threads[idx]->MachPortNumber() == mach_port_number)
+ {
+ return m_threads[idx]->ThreadID();
+ }
+ }
+ return INVALID_NUB_THREAD;
+}
+
bool
-MachThreadList::GetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const
+MachThreadList::GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const
{
MachThreadSP thread_sp (GetThreadByID (tid));
if (thread_sp)
@@ -121,7 +155,7 @@ MachThreadList::GetRegisterValue ( nub_t
}
bool
-MachThreadList::SetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value ) const
+MachThreadList::SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value ) const
{
MachThreadSP thread_sp (GetThreadByID (tid));
if (thread_sp)
@@ -177,7 +211,7 @@ MachThreadList::CurrentThreadID ( )
bool
MachThreadList::NotifyException(MachException::Data& exc)
{
- MachThreadSP thread_sp (GetThreadByID (exc.thread_port));
+ MachThreadSP thread_sp (GetThreadByMachPortNumber (exc.thread_port));
if (thread_sp)
{
thread_sp->NotifyException(exc);
@@ -238,9 +272,10 @@ MachThreadList::UpdateThreadList(MachPro
// (add them), and which ones are not around anymore (remove them).
for (idx = 0; idx < thread_list_count; ++idx)
{
- const thread_t tid = thread_list[idx];
+ const thread_t mach_port_num = thread_list[idx];
- MachThreadSP thread_sp (GetThreadByID (tid));
+ uint64_t unique_thread_id = MachThread::GetGloballyUniqueThreadIDForMachPortID (mach_port_num);
+ MachThreadSP thread_sp (GetThreadByID (unique_thread_id));
if (thread_sp)
{
// Keep the existing thread class
@@ -249,7 +284,7 @@ MachThreadList::UpdateThreadList(MachPro
else
{
// We don't have this thread, lets add it.
- thread_sp.reset(new MachThread(process, tid));
+ thread_sp.reset(new MachThread(process, unique_thread_id, mach_port_num));
// Add the new thread regardless of its is user ready state...
// Make sure the thread is ready to be displayed and shown to users
@@ -382,7 +417,7 @@ MachThreadList::ProcessWillResume(MachPr
{
for (uint32_t idx = 0; idx < num_new_threads; ++idx)
{
- DNBLogThreadedIf (LOG_THREAD, "MachThreadList::ProcessWillResume (pid = %4.4x) stop-id=%u, resuming newly discovered thread: 0x%4.4x, thread-is-user-ready=%i)",
+ DNBLogThreadedIf (LOG_THREAD, "MachThreadList::ProcessWillResume (pid = %4.4x) stop-id=%u, resuming newly discovered thread: 0x%8.8" PRIx64 ", thread-is-user-ready=%i)",
process->ProcessID(),
process->StopCount(),
new_threads[idx]->ThreadID(),
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.h?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.h Fri Feb 22 01:27:08 2013
@@ -35,9 +35,9 @@ public:
uint32_t ProcessDidStop (MachProcess *process);
bool NotifyException (MachException::Data& exc);
bool ShouldStop (bool &step_more);
- const char * GetName (thread_t tid);
- nub_state_t GetState (thread_t tid);
- nub_thread_t SetCurrentThread (thread_t tid);
+ const char * GetName (nub_thread_t tid);
+ nub_state_t GetState (nub_thread_t tid);
+ nub_thread_t SetCurrentThread (nub_thread_t tid);
bool GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
void DumpThreadStoppedReason (nub_thread_t tid) const;
bool GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
@@ -56,6 +56,9 @@ public:
MachThreadSP GetThreadByID (nub_thread_t tid) const;
+ MachThreadSP GetThreadByMachPortNumber (thread_t mach_port_number) const;
+ nub_thread_t GetThreadIDByMachPortNumber (thread_t mach_port_number) const;
+
protected:
typedef std::vector<MachThreadSP> collection;
typedef collection::iterator iterator;
Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Fri Feb 22 01:27:08 2013
@@ -188,10 +188,10 @@ DNBArchMachARM::GetGPRState(bool force)
// Read the registers from our thread
mach_msg_type_number_t count = ARM_THREAD_STATE_COUNT;
- kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count);
+ kern_return_t kret = ::thread_get_state(m_thread->MachPortNumber(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count);
uint32_t *r = &m_state.context.gpr.__r[0];
DNBLogThreadedIf(LOG_THREAD, "thread_get_state(0x%4.4x, %u, &gpr, %u) => 0x%8.8x (count = %u) regs r0=%8.8x r1=%8.8x r2=%8.8x r3=%8.8x r4=%8.8x r5=%8.8x r6=%8.8x r7=%8.8x r8=%8.8x r9=%8.8x r10=%8.8x r11=%8.8x s12=%8.8x sp=%8.8x lr=%8.8x pc=%8.8x cpsr=%8.8x",
- m_thread->ThreadID(),
+ m_thread->MachPortNumber(),
ARM_THREAD_STATE,
ARM_THREAD_STATE_COUNT,
kret,
@@ -227,12 +227,12 @@ DNBArchMachARM::GetVFPState(bool force)
// Read the registers from our thread
mach_msg_type_number_t count = ARM_VFP_STATE_COUNT;
- kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, &count);
+ kern_return_t kret = ::thread_get_state(m_thread->MachPortNumber(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, &count);
if (DNBLogEnabledForAny (LOG_THREAD))
{
uint32_t *r = &m_state.context.vfp.__r[0];
DNBLogThreaded ("thread_get_state(0x%4.4x, %u, &gpr, %u) => 0x%8.8x (count => %u)",
- m_thread->ThreadID(),
+ m_thread->MachPortNumber(),
ARM_THREAD_STATE,
ARM_THREAD_STATE_COUNT,
kret,
@@ -260,7 +260,7 @@ DNBArchMachARM::GetEXCState(bool force)
// Read the registers from our thread
mach_msg_type_number_t count = ARM_EXCEPTION_STATE_COUNT;
- kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count);
+ kern_return_t kret = ::thread_get_state(m_thread->MachPortNumber(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count);
m_state.SetError(set, Read, kret);
return kret;
}
@@ -287,7 +287,7 @@ DNBArchMachARM::GetDBGState(bool force)
// Read the registers from our thread
mach_msg_type_number_t count = ARM_DEBUG_STATE_COUNT;
- kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_DEBUG_STATE, (thread_state_t)&m_state.dbg, &count);
+ kern_return_t kret = ::thread_get_state(m_thread->MachPortNumber(), ARM_DEBUG_STATE, (thread_state_t)&m_state.dbg, &count);
m_state.SetError(set, Read, kret);
return kret;
}
@@ -296,7 +296,7 @@ kern_return_t
DNBArchMachARM::SetGPRState()
{
int set = e_regSetGPR;
- kern_return_t kret = ::thread_set_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, ARM_THREAD_STATE_COUNT);
+ kern_return_t kret = ::thread_set_state(m_thread->MachPortNumber(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, ARM_THREAD_STATE_COUNT);
m_state.SetError(set, Write, kret); // Set the current write error for this register set
m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently
return kret; // Return the error code
@@ -306,7 +306,7 @@ kern_return_t
DNBArchMachARM::SetVFPState()
{
int set = e_regSetVFP;
- kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, ARM_VFP_STATE_COUNT);
+ kern_return_t kret = ::thread_set_state (m_thread->MachPortNumber(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, ARM_VFP_STATE_COUNT);
m_state.SetError(set, Write, kret); // Set the current write error for this register set
m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently
return kret; // Return the error code
@@ -316,7 +316,7 @@ kern_return_t
DNBArchMachARM::SetEXCState()
{
int set = e_regSetEXC;
- kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, ARM_EXCEPTION_STATE_COUNT);
+ kern_return_t kret = ::thread_set_state (m_thread->MachPortNumber(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, ARM_EXCEPTION_STATE_COUNT);
m_state.SetError(set, Write, kret); // Set the current write error for this register set
m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently
return kret; // Return the error code
@@ -326,7 +326,7 @@ kern_return_t
DNBArchMachARM::SetDBGState()
{
int set = e_regSetDBG;
- kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_DEBUG_STATE, (thread_state_t)&m_state.dbg, ARM_DEBUG_STATE_COUNT);
+ kern_return_t kret = ::thread_set_state (m_thread->MachPortNumber(), ARM_DEBUG_STATE, (thread_state_t)&m_state.dbg, ARM_DEBUG_STATE_COUNT);
m_state.SetError(set, Write, kret); // Set the current write error for this register set
m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently
return kret; // Return the error code
Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Fri Feb 22 01:27:08 2013
@@ -334,7 +334,7 @@ DNBArchImplI386::GetGPRState(bool force)
m_state.SetError(e_regSetGPR, Read, 0);
#else
mach_msg_type_number_t count = e_regSetWordSizeGPR;
- m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count));
+ m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->MachPortNumber(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count));
#endif
}
return m_state.GetError(e_regSetGPR, Read);
@@ -483,17 +483,17 @@ DNBArchImplI386::GetFPUState(bool force)
if (CPUHasAVX() || FORCE_AVX_REGS)
{
mach_msg_type_number_t count = e_regSetWordSizeAVX;
- m_state.SetError (e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
+ m_state.SetError (e_regSetFPU, Read, ::thread_get_state(m_thread->MachPortNumber(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in)) => 0x%8.8x",
- m_thread->ThreadID(), __i386_AVX_STATE, count, e_regSetWordSizeAVX,
+ m_thread->MachPortNumber(), __i386_AVX_STATE, count, e_regSetWordSizeAVX,
m_state.GetError(e_regSetFPU, Read));
}
else
{
mach_msg_type_number_t count = e_regSetWordSizeFPU;
- m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));
+ m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->MachPortNumber(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));
DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",
- m_thread->ThreadID(), __i386_FLOAT_STATE, count, e_regSetWordSizeFPU,
+ m_thread->MachPortNumber(), __i386_FLOAT_STATE, count, e_regSetWordSizeFPU,
m_state.GetError(e_regSetFPU, Read));
}
}
@@ -507,7 +507,7 @@ DNBArchImplI386::GetEXCState(bool force)
if (force || m_state.GetError(e_regSetEXC, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeEXC;
- m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count));
+ m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->MachPortNumber(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count));
}
return m_state.GetError(e_regSetEXC, Read);
}
@@ -515,7 +515,7 @@ DNBArchImplI386::GetEXCState(bool force)
kern_return_t
DNBArchImplI386::SetGPRState()
{
- m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR));
+ m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->MachPortNumber(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR));
return m_state.GetError(e_regSetGPR, Write);
}
@@ -530,9 +530,9 @@ DNBArchImplI386::SetFPUState()
else
{
if (CPUHasAVX() || FORCE_AVX_REGS)
- m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX));
+ m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->MachPortNumber(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX));
else
- m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));
+ m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->MachPortNumber(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));
return m_state.GetError(e_regSetFPU, Write);
}
}
@@ -540,7 +540,7 @@ DNBArchImplI386::SetFPUState()
kern_return_t
DNBArchImplI386::SetEXCState()
{
- m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC));
+ m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->MachPortNumber(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC));
return m_state.GetError(e_regSetEXC, Write);
}
@@ -550,7 +550,7 @@ DNBArchImplI386::GetDBGState(bool force)
if (force || m_state.GetError(e_regSetDBG, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeDBG;
- m_state.SetError(e_regSetDBG, Read, ::thread_get_state(m_thread->ThreadID(), __i386_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, &count));
+ m_state.SetError(e_regSetDBG, Read, ::thread_get_state(m_thread->MachPortNumber(), __i386_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, &count));
}
return m_state.GetError(e_regSetDBG, Read);
}
@@ -558,7 +558,7 @@ DNBArchImplI386::GetDBGState(bool force)
kern_return_t
DNBArchImplI386::SetDBGState()
{
- m_state.SetError(e_regSetDBG, Write, ::thread_set_state(m_thread->ThreadID(), __i386_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, e_regSetWordSizeDBG));
+ m_state.SetError(e_regSetDBG, Write, ::thread_set_state(m_thread->MachPortNumber(), __i386_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, e_regSetWordSizeDBG));
return m_state.GetError(e_regSetDBG, Write);
}
Modified: lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp Fri Feb 22 01:27:08 2013
@@ -78,7 +78,7 @@ DNBArchMachPPC::GetGPRState(bool force)
if (force || m_state.GetError(e_regSetGPR, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeGPR;
- m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), e_regSetGPR, (thread_state_t)&m_state.gpr, &count));
+ m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->MachPortNumber(), e_regSetGPR, (thread_state_t)&m_state.gpr, &count));
}
return m_state.GetError(e_regSetGPR, Read);
}
@@ -89,7 +89,7 @@ DNBArchMachPPC::GetFPRState(bool force)
if (force || m_state.GetError(e_regSetFPR, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeFPR;
- m_state.SetError(e_regSetFPR, Read, ::thread_get_state(m_thread->ThreadID(), e_regSetFPR, (thread_state_t)&m_state.fpr, &count));
+ m_state.SetError(e_regSetFPR, Read, ::thread_get_state(m_thread->MachPortNumber(), e_regSetFPR, (thread_state_t)&m_state.fpr, &count));
}
return m_state.GetError(e_regSetFPR, Read);
}
@@ -100,7 +100,7 @@ DNBArchMachPPC::GetEXCState(bool force)
if (force || m_state.GetError(e_regSetEXC, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeEXC;
- m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), e_regSetEXC, (thread_state_t)&m_state.exc, &count));
+ m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->MachPortNumber(), e_regSetEXC, (thread_state_t)&m_state.exc, &count));
}
return m_state.GetError(e_regSetEXC, Read);
}
@@ -111,7 +111,7 @@ DNBArchMachPPC::GetVECState(bool force)
if (force || m_state.GetError(e_regSetVEC, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeVEC;
- m_state.SetError(e_regSetVEC, Read, ::thread_get_state(m_thread->ThreadID(), e_regSetVEC, (thread_state_t)&m_state.vec, &count));
+ m_state.SetError(e_regSetVEC, Read, ::thread_get_state(m_thread->MachPortNumber(), e_regSetVEC, (thread_state_t)&m_state.vec, &count));
}
return m_state.GetError(e_regSetVEC, Read);
}
@@ -119,28 +119,28 @@ DNBArchMachPPC::GetVECState(bool force)
kern_return_t
DNBArchMachPPC::SetGPRState()
{
- m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), e_regSetGPR, (thread_state_t)&m_state.gpr, e_regSetWordSizeGPR));
+ m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->MachPortNumber(), e_regSetGPR, (thread_state_t)&m_state.gpr, e_regSetWordSizeGPR));
return m_state.GetError(e_regSetGPR, Write);
}
kern_return_t
DNBArchMachPPC::SetFPRState()
{
- m_state.SetError(e_regSetFPR, Write, ::thread_set_state(m_thread->ThreadID(), e_regSetFPR, (thread_state_t)&m_state.fpr, e_regSetWordSizeFPR));
+ m_state.SetError(e_regSetFPR, Write, ::thread_set_state(m_thread->MachPortNumber(), e_regSetFPR, (thread_state_t)&m_state.fpr, e_regSetWordSizeFPR));
return m_state.GetError(e_regSetFPR, Write);
}
kern_return_t
DNBArchMachPPC::SetEXCState()
{
- m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), e_regSetEXC, (thread_state_t)&m_state.exc, e_regSetWordSizeEXC));
+ m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->MachPortNumber(), e_regSetEXC, (thread_state_t)&m_state.exc, e_regSetWordSizeEXC));
return m_state.GetError(e_regSetEXC, Write);
}
kern_return_t
DNBArchMachPPC::SetVECState()
{
- m_state.SetError(e_regSetVEC, Write, ::thread_set_state(m_thread->ThreadID(), e_regSetVEC, (thread_state_t)&m_state.vec, e_regSetWordSizeVEC));
+ m_state.SetError(e_regSetVEC, Write, ::thread_set_state(m_thread->MachPortNumber(), e_regSetVEC, (thread_state_t)&m_state.vec, e_regSetWordSizeVEC));
return m_state.GetError(e_regSetVEC, Write);
}
Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=175870&r1=175869&r2=175870&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Fri Feb 22 01:27:08 2013
@@ -180,7 +180,7 @@ DNBArchImplX86_64::GetGPRState(bool forc
m_state.SetError(e_regSetGPR, Read, 0);
#else
mach_msg_type_number_t count = e_regSetWordSizeGPR;
- m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count));
+ m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->MachPortNumber(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count));
DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &gpr, %u) => 0x%8.8x"
"\n\trax = %16.16llx rbx = %16.16llx rcx = %16.16llx rdx = %16.16llx"
"\n\trdi = %16.16llx rsi = %16.16llx rbp = %16.16llx rsp = %16.16llx"
@@ -188,7 +188,7 @@ DNBArchImplX86_64::GetGPRState(bool forc
"\n\tr12 = %16.16llx r13 = %16.16llx r14 = %16.16llx r15 = %16.16llx"
"\n\trip = %16.16llx"
"\n\tflg = %16.16llx cs = %16.16llx fs = %16.16llx gs = %16.16llx",
- m_thread->ThreadID(), x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT,
+ m_thread->MachPortNumber(), x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT,
m_state.GetError(e_regSetGPR, Read),
m_state.context.gpr.__rax,m_state.context.gpr.__rbx,m_state.context.gpr.__rcx,
m_state.context.gpr.__rdx,m_state.context.gpr.__rdi,m_state.context.gpr.__rsi,
@@ -220,7 +220,7 @@ DNBArchImplX86_64::GetGPRState(bool forc
// "\n\t cs = %16.16llx"
// "\n\t fs = %16.16llx"
// "\n\t gs = %16.16llx",
- // m_thread->ThreadID(),
+ // m_thread->MachPortNumber(),
// x86_THREAD_STATE64,
// x86_THREAD_STATE64_COUNT,
// m_state.GetError(e_regSetGPR, Read),
@@ -414,17 +414,17 @@ DNBArchImplX86_64::GetFPUState(bool forc
if (CPUHasAVX() || FORCE_AVX_REGS)
{
mach_msg_type_number_t count = e_regSetWordSizeAVX;
- m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
+ m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->MachPortNumber(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x",
- m_thread->ThreadID(), __x86_64_AVX_STATE, (uint32_t)count,
+ m_thread->MachPortNumber(), __x86_64_AVX_STATE, (uint32_t)count,
e_regSetWordSizeAVX, m_state.GetError(e_regSetFPU, Read));
}
else
{
mach_msg_type_number_t count = e_regSetWordSizeFPU;
- m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));
+ m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->MachPortNumber(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));
DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",
- m_thread->ThreadID(), __x86_64_FLOAT_STATE, (uint32_t)count,
+ m_thread->MachPortNumber(), __x86_64_FLOAT_STATE, (uint32_t)count,
e_regSetWordSizeFPU, m_state.GetError(e_regSetFPU, Read));
}
}
@@ -438,7 +438,7 @@ DNBArchImplX86_64::GetEXCState(bool forc
if (force || m_state.GetError(e_regSetEXC, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeEXC;
- m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count));
+ m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->MachPortNumber(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count));
}
return m_state.GetError(e_regSetEXC, Read);
}
@@ -446,10 +446,10 @@ DNBArchImplX86_64::GetEXCState(bool forc
kern_return_t
DNBArchImplX86_64::SetGPRState()
{
- kern_return_t kret = ::thread_abort_safely(m_thread->ThreadID());
- DNBLogThreadedIf (LOG_THREAD, "thread = 0x%4.4x calling thread_abort_safely (tid) => %u (SetGPRState() for stop_count = %u)", m_thread->ThreadID(), kret, m_thread->Process()->StopCount());
+ kern_return_t kret = ::thread_abort_safely(m_thread->MachPortNumber());
+ DNBLogThreadedIf (LOG_THREAD, "thread = 0x%4.4x calling thread_abort_safely (tid) => %u (SetGPRState() for stop_count = %u)", m_thread->MachPortNumber(), kret, m_thread->Process()->StopCount());
- m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR));
+ m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->MachPortNumber(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR));
DNBLogThreadedIf (LOG_THREAD, "::thread_set_state (0x%4.4x, %u, &gpr, %u) => 0x%8.8x"
"\n\trax = %16.16llx rbx = %16.16llx rcx = %16.16llx rdx = %16.16llx"
"\n\trdi = %16.16llx rsi = %16.16llx rbp = %16.16llx rsp = %16.16llx"
@@ -457,7 +457,7 @@ DNBArchImplX86_64::SetGPRState()
"\n\tr12 = %16.16llx r13 = %16.16llx r14 = %16.16llx r15 = %16.16llx"
"\n\trip = %16.16llx"
"\n\tflg = %16.16llx cs = %16.16llx fs = %16.16llx gs = %16.16llx",
- m_thread->ThreadID(), __x86_64_THREAD_STATE, e_regSetWordSizeGPR,
+ m_thread->MachPortNumber(), __x86_64_THREAD_STATE, e_regSetWordSizeGPR,
m_state.GetError(e_regSetGPR, Write),
m_state.context.gpr.__rax,m_state.context.gpr.__rbx,m_state.context.gpr.__rcx,
m_state.context.gpr.__rdx,m_state.context.gpr.__rdi,m_state.context.gpr.__rsi,
@@ -481,12 +481,12 @@ DNBArchImplX86_64::SetFPUState()
{
if (CPUHasAVX() || FORCE_AVX_REGS)
{
- m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX));
+ m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->MachPortNumber(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX));
return m_state.GetError(e_regSetFPU, Write);
}
else
{
- m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));
+ m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->MachPortNumber(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));
return m_state.GetError(e_regSetFPU, Write);
}
}
@@ -495,7 +495,7 @@ DNBArchImplX86_64::SetFPUState()
kern_return_t
DNBArchImplX86_64::SetEXCState()
{
- m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC));
+ m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->MachPortNumber(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC));
return m_state.GetError(e_regSetEXC, Write);
}
@@ -505,7 +505,7 @@ DNBArchImplX86_64::GetDBGState(bool forc
if (force || m_state.GetError(e_regSetDBG, Read))
{
mach_msg_type_number_t count = e_regSetWordSizeDBG;
- m_state.SetError(e_regSetDBG, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, &count));
+ m_state.SetError(e_regSetDBG, Read, ::thread_get_state(m_thread->MachPortNumber(), __x86_64_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, &count));
}
return m_state.GetError(e_regSetDBG, Read);
}
@@ -513,7 +513,7 @@ DNBArchImplX86_64::GetDBGState(bool forc
kern_return_t
DNBArchImplX86_64::SetDBGState()
{
- m_state.SetError(e_regSetDBG, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, e_regSetWordSizeDBG));
+ m_state.SetError(e_regSetDBG, Write, ::thread_set_state(m_thread->MachPortNumber(), __x86_64_DEBUG_STATE, (thread_state_t)&m_state.context.dbg, e_regSetWordSizeDBG));
return m_state.GetError(e_regSetDBG, Write);
}
More information about the lldb-commits
mailing list