https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/133078
>From 91110b85aab9ddf41d1b52b9fc23d68883966b93 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 26 Mar 2025 13:20:24 +0000 Subject: [PATCH 1/2] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction --- lldb/include/lldb/Target/StackFrameList.h | 3 +++ lldb/include/lldb/Target/Thread.h | 5 +++++ lldb/source/Target/Process.cpp | 2 ++ lldb/source/Target/StackFrameList.cpp | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/Target/StackFrameList.h b/lldb/include/lldb/Target/StackFrameList.h index 8a66296346f2d..d805b644b0b31 100644 --- a/lldb/include/lldb/Target/StackFrameList.h +++ b/lldb/include/lldb/Target/StackFrameList.h @@ -46,6 +46,9 @@ class StackFrameList { /// Mark a stack frame as the currently selected frame and return its index. uint32_t SetSelectedFrame(lldb_private::StackFrame *frame); + /// Resets the selected frame index of this object. + void ClearSelectedFrameIndex(); + /// Get the currently selected frame index. /// We should only call SelectMostRelevantFrame if (a) the user hasn't already /// selected a frame, and (b) if this really is a user facing diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 1d1e3dcfc1dc6..9eb9cda983c4a 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -480,6 +480,11 @@ class Thread : public std::enable_shared_from_this<Thread>, bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream); + /// Resets the selected frame index of this object. + void ClearSelectedFrameIndex() { + return GetStackFrameList()->ClearSelectedFrameIndex(); + } + void SetDefaultFileAndLineToSelectedFrame() { GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame(); } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f2f5598f0ab53..6843d5b220742 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4257,6 +4257,8 @@ bool Process::ProcessEventData::ShouldStop(Event *event_ptr, // appropriately. We also need to stop processing actions, since they // aren't expecting the target to be running. + thread_sp->ClearSelectedFrameIndex(); + // FIXME: we might have run. if (stop_info_sp->HasTargetRunSinceMe()) { SetRestarted(true); diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index 9c6208e9e0a65..3592c3c03db74 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame, strm.IndentLess(); return num_frames_displayed; } + +void StackFrameList::ClearSelectedFrameIndex() { + m_selected_frame_idx.reset(); +} >From a7b6bd3f84225875755d0adb6c33c972fba5eaf1 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 26 Mar 2025 13:35:23 +0000 Subject: [PATCH 2/2] fixup! clang-format --- lldb/source/Target/Process.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 6843d5b220742..af805183b24fb 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4257,6 +4257,12 @@ bool Process::ProcessEventData::ShouldStop(Event *event_ptr, // appropriately. We also need to stop processing actions, since they // aren't expecting the target to be running. + // Clear the selected frame which may have been set as part of utility + // expressions that have been run as part of this stop. If we didn't + // clear this, then StopInfo::GetSuggestedStackFrameIndex would not + // take affect when we next called SelectMostRelevantFrame. PerformAction + // should not be the one setting a selected frame, instead this should be + // done via GetSuggestedStackFrameIndex. thread_sp->ClearSelectedFrameIndex(); // FIXME: we might have run. _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits