[llvm-branch-commits] [lldb] [lldb] Create ThreadPlanStepOut ctor that never skips frames (PR #136163)
Felipe de Azevedo Piovezan via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 17 13:48:22 PDT 2025
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/136163
>From 0a2dc4a280d83ca35bc4458ecb939f96e4dee8af Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Thu, 17 Apr 2025 11:34:39 -0700
Subject: [PATCH 1/3] fixup! Run clang-format
---
lldb/source/Target/ThreadPlanStepOut.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp
index b3c9a790487d4..f2606403016a6 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -79,8 +79,8 @@ ThreadPlanStepOut::ThreadPlanStepOut(
ComputeTargetFrame(thread, frame_idx, m_stepped_past_frames);
StackFrameSP immediate_return_from_sp(thread.GetStackFrameAtIndex(frame_idx));
- SetupReturnAddress(return_frame_sp, immediate_return_from_sp,
- frame_idx, continue_to_next_branch);
+ SetupReturnAddress(return_frame_sp, immediate_return_from_sp, frame_idx,
+ continue_to_next_branch);
}
void ThreadPlanStepOut::SetupReturnAddress(
@@ -101,8 +101,8 @@ void ThreadPlanStepOut::SetupReturnAddress(
// First queue a plan that gets us to this inlined frame, and when we get
// there we'll queue a second plan that walks us out of this frame.
m_step_out_to_inline_plan_sp = std::make_shared<ThreadPlanStepOut>(
- GetThread(), nullptr, false, m_stop_others, eVoteNoOpinion, eVoteNoOpinion,
- frame_idx - 1, eLazyBoolNo, continue_to_next_branch);
+ GetThread(), nullptr, false, m_stop_others, eVoteNoOpinion,
+ eVoteNoOpinion, frame_idx - 1, eLazyBoolNo, continue_to_next_branch);
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())
->SetShouldStopHereCallbacks(nullptr, nullptr);
m_step_out_to_inline_plan_sp->SetPrivate(true);
>From 923f6c73fae39c0f4686a65282c81755fa876b70 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Thu, 17 Apr 2025 09:36:22 -0700
Subject: [PATCH 2/3] [lldb] Create ThreadPlanStepOut ctor that never skips
frames
The function QueueThreadPlanForStepOutNoShouldStop has the semantics of
"go this parent frame"; ThreadPlanStepOut needs to respect that, not
skipping over any frames it finds uninteresting. This commit creates a
constructor that respects such instruction.
---
lldb/include/lldb/Target/ThreadPlanStepOut.h | 9 ++++++++
lldb/source/Target/Thread.cpp | 5 ++---
lldb/source/Target/ThreadPlanStepOut.cpp | 22 ++++++++++++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index e414a6e0a2d49..9a62f6102d368 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -17,6 +17,9 @@ namespace lldb_private {
class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
public:
+ /// Creates a thread plan to step out from frame_idx, skipping parent frames
+ /// that artificial and hidden frames. Also skips frames without debug info
+ /// based on step_out_avoids_code_without_debug_info.
ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
bool first_insn, bool stop_others, Vote report_stop_vote,
Vote report_run_vote, uint32_t frame_idx,
@@ -24,6 +27,12 @@ class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
bool continue_to_next_branch = false,
bool gather_return_value = true);
+ /// Creates a thread plan to step out from frame_idx to frame_idx + 1.
+ ThreadPlanStepOut(Thread &thread, bool stop_others, Vote report_stop_vote,
+ Vote report_run_vote, uint32_t frame_idx,
+ bool continue_to_next_branch = false,
+ bool gather_return_value = true);
+
~ThreadPlanStepOut() override;
void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index accc4708c24e1..b0e0f1e67c060 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1360,9 +1360,8 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOutNoShouldStop(
const bool calculate_return_value =
false; // No need to calculate the return value here.
ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut(
- *this, addr_context, first_insn, stop_other_threads, report_stop_vote,
- report_run_vote, frame_idx, eLazyBoolNo, continue_to_next_branch,
- calculate_return_value));
+ *this, stop_other_threads, report_stop_vote, report_run_vote, frame_idx,
+ continue_to_next_branch, calculate_return_value));
ThreadPlanStepOut *new_plan =
static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp
index f2606403016a6..0628451a5abf9 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -83,6 +83,28 @@ ThreadPlanStepOut::ThreadPlanStepOut(
continue_to_next_branch);
}
+ThreadPlanStepOut::ThreadPlanStepOut(Thread &thread, bool stop_others,
+ Vote report_stop_vote,
+ Vote report_run_vote, uint32_t frame_idx,
+ bool continue_to_next_branch,
+ bool gather_return_value)
+ : ThreadPlan(ThreadPlan::eKindStepOut, "Step out", thread, report_stop_vote,
+ report_run_vote),
+ ThreadPlanShouldStopHere(this), m_return_bp_id(LLDB_INVALID_BREAK_ID),
+ m_return_addr(LLDB_INVALID_ADDRESS), m_stop_others(stop_others),
+ m_immediate_step_from_function(nullptr),
+ m_calculate_return_value(gather_return_value) {
+ SetFlagsToDefault();
+ m_step_from_insn = thread.GetRegisterContext()->GetPC(0);
+
+ StackFrameSP return_frame_sp = thread.GetStackFrameAtIndex(frame_idx + 1);
+ StackFrameSP immediate_return_from_sp =
+ thread.GetStackFrameAtIndex(frame_idx);
+
+ SetupReturnAddress(return_frame_sp, immediate_return_from_sp, frame_idx,
+ continue_to_next_branch);
+}
+
void ThreadPlanStepOut::SetupReturnAddress(
StackFrameSP return_frame_sp, StackFrameSP immediate_return_from_sp,
uint32_t frame_idx, bool continue_to_next_branch) {
>From fc70c64244dea43d45b6341531ba3471c1792245 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Thu, 17 Apr 2025 13:48:08 -0700
Subject: [PATCH 3/3] fixup! Update comment
---
lldb/include/lldb/Target/ThreadPlanStepOut.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 9a62f6102d368..ad4434be14120 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -18,8 +18,8 @@ namespace lldb_private {
class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
public:
/// Creates a thread plan to step out from frame_idx, skipping parent frames
- /// that artificial and hidden frames. Also skips frames without debug info
- /// based on step_out_avoids_code_without_debug_info.
+ /// if they are artificial or hidden frames. Also skips frames without debug
+ /// info based on step_out_avoids_code_without_debug_info.
ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
bool first_insn, bool stop_others, Vote report_stop_vote,
Vote report_run_vote, uint32_t frame_idx,
More information about the llvm-branch-commits
mailing list