[Lldb-commits] [lldb] [lldb] Skip local variable declarations at start of Wasm function (PR #190093)

via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 2 09:59:10 PDT 2026


================
@@ -1355,6 +1355,25 @@ size_t Disassembler::AppendInstructions(Target &target, Address start,
 
   start = ResolveAddress(target, start);
 
+  // WebAssembly functions begin with local variable declarations that are part
+  // of the binary format but are not executable instructions. Skip past them
+  // so the disassembler doesn't try to decode non-instruction bytes.
+  if (m_arch.GetTriple().getArch() == llvm::Triple::wasm32 ||
+      m_arch.GetTriple().getArch() == llvm::Triple::wasm64) {
+    if (ModuleSP module_sp = start.GetModule()) {
+      SymbolContext sc;
+      module_sp->ResolveSymbolContextForAddress(start, eSymbolContextSymbol,
+                                                sc);
+      if (sc.symbol && sc.symbol->GetAddress() == start) {
+        if (uint32_t skip = sc.symbol->GetPrologueByteSize()) {
+          start.Slide(skip);
+          if (limit.kind == Limit::Bytes && limit.value > skip)
+            limit.value -= skip;
----------------
jimingham wrote:

limit.value is treated as a number of bytes below.  It is used to size the DataBuffer that holds the instruction bytes we are going to read.  So this is just making sure we don't read past data requested when the start is moved forward.
A comment would not go awry here, however.
That value could either be a number of bytes or a number of instructions.  I don't think we have a good lldb typedef for that.

https://github.com/llvm/llvm-project/pull/190093


More information about the lldb-commits mailing list