summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-09-29 01:20:42 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-09-29 01:20:42 +0000
commit825ea37835650a22e820e7929fe8c4653a8f9ba6 (patch)
tree48a511e3ab09f10c46134bd5f6defc76c7596492 /lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
parent400e7e3b39f31ef597e06e02fa413b87977db74c (diff)
downloadbcm5719-llvm-825ea37835650a22e820e7929fe8c4653a8f9ba6.tar.gz
bcm5719-llvm-825ea37835650a22e820e7929fe8c4653a8f9ba6.zip
Fix a bug in the current MacOSX MachThreadList::EnableHardwareWatchpoint() impl so that
it enables the hardware watchpoint for all existing threads. Add a test file for that. Also fix MachThreadList::DisableHardwareWatchpoint(). llvm-svn: 140757
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index 33213fbca43..4ad3ca9847c 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -99,26 +99,14 @@ 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();
- if (MachThread::ThreadIDIsValid(tid))
+ for (size_t idx = 0; idx < num_threads; ++idx)
{
- for (size_t idx = 0; idx < num_threads; ++idx)
+ if (m_threads[idx]->ThreadID() == tid)
{
- if (m_threads[idx]->ThreadID() == tid)
- {
- thread_sp = m_threads[idx];
- break;
- }
+ 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;
}
@@ -477,14 +465,22 @@ MachThreadList::DisableHardwareBreakpoint (const DNBBreakpoint* bp) const
return false;
}
+// DNBWatchpointSet() -> MachProcess::CreateWatchpoint() -> MachProcess::EnableWatchpoint()
+// -> MachThreadList::EnableHardwareWatchpoint().
uint32_t
MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
{
if (wp != NULL)
{
- MachThreadSP thread_sp (GetThreadByID (wp->ThreadID()));
- if (thread_sp)
- return thread_sp->EnableHardwareWatchpoint(wp);
+ uint32_t hw_index;
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+ const uint32_t num_threads = m_threads.size();
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
+ {
+ if ((hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp)) == INVALID_NUB_HW_INDEX)
+ return INVALID_NUB_HW_INDEX;
+ }
+ return hw_index;
}
return INVALID_NUB_HW_INDEX;
}
@@ -494,9 +490,14 @@ MachThreadList::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const
{
if (wp != NULL)
{
- MachThreadSP thread_sp (GetThreadByID (wp->ThreadID()));
- if (thread_sp)
- return thread_sp->DisableHardwareWatchpoint(wp);
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+ const uint32_t num_threads = m_threads.size();
+ for (uint32_t idx = 0; idx < num_threads; ++idx)
+ {
+ if (!m_threads[idx]->DisableHardwareWatchpoint(wp))
+ return false;
+ }
+ return true;
}
return false;
}
OpenPOWER on IntegriCloud