From 847075607f536d5a2304880785825775ffe76d3b Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 1 Jun 2012 23:43:05 +0000 Subject: rdar://problem/11320188 Designate MachThreadList as a transaction coordinator when doing Enable/DisableHardwareWatchpoint on the list of threads. In case the operation (iterating on the threads and doing enable/disable) fails in the middle, we rollback the already enabled/disabled threads to their checkpointed states. When all the threads succeed in enable/disable, we ask each thread to finsih the transaction and commit the change of the debug state. llvm-svn: 157858 --- .../tools/debugserver/source/MacOSX/MachThreadList.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp') diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index e2aa0f2eedd..b8044fe6c7f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -478,8 +478,17 @@ MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const for (uint32_t idx = 0; idx < num_threads; ++idx) { if ((hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp)) == INVALID_NUB_HW_INDEX) + { + // We know that idx failed for some reason. Let's rollback the transaction for [0, idx). + for (uint32_t i = 0; i < idx; ++i) + m_threads[i]->RollbackTransForHWP(); return INVALID_NUB_HW_INDEX; + } } + // Notify each thread to commit the pending transaction. + for (uint32_t idx = 0; idx < num_threads; ++idx) + m_threads[idx]->FinishTransForHWP(); + // Use an arbitrary thread to signal the completion of our transaction. if (num_threads) m_threads[0]->HardwareWatchpointStateChanged(); @@ -498,8 +507,17 @@ MachThreadList::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const for (uint32_t idx = 0; idx < num_threads; ++idx) { if (!m_threads[idx]->DisableHardwareWatchpoint(wp)) + { + // We know that idx failed for some reason. Let's rollback the transaction for [0, idx). + for (uint32_t i = 0; i < idx; ++i) + m_threads[i]->RollbackTransForHWP(); return false; + } } + // Notify each thread to commit the pending transaction. + for (uint32_t idx = 0; idx < num_threads; ++idx) + m_threads[idx]->FinishTransForHWP(); + // Use an arbitrary thread to signal the completion of our transaction. if (num_threads) m_threads[0]->HardwareWatchpointStateChanged(); -- cgit v1.2.3