[Lldb-commits] [lldb] [lldb] Skip the prologue before reading `this` when stepping into std::function (PR #209629)
Augusto Noronha via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 15 12:50:24 PDT 2026
https://github.com/augusto2112 updated https://github.com/llvm/llvm-project/pull/209629
>From 1260647daf3d759795afe89a62c0cb2fdc0d053e Mon Sep 17 00:00:00 2001
From: Augusto Noronha <anoronha at apple.com>
Date: Wed, 15 Jul 2026 12:50:06 -0700
Subject: [PATCH] [lldb] Skip the prologue before reading `this` when stepping
into std::function
Commit 40152b8 broke CPPLanguageRuntime::GetStepThroughTrampolinePlan by
changing operator() from a multi-line function to a single line function.
This used to work by accident, because the fallback step-in plan first advanced
past the prologue and the trampoline detection was re-invoked there with a valid
`this`. Once operator() became a one-line inline definition that intermediate
step no longer happened.
Run past the prologue when stopped at the function entry and let the
step-through machinery re-invoke the plan, so the thread plan has a
valid `this` to read from.
---
.../CPlusPlus/CPPLanguageRuntime.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c517ec8611932..74203c1887b6a 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -470,6 +470,23 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
StackFrameSP frame = thread.GetStackFrameAtIndex(0);
if (frame) {
+ Address func_start_address =
+ sc.function ? sc.function->GetAddress() : symbol->GetAddress();
+ lldb::addr_t func_start =
+ func_start_address.GetLoadAddress(target_sp.get());
+
+ if (func_start == LLDB_INVALID_ADDRESS)
+ return ret_plan_sp;
+
+ // Advance past the prologue if we stopped there.
+ uint32_t prologue_size = sc.function ? sc.function->GetPrologueByteSize()
+ : symbol->GetPrologueByteSize();
+ if (curr_pc < func_start + prologue_size) {
+ func_start_address.Slide(prologue_size);
+ return std::make_shared<ThreadPlanRunToAddress>(
+ thread, func_start_address, stop_others);
+ }
+
ValueObjectSP value_sp = frame->FindVariable(g_this);
CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
More information about the lldb-commits
mailing list