summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-09-07 19:03:50 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-09-07 19:03:50 +0000
commitec6a2d31609da6f8f1d09e9cf85c12ca45fcb3b5 (patch)
tree2d868b9479f99465ce28aea36f014a7369c5efd8 /lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
parent02f2f89a985d2fe02227cbc579aef6f73e8f5c54 (diff)
downloadbcm5719-llvm-ec6a2d31609da6f8f1d09e9cf85c12ca45fcb3b5.tar.gz
bcm5719-llvm-ec6a2d31609da6f8f1d09e9cf85c12ca45fcb3b5.zip
Add logic to MachThreadList::GetThreadID() for the use case of setting a watchpoint
(MachThreadList::EnableHardwareWatchpoint()) where the watchpoint is not associated with a thread and the current thread, if set, is returned, otherwise we return the first thread. Plus minor change to RNBRemote::HandlePacket_z() to use the existing macros to check the validity of break_id/watch_id. llvm-svn: 139246
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index acd38eb7707..33213fbca43 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -99,14 +99,26 @@ MachThreadList::GetThreadByID (nub_thread_t tid) 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 (MachThread::ThreadIDIsValid(tid))
{
- if (m_threads[idx]->ThreadID() == tid)
+ for (size_t idx = 0; idx < num_threads; ++idx)
{
- thread_sp = m_threads[idx];
- break;
+ if (m_threads[idx]->ThreadID() == tid)
+ {
+ thread_sp = m_threads[idx];
+ break;
+ }
}
}
+ else if (num_threads > 0)
+ {
+ // See DNBWatchpointSet() -> MachProcess::CreateWatchpoint() -> MachProcess::EnableWatchpoint()
+ // -> MachThreadList::EnableHardwareWatchpoint() for a use case of this branch.
+ if (m_current_thread)
+ thread_sp = m_current_thread;
+ else
+ thread_sp = m_threads[0];
+ }
return thread_sp;
}
OpenPOWER on IntegriCloud