[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
Tue Jul 14 16:00:46 PDT 2026
https://github.com/augusto2112 updated https://github.com/llvm/llvm-project/pull/209629
>From 09ad767e2566adf0934db57f3edf0e659fedaa35 Mon Sep 17 00:00:00 2001
From: Augusto Noronha <anoronha at apple.com>
Date: Tue, 14 Jul 2026 13:08:24 -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 | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c517ec8611932..90cedd6df6606 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -470,6 +470,21 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
StackFrameSP frame = thread.GetStackFrameAtIndex(0);
if (frame) {
+ // Advance past the prologue if we stopped there.
+ 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 && func_start == curr_pc) {
+ uint32_t prologue_size = sc.function ? sc.function->GetPrologueByteSize()
+ : symbol->GetPrologueByteSize();
+ if (prologue_size > 0) {
+ 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