From 076341d1088b0b3e0140178760dc45ac5162cd65 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 21 Apr 2023 13:49:01 -0700 Subject: Make sure SelectMostRelevantFrame happens only when returning to the user. This is a user facing action, it is meant to focus the user's attention on something other than the 0th frame when you stop somewhere where that's helpful. For instance, stopping in pthread_kill after an assert will select the assert frame. This is not something you want to have happen internally in lldb, both because internally you really don't want the selected frame changing out from under you, and because the recognizers can do arbitrary work, and that can cause deadlocks or other unexpected behavior. However, it's not something that the current code does explicitly after a stop has been delivered, it's expected to happen implicitly as part of stopping. I changing this to call SMRF explicitly after a user stop, but that got pretty ugly quickly. So I added a bool to control whether to run this and audited all the current uses to determine whether we're returning to the user or not. Differential Revision: https://reviews.llvm.org/D148863 --- lldb/source/Commands/CommandObjectFrame.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lldb/source/Commands/CommandObjectFrame.cpp') diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 4a0d752..71fed65 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -135,7 +135,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { Thread *thread = m_exe_ctx.GetThreadPtr(); - StackFrameSP frame_sp = thread->GetSelectedFrame(); + StackFrameSP frame_sp = thread->GetSelectedFrame(SelectMostRelevantFrame); ValueObjectSP valobj_sp; @@ -308,7 +308,7 @@ protected: uint32_t frame_idx = UINT32_MAX; if (m_options.relative_frame_offset) { // The one and only argument is a signed relative frame index - frame_idx = thread->GetSelectedFrameIndex(); + frame_idx = thread->GetSelectedFrameIndex(SelectMostRelevantFrame); if (frame_idx == UINT32_MAX) frame_idx = 0; @@ -362,7 +362,7 @@ protected: return false; } } else if (command.GetArgumentCount() == 0) { - frame_idx = thread->GetSelectedFrameIndex(); + frame_idx = thread->GetSelectedFrameIndex(SelectMostRelevantFrame); if (frame_idx == UINT32_MAX) { frame_idx = 0; } @@ -372,7 +372,7 @@ protected: bool success = thread->SetSelectedFrameByIndexNoisily( frame_idx, result.GetOutputStream()); if (success) { - m_exe_ctx.SetFrameSP(thread->GetSelectedFrame()); + m_exe_ctx.SetFrameSP(thread->GetSelectedFrame(SelectMostRelevantFrame)); result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat("Frame index (%u) out of range.\n", -- cgit v1.1