diff --git a/lldb/tools/debugserver/source/DNBArch.h b/lldb/tools/debugserver/source/DNBArch.h --- a/lldb/tools/debugserver/source/DNBArch.h +++ b/lldb/tools/debugserver/source/DNBArch.h @@ -78,7 +78,8 @@ virtual bool NotifyException(MachException::Data &exc) { return false; } virtual uint32_t NumSupportedHardwareBreakpoints() { return 0; } virtual uint32_t NumSupportedHardwareWatchpoints() { return 0; } - virtual uint32_t EnableHardwareBreakpoint(nub_addr_t addr, nub_size_t size) { + virtual uint32_t EnableHardwareBreakpoint(nub_addr_t addr, nub_size_t size, + bool also_set_on_task) { return INVALID_NUB_HW_INDEX; } virtual uint32_t EnableHardwareWatchpoint(nub_addr_t addr, nub_size_t size, @@ -86,7 +87,10 @@ bool also_set_on_task) { return INVALID_NUB_HW_INDEX; } - virtual bool DisableHardwareBreakpoint(uint32_t hw_index) { return false; } + virtual bool DisableHardwareBreakpoint(uint32_t hw_index, + bool also_set_on_task) { + return false; + } virtual bool DisableHardwareWatchpoint(uint32_t hw_index, bool also_set_on_task) { return false; diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -66,10 +66,12 @@ uint64_t GetSP(uint64_t failValue = INVALID_NUB_ADDRESS); // Get stack pointer DNBBreakpoint *CurrentBreakpoint(); - uint32_t EnableHardwareBreakpoint(const DNBBreakpoint *breakpoint); + uint32_t EnableHardwareBreakpoint(const DNBBreakpoint *breakpoint, + bool also_set_on_task); uint32_t EnableHardwareWatchpoint(const DNBBreakpoint *watchpoint, bool also_set_on_task); - bool DisableHardwareBreakpoint(const DNBBreakpoint *breakpoint); + bool DisableHardwareBreakpoint(const DNBBreakpoint *breakpoint, + bool also_set_on_task); bool DisableHardwareWatchpoint(const DNBBreakpoint *watchpoint, bool also_set_on_task); uint32_t NumSupportedHardwareWatchpoints() const; diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -534,9 +534,12 @@ return m_arch_up->RestoreRegisterState(save_id); } -uint32_t MachThread::EnableHardwareBreakpoint(const DNBBreakpoint *bp) { - if (bp != NULL && bp->IsBreakpoint()) - return m_arch_up->EnableHardwareBreakpoint(bp->Address(), bp->ByteSize()); +uint32_t MachThread::EnableHardwareBreakpoint(const DNBBreakpoint *bp, + bool also_set_on_task) { + if (bp != NULL && bp->IsBreakpoint()) { + return m_arch_up->EnableHardwareBreakpoint(bp->Address(), bp->ByteSize(), + also_set_on_task); + } return INVALID_NUB_HW_INDEX; } @@ -555,9 +558,12 @@ bool MachThread::FinishTransForHWP() { return m_arch_up->FinishTransForHWP(); } -bool MachThread::DisableHardwareBreakpoint(const DNBBreakpoint *bp) { - if (bp != NULL && bp->IsHardware()) - return m_arch_up->DisableHardwareBreakpoint(bp->GetHardwareIndex()); +bool MachThread::DisableHardwareBreakpoint(const DNBBreakpoint *bp, + bool also_set_on_task) { + if (bp != NULL && bp->IsHardware()) { + return m_arch_up->DisableHardwareBreakpoint(bp->GetHardwareIndex(), + also_set_on_task); + } return false; } diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h @@ -86,9 +86,11 @@ enum class HardwareBreakpointAction { EnableWatchpoint, DisableWatchpoint, + EnableBreakpoint, + DisableBreakpoint, }; - uint32_t DoHardwareBreakpointAction(const DNBBreakpoint *wp, + uint32_t DoHardwareBreakpointAction(const DNBBreakpoint *bp, HardwareBreakpointAction action) const; uint32_t UpdateThreadList(MachProcess *process, bool update, diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -483,28 +483,9 @@ } } -uint32_t -MachThreadList::EnableHardwareBreakpoint(const DNBBreakpoint *bp) const { - if (bp != NULL) { - const size_t num_threads = m_threads.size(); - for (uint32_t idx = 0; idx < num_threads; ++idx) - m_threads[idx]->EnableHardwareBreakpoint(bp); - } - return INVALID_NUB_HW_INDEX; -} - -bool MachThreadList::DisableHardwareBreakpoint(const DNBBreakpoint *bp) const { - if (bp != NULL) { - const size_t num_threads = m_threads.size(); - for (uint32_t idx = 0; idx < num_threads; ++idx) - m_threads[idx]->DisableHardwareBreakpoint(bp); - } - return false; -} - uint32_t MachThreadList::DoHardwareBreakpointAction( - const DNBBreakpoint *wp, HardwareBreakpointAction action) const { - if (wp == NULL) + const DNBBreakpoint *bp, HardwareBreakpointAction action) const { + if (bp == NULL) return INVALID_NUB_HW_INDEX; uint32_t hw_index = INVALID_NUB_HW_INDEX; @@ -517,11 +498,18 @@ for (uint32_t idx = 0; idx < num_threads; ++idx) { switch (action) { case HardwareBreakpointAction::EnableWatchpoint: - hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp, also_set_on_task); + hw_index = m_threads[idx]->EnableHardwareWatchpoint(bp, also_set_on_task); break; case HardwareBreakpointAction::DisableWatchpoint: hw_index = - m_threads[idx]->DisableHardwareWatchpoint(wp, also_set_on_task); + m_threads[idx]->DisableHardwareWatchpoint(bp, also_set_on_task); + break; + case HardwareBreakpointAction::EnableBreakpoint: + hw_index = m_threads[idx]->EnableHardwareBreakpoint(bp, also_set_on_task); + break; + case HardwareBreakpointAction::DisableBreakpoint: + hw_index = + m_threads[idx]->DisableHardwareBreakpoint(bp, also_set_on_task); break; } if (hw_index == INVALID_NUB_HW_INDEX) { @@ -554,6 +542,18 @@ INVALID_NUB_HW_INDEX; } +uint32_t +MachThreadList::EnableHardwareBreakpoint(const DNBBreakpoint *bp) const { + return DoHardwareBreakpointAction(bp, + HardwareBreakpointAction::EnableBreakpoint); +} + +bool MachThreadList::DisableHardwareBreakpoint(const DNBBreakpoint *bp) const { + return DoHardwareBreakpointAction( + bp, HardwareBreakpointAction::DisableBreakpoint) != + INVALID_NUB_HW_INDEX; +} + uint32_t MachThreadList::NumSupportedHardwareWatchpoints() const { PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); const size_t num_threads = m_threads.size();