summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/tools/debugserver/source')
-rw-r--r--lldb/tools/debugserver/source/DNBBreakpoint.cpp4
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachProcess.cpp14
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachProcess.h1
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThread.cpp6
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp237
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.h7
-rw-r--r--lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp7
-rw-r--r--lldb/tools/debugserver/source/RNBRemote.cpp2
8 files changed, 116 insertions, 162 deletions
diff --git a/lldb/tools/debugserver/source/DNBBreakpoint.cpp b/lldb/tools/debugserver/source/DNBBreakpoint.cpp
index 837f53260cf..355ada0ba1f 100644
--- a/lldb/tools/debugserver/source/DNBBreakpoint.cpp
+++ b/lldb/tools/debugserver/source/DNBBreakpoint.cpp
@@ -148,10 +148,10 @@ DNBBreakpointList::FindIDByAddress (nub_addr_t addr)
DNBBreakpoint *bp = FindByAddress (addr);
if (bp)
{
- DNBLogThreadedIf(LOG_BREAKPOINTS, "DNBBreakpointList::%s ( addr = 0x%8.8llx ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
+ DNBLogThreadedIf(LOG_BREAKPOINTS, "DNBBreakpointList::%s ( addr = 0x%16.16llx ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
return bp->GetID();
}
- DNBLogThreadedIf(LOG_BREAKPOINTS, "DNBBreakpointList::%s ( addr = 0x%8.8llx ) => NONE", __FUNCTION__, (uint64_t)addr);
+ DNBLogThreadedIf(LOG_BREAKPOINTS, "DNBBreakpointList::%s ( addr = 0x%16.16llx ) => NONE", __FUNCTION__, (uint64_t)addr);
return INVALID_NUB_BREAK_ID;
}
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index 05298168037..aa3465b0f6a 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -170,12 +170,6 @@ MachProcess::GetThreadAtIndex (nub_size_t thread_idx) const
return m_thread_list.ThreadIDAtIndex(thread_idx);
}
-uint32_t
-MachProcess::GetThreadIndexFromThreadID (nub_thread_t tid)
-{
- return m_thread_list.GetThreadIndexByID(tid);
-}
-
nub_thread_t
MachProcess::GetCurrentThread ()
{
@@ -207,12 +201,12 @@ MachProcess::GetThreadInfo(nub_thread_t tid) const
}
const DNBRegisterSetInfo *
-MachProcess::GetRegisterSetInfo(nub_thread_t tid, nub_size_t *num_reg_sets ) const
+MachProcess::GetRegisterSetInfo (nub_thread_t tid, nub_size_t *num_reg_sets) const
{
- MachThread *thread = m_thread_list.GetThreadByID (tid);
- if (thread)
+ MachThreadSP thread_sp (m_thread_list.GetThreadByID (tid));
+ if (thread_sp)
{
- DNBArchProtocol *arch = thread->GetArchProtocol();
+ DNBArchProtocol *arch = thread_sp->GetArchProtocol();
if (arch)
return arch->GetRegisterSetInfo (num_reg_sets);
}
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
index 8866187b56a..0c6f2371f2b 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -139,7 +139,6 @@ public:
nub_state_t ThreadGetState (nub_thread_t tid);
nub_size_t GetNumThreads () const;
nub_thread_t GetThreadAtIndex (nub_size_t thread_idx) const;
- uint32_t GetThreadIndexFromThreadID (nub_thread_t tid);
nub_thread_t GetCurrentThread ();
nub_thread_t SetCurrentThread (nub_thread_t tid);
MachThreadList & GetThreadList() { return m_thread_list; }
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index 003a58b79d6..e61d2800287 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -297,14 +297,14 @@ MachThread::Dump(uint32_t index)
default: thread_run_state = "???"; break;
}
- DNBLogThreaded("thread[%u] %4.4x (%u): pc: 0x%8.8llx sp: 0x%8.8llx breakID: %d user: %d.%06.6d system: %d.%06.6d cpu: %d policy: %d run_state: %d (%s) flags: %d suspend_count: %d (current %d) sleep_time: %d",
+ DNBLogThreaded("[%3u] #%3u tid: 0x%4.4x, pc: 0x%16.16llx, sp: 0x%16.16llx, breakID: %3d, user: %d.%06.6d, system: %d.%06.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
index,
- m_tid,
m_seq_id,
+ m_tid,
GetPC(INVALID_NUB_ADDRESS),
GetSP(INVALID_NUB_ADDRESS),
m_breakID,
- m_basicInfo.user_time.seconds, m_basicInfo.user_time.microseconds,
+ m_basicInfo.user_time.seconds, m_basicInfo.user_time.microseconds,
m_basicInfo.system_time.seconds, m_basicInfo.system_time.microseconds,
m_basicInfo.cpu_usage,
m_basicInfo.policy,
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index 7aaf64258ba..84031bdd555 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -29,47 +29,33 @@ MachThreadList::~MachThreadList()
{
}
-// Not thread safe, must lock m_threads_mutex prior to using this function.
-uint32_t
-MachThreadList::GetThreadIndexByID(thread_t tid) const
-{
- uint32_t idx = 0;
- const uint32_t num_threads = m_threads.size();
- for (idx = 0; idx < num_threads; ++idx)
- {
- if (m_threads[idx]->ThreadID() == tid)
- return idx;
- }
- return ~((uint32_t)0);
-}
-
nub_state_t
MachThreadList::GetState(thread_t tid)
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetState();
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetState();
return eStateInvalid;
}
const char *
MachThreadList::GetName (thread_t tid)
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetName();
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetName();
return NULL;
}
nub_thread_t
MachThreadList::SetCurrentThread(thread_t tid)
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- m_current_thread = m_threads[idx];
-
- if (m_current_thread.get())
- return m_current_thread->ThreadID();
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ {
+ m_current_thread = thread_sp;
+ return tid;
+ }
return INVALID_NUB_THREAD;
}
@@ -77,9 +63,9 @@ MachThreadList::SetCurrentThread(thread_t tid)
bool
MachThreadList::GetThreadStoppedReason(nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetStopException().GetStopInfo(stop_info);
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetStopException().GetStopInfo(stop_info);
return false;
}
@@ -91,37 +77,45 @@ MachThreadList::GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data
}
void
-MachThreadList::DumpThreadStoppedReason(nub_thread_t tid) const
+MachThreadList::DumpThreadStoppedReason (nub_thread_t tid) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- m_threads[idx]->GetStopException().DumpStopReason();
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ thread_sp->GetStopException().DumpStopReason();
}
const char *
-MachThreadList::GetThreadInfo(nub_thread_t tid) const
+MachThreadList::GetThreadInfo (nub_thread_t tid) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetBasicInfoAsString();
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetBasicInfoAsString();
return NULL;
}
-MachThread *
+MachThreadSP
MachThreadList::GetThreadByID (nub_thread_t tid) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx].get();
- return NULL;
+ 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]->ThreadID() == tid)
+ {
+ thread_sp = m_threads[idx];
+ break;
+ }
+ }
+ return thread_sp;
}
bool
MachThreadList::GetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetRegisterValue(reg_set_idx, reg_idx, reg_value);
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetRegisterValue(reg_set_idx, reg_idx, reg_value);
return false;
}
@@ -129,9 +123,9 @@ MachThreadList::GetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint3
bool
MachThreadList::SetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value ) const
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->SetRegisterValue(reg_set_idx, reg_idx, reg_value);
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->SetRegisterValue(reg_set_idx, reg_idx, reg_value);
return false;
}
@@ -139,30 +133,32 @@ MachThreadList::SetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint3
nub_size_t
MachThreadList::GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len)
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->GetRegisterContext (buf, buf_len);
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->GetRegisterContext (buf, buf_len);
return 0;
}
nub_size_t
MachThreadList::SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len)
{
- uint32_t idx = GetThreadIndexByID(tid);
- if (idx < m_threads.size())
- return m_threads[idx]->SetRegisterContext (buf, buf_len);
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
+ return thread_sp->SetRegisterContext (buf, buf_len);
return 0;
}
nub_size_t
-MachThreadList::NumThreads() const
+MachThreadList::NumThreads () const
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
return m_threads.size();
}
nub_thread_t
-MachThreadList::ThreadIDAtIndex(nub_size_t idx) const
+MachThreadList::ThreadIDAtIndex (nub_size_t idx) const
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
if (idx < m_threads.size())
return m_threads[idx]->ThreadID();
return INVALID_NUB_THREAD;
@@ -171,42 +167,29 @@ MachThreadList::ThreadIDAtIndex(nub_size_t idx) const
nub_thread_t
MachThreadList::CurrentThreadID ( )
{
- MachThreadSP threadSP;
- CurrentThread(threadSP);
- if (threadSP.get())
- return threadSP->ThreadID();
+ MachThreadSP thread_sp;
+ CurrentThread(thread_sp);
+ if (thread_sp.get())
+ return thread_sp->ThreadID();
return INVALID_NUB_THREAD;
}
bool
MachThreadList::NotifyException(MachException::Data& exc)
{
- uint32_t idx = GetThreadIndexByID(exc.thread_port);
- if (idx < m_threads.size())
+ MachThreadSP thread_sp (GetThreadByID (exc.thread_port));
+ if (thread_sp)
{
- m_threads[idx]->NotifyException(exc);
+ thread_sp->NotifyException(exc);
return true;
}
return false;
}
-/*
-MachThreadList::const_iterator
-MachThreadList::FindThreadByID(thread_t tid) const
-{
- const_iterator pos;
- const_iterator end = m_threads.end();
- for (pos = m_threads.begin(); pos != end; ++pos)
- {
- if (pos->ThreadID() == tid)
- return pos;
- }
- return NULL;
-}
-*/
void
MachThreadList::Clear()
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
m_threads.clear();
}
@@ -249,29 +232,28 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update)
if (err.Error() == KERN_SUCCESS && thread_list_count > 0)
{
MachThreadList::collection currThreads;
- const size_t numOldThreads = m_threads.size();
size_t idx;
// Iterator through the current thread list and see which threads
// we already have in our list (keep them), which ones we don't
// (add them), and which ones are not around anymore (remove them).
for (idx = 0; idx < thread_list_count; ++idx)
{
- uint32_t existing_idx = 0;
- if (numOldThreads > 0)
- existing_idx = GetThreadIndexByID(thread_list[idx]);
- if (existing_idx < numOldThreads)
+ const thread_t tid = thread_list[idx];
+
+ MachThreadSP thread_sp (GetThreadByID (tid));
+ if (thread_sp)
{
// Keep the existing thread class
- currThreads.push_back(m_threads[existing_idx]);
+ currThreads.push_back(thread_sp);
}
else
{
// We don't have this thread, lets add it.
- MachThreadSP threadSP(new MachThread(process, thread_list[idx]));
+ thread_sp.reset(new MachThread(process, tid));
// Make sure the thread is ready to be displayed and shown to users
// before we add this thread to our list...
- if (threadSP->IsUserReady())
- currThreads.push_back(threadSP);
+ if (thread_sp->IsUserReady())
+ currThreads.push_back(thread_sp);
}
}
@@ -290,7 +272,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update)
void
-MachThreadList::CurrentThread(MachThreadSP& threadSP)
+MachThreadList::CurrentThread (MachThreadSP& thread_sp)
{
// locker will keep a mutex locked until it goes out of scope
PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
@@ -299,49 +281,25 @@ MachThreadList::CurrentThread(MachThreadSP& threadSP)
// Figure out which thread is going to be our current thread.
// This is currently done by finding the first thread in the list
// that has a valid exception.
- const size_t num_threads = m_threads.size();
- size_t idx;
- for (idx = 0; idx < num_threads; ++idx)
+ const uint32_t num_threads = m_threads.size();
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
- MachThread *thread = m_threads[idx].get();
- if (thread->GetStopException().IsValid())
+ if (m_threads[idx]->GetStopException().IsValid())
{
m_current_thread = m_threads[idx];
break;
}
}
}
- threadSP = m_current_thread;
-}
-
-void
-MachThreadList::GetRegisterState(int flavor, bool force)
-{
- uint32_t idx = 0;
- const uint32_t num_threads = m_threads.size();
- for (idx = 0; idx < num_threads; ++idx)
- {
- m_threads[idx]->GetRegisterState(flavor, force);
- }
-}
-
-void
-MachThreadList::SetRegisterState(int flavor)
-{
- uint32_t idx = 0;
- const uint32_t num_threads = m_threads.size();
- for (idx = 0; idx < num_threads; ++idx)
- {
- m_threads[idx]->SetRegisterState(flavor);
- }
+ thread_sp = m_current_thread;
}
void
MachThreadList::Dump() const
{
- uint32_t idx = 0;
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
const uint32_t num_threads = m_threads.size();
- for (idx = 0; idx < num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
m_threads[idx]->Dump(idx);
}
@@ -351,10 +309,9 @@ MachThreadList::Dump() const
void
MachThreadList::ProcessWillResume(MachProcess *process, const DNBThreadResumeActions &thread_actions)
{
- uint32_t idx = 0;
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
const uint32_t num_threads = m_threads.size();
-
- for (idx = 0; idx < num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
MachThread *thread = m_threads[idx].get();
@@ -368,10 +325,10 @@ MachThreadList::ProcessWillResume(MachProcess *process, const DNBThreadResumeAct
uint32_t
MachThreadList::ProcessDidStop(MachProcess *process)
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
// Update our thread list
const uint32_t num_threads = UpdateThreadList(process, true);
- uint32_t idx = 0;
- for (idx = 0; idx < num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
m_threads[idx]->ThreadDidStop();
}
@@ -392,10 +349,10 @@ MachThreadList::ProcessDidStop(MachProcess *process)
bool
MachThreadList::ShouldStop(bool &step_more)
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
uint32_t should_stop = false;
const uint32_t num_threads = m_threads.size();
- uint32_t idx = 0;
- for (idx = 0; !should_stop && idx < num_threads; ++idx)
+ for (uint32_t idx = 0; !should_stop && idx < num_threads; ++idx)
{
should_stop = m_threads[idx]->ShouldStop(step_more);
}
@@ -406,9 +363,9 @@ MachThreadList::ShouldStop(bool &step_more)
void
MachThreadList::NotifyBreakpointChanged (const DNBBreakpoint *bp)
{
- uint32_t idx = 0;
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
const uint32_t num_threads = m_threads.size();
- for (idx = 0; idx < num_threads; ++idx)
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
{
m_threads[idx]->NotifyBreakpointChanged(bp);
}
@@ -420,9 +377,9 @@ MachThreadList::EnableHardwareBreakpoint (const DNBBreakpoint* bp) const
{
if (bp != NULL)
{
- uint32_t idx = GetThreadIndexByID(bp->ThreadID());
- if (idx < m_threads.size())
- return m_threads[idx]->EnableHardwareBreakpoint(bp);
+ MachThreadSP thread_sp (GetThreadByID (bp->ThreadID()));
+ if (thread_sp)
+ return thread_sp->EnableHardwareBreakpoint(bp);
}
return INVALID_NUB_HW_INDEX;
}
@@ -432,9 +389,9 @@ MachThreadList::DisableHardwareBreakpoint (const DNBBreakpoint* bp) const
{
if (bp != NULL)
{
- uint32_t idx = GetThreadIndexByID(bp->ThreadID());
- if (idx < m_threads.size())
- return m_threads[idx]->DisableHardwareBreakpoint(bp);
+ MachThreadSP thread_sp (GetThreadByID (bp->ThreadID()));
+ if (thread_sp)
+ return thread_sp->DisableHardwareBreakpoint(bp);
}
return false;
}
@@ -444,9 +401,9 @@ MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
{
if (wp != NULL)
{
- uint32_t idx = GetThreadIndexByID(wp->ThreadID());
- if (idx < m_threads.size())
- return m_threads[idx]->EnableHardwareWatchpoint(wp);
+ MachThreadSP thread_sp (GetThreadByID (wp->ThreadID()));
+ if (thread_sp)
+ return thread_sp->EnableHardwareWatchpoint(wp);
}
return INVALID_NUB_HW_INDEX;
}
@@ -456,9 +413,9 @@ MachThreadList::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const
{
if (wp != NULL)
{
- uint32_t idx = GetThreadIndexByID(wp->ThreadID());
- if (idx < m_threads.size())
- return m_threads[idx]->DisableHardwareWatchpoint(wp);
+ MachThreadSP thread_sp (GetThreadByID (wp->ThreadID()));
+ if (thread_sp)
+ return thread_sp->DisableHardwareWatchpoint(wp);
}
return false;
}
@@ -466,10 +423,10 @@ MachThreadList::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const
uint32_t
MachThreadList::GetThreadIndexForThreadStoppedWithSignal (const int signo) const
{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
uint32_t should_stop = false;
const uint32_t num_threads = m_threads.size();
- uint32_t idx = 0;
- for (idx = 0; !should_stop && idx < num_threads; ++idx)
+ for (uint32_t idx = 0; !should_stop && idx < num_threads; ++idx)
{
if (m_threads[idx]->GetStopException().SoftSignal () == signo)
return idx;
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
index 1a17618a7e3..4ffa7e6610e 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
@@ -26,8 +26,6 @@ public:
void Clear ();
void Dump () const;
- void GetRegisterState (int flavor, bool force);
- void SetRegisterState (int flavor);
bool GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value) const;
bool SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value) const;
nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
@@ -46,7 +44,6 @@ public:
nub_size_t NumThreads () const;
nub_thread_t ThreadIDAtIndex (nub_size_t idx) const;
nub_thread_t CurrentThreadID ();
- uint32_t GetThreadIndexByID (thread_t tid) const;
void CurrentThread (MachThreadSP& threadSP);
void NotifyBreakpointChanged (const DNBBreakpoint *bp);
uint32_t EnableHardwareBreakpoint (const DNBBreakpoint *bp) const;
@@ -55,7 +52,7 @@ public:
bool DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
uint32_t GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
- MachThread * GetThreadByID (nub_thread_t tid) const;
+ MachThreadSP GetThreadByID (nub_thread_t tid) const;
protected:
typedef std::vector<MachThreadSP> collection;
@@ -66,7 +63,7 @@ protected:
// const_iterator FindThreadByID (thread_t tid) const;
collection m_threads;
- PThreadMutex m_threads_mutex;
+ mutable PThreadMutex m_threads_mutex;
MachThreadSP m_current_thread;
};
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 ce0e9c2c579..a479031c95e 100644
--- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -19,6 +19,7 @@
#include "DNBLog.h"
#include "MachThread.h"
#include "MachProcess.h"
+#include <mach/mach.h>
uint64_t
DNBArchImplX86_64::GetPC(uint64_t failValue)
@@ -59,6 +60,9 @@ DNBArchImplX86_64::GetGPRState(bool force)
{
if (force || m_state.GetError(e_regSetGPR, Read))
{
+ kern_return_t kret = ::thread_abort_safely(m_thread->ThreadID());
+ DNBLogThreaded("thread = 0x%4.4x calling thread_abort_safely (tid) => %u (GetGPRState() for stop_count = %u)", m_thread->ThreadID(), kret, m_thread->Process()->StopCount());
+
#if DEBUG_GPR_VALUES
m_state.context.gpr.__rax = ('a' << 8) + 'x';
m_state.context.gpr.__rbx = ('b' << 8) + 'x';
@@ -247,6 +251,9 @@ DNBArchImplX86_64::GetEXCState(bool force)
kern_return_t
DNBArchImplX86_64::SetGPRState()
{
+ kern_return_t kret = ::thread_abort_safely(m_thread->ThreadID());
+ DNBLogThreaded("thread = 0x%4.4x calling thread_abort_safely (tid) => %u (SetGPRState() for stop_count = %u)", m_thread->ThreadID(), kret, m_thread->Process()->StopCount());
+
m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), x86_THREAD_STATE64, (thread_state_t)&m_state.context.gpr, x86_THREAD_STATE64_COUNT));
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"
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp
index 7ce808dbab4..bb1951955d3 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -2894,8 +2894,8 @@ RNBRemote::ExtractThreadIDFromThreadSuffix (const char *p)
tid_cstr += strlen ("thread:");
tid = strtoul(tid_cstr, NULL, 16);
}
- DNBLogThreadedIf (LOG_RNB_PACKETS, "RNBRemote::ExtractThreadIDFromThreadSuffix(%s) got thread 0x%4.4x", p, tid);
}
+ return tid;
}
return GetCurrentThread();
OpenPOWER on IntegriCloud