[Lldb-commits] [lldb] [lldb] Skip the WebAssembly function header for frame recognizers (PR #211806)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 24 07:25:50 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/211806

A frame recognizer restricted to the first instruction matches when the frame's PC equals the function's start address. On WebAssembly a function begins with a non-executable local variable header, so the symbol's start address is never a value the PC can take and such recognizers never matched.

Route the start address through Architecture::SkipFunctionHeader, which already maps a function start past this header for breakpoints and disassembly, so the comparison uses the first executable instruction.

>From 048b4bf1e7c321c70e0cbd2c90b607be1806402f Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 24 Jul 2026 07:23:03 -0700
Subject: [PATCH] [lldb] Skip the WebAssembly function header for frame
 recognizers

A frame recognizer restricted to the first instruction matches when the
frame's PC equals the function's start address. On WebAssembly a function
begins with a non-executable local variable header, so the symbol's start
address is never a value the PC can take and such recognizers never matched.

Route the start address through Architecture::SkipFunctionHeader, which
already maps a function start past this header for breakpoints and
disassembly, so the comparison uses the first executable instruction.
---
 lldb/source/Target/StackFrameRecognizer.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lldb/source/Target/StackFrameRecognizer.cpp b/lldb/source/Target/StackFrameRecognizer.cpp
index 589f3805e3a67..788efff98f06e 100644
--- a/lldb/source/Target/StackFrameRecognizer.cpp
+++ b/lldb/source/Target/StackFrameRecognizer.cpp
@@ -7,11 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Core/Architecture.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Interpreter/Interfaces/ScriptedStackFrameRecognizerInterface.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/ScriptedMetadata.h"
 
@@ -180,6 +182,13 @@ StackFrameRecognizerManager::GetRecognizerForFrame(StackFrameSP frame) {
   Address start_addr = symbol->GetAddress();
   Address current_addr = frame->GetFrameCodeAddress();
 
+  // The symbol's start address may fall inside a non-executable function
+  // header (as on WebAssembly), which no frame's PC can equal. Compare against
+  // the first instruction instead.
+  if (TargetSP target_sp = frame->CalculateTarget())
+    if (Architecture *arch = target_sp->GetArchitecturePlugin())
+      start_addr = arch->SkipFunctionHeader(start_addr);
+
   for (const auto &entry : m_recognizers) {
     if (!entry.enabled)
       continue;



More information about the lldb-commits mailing list