https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/128726
* One of the overloads of CreateStopReasonWithBreakpointSiteID was missing a call to SetThreadHitBreakpointSite. * ThreadMemory was missing a "DetectThreadStoppedAtUnexecutedBP" in its CalculateStopInfo. * When OS plugins are involved, they will sometimes calculate the stop info for the backing thread, and then "grab" it from them (see for example `ThreadMemory::CalculateStopInfo`. So the stop info is created on the backing thread (e.g. a GDBRemoteThread), and then we call SetStopInfo on the OS plugin thread. As a result, we never call `SetThreadHitBreakpointSite" for MemoryThreads, as this is done at the StopInfo creation. To address this, we add a check in SetStopInfo.) >From a373f8a4523f22901307d474d19ff39c4fa931f0 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan <fpiove...@apple.com> Date: Tue, 25 Feb 2025 07:01:17 -0800 Subject: [PATCH] [lldb] Add missing calls to SetThreadHitBreakpointSite/DetectThreadStoppedAtUnexecutedBP * One of the overloads of CreateStopReasonWithBreakpointSiteID was missing a call to SetThreadHitBreakpointSite. * ThreadMemory was missing a "DetectThreadStoppedAtUnexecutedBP" in its CalculateStopInfo. * When OS plugins are involved, they will sometimes calculate the stop info for the backing thread, and then "grab" it from them (see for example `ThreadMemory::CalculateStopInfo`. So the stop info is created on the backing thread (e.g. a GDBRemoteThread), and then we call SetStopInfo on the OS plugin thread. As a result, we never call `SetThreadHitBreakpointSite" for MemoryThreads, as this is done at the StopInfo creation. To address this, we add a check in SetStopInfo. --- lldb/source/Plugins/Process/Utility/ThreadMemory.cpp | 1 + lldb/source/Target/StopInfo.cpp | 2 ++ lldb/source/Target/Thread.cpp | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp index 550b53688fd39..9643d721b8501 100644 --- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp @@ -66,6 +66,7 @@ ThreadMemory::CreateRegisterContextForFrame(StackFrame *frame) { } bool ThreadMemory::CalculateStopInfo() { + DetectThreadStoppedAtUnexecutedBP(); if (m_backing_thread_sp) { lldb::StopInfoSP backing_stop_info_sp( m_backing_thread_sp->GetPrivateStopInfo()); diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index 1c9ecbfe70c3c..1999216f8d2e9 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -1451,6 +1451,8 @@ StopInfoSP StopInfo::CreateStopReasonWithBreakpointSiteID(Thread &thread, StopInfoSP StopInfo::CreateStopReasonWithBreakpointSiteID(Thread &thread, break_id_t break_id, bool should_stop) { + thread.SetThreadHitBreakpointSite(); + return StopInfoSP(new StopInfoBreakpoint(thread, break_id, should_stop)); } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 50f7c73f2c4c1..71ea76ebfa0dc 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -462,6 +462,10 @@ void Thread::ResetStopInfo() { } void Thread::SetStopInfo(const lldb::StopInfoSP &stop_info_sp) { + if (stop_info_sp && + stop_info_sp->GetStopReason() == lldb::eStopReasonBreakpoint) + SetThreadHitBreakpointSite(); + m_stop_info_sp = stop_info_sp; if (m_stop_info_sp) { m_stop_info_sp->MakeStopInfoValid(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits