[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 29 12:12:29 PDT 2025
================
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SymbolFileWasm.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::plugin::dwarf;
+SymbolFileWasm::SymbolFileWasm(ObjectFileSP objfile_sp,
+ SectionList *dwo_section_list)
+ : SymbolFileDWARF(objfile_sp, dwo_section_list) {}
+
+SymbolFileWasm::~SymbolFileWasm() = default;
+
+lldb::offset_t
+SymbolFileWasm::GetVendorDWARFOpcodeSize(const DataExtractor &data,
+ const lldb::offset_t data_offset,
+ const uint8_t op) const {
+ if (op != llvm::dwarf::DW_OP_WASM_location) {
+ return LLDB_INVALID_OFFSET;
+ }
+
+ lldb::offset_t offset = data_offset;
+ uint8_t wasm_op = data.GetU8(&offset);
+ if (wasm_op == 3) {
+ data.GetU32(&offset);
+ } else {
+ data.GetULEB128(&offset);
+ }
+ return offset - data_offset;
+}
+
+bool SymbolFileWasm::ParseVendorDWARFOpcode(uint8_t op,
+ const DataExtractor &opcodes,
+ lldb::offset_t &offset,
+ RegisterContext *reg_ctx,
+ lldb::RegisterKind reg_kind,
+ std::vector<Value> &stack) const {
+ if (op != llvm::dwarf::DW_OP_WASM_location) {
+ return false;
+ }
+
+ uint8_t wasm_op = opcodes.GetU8(&offset);
+
+ /* LLDB doesn't have an address space to represents WebAssembly locals,
----------------
JDevlieghere wrote:
@jasonmolenda made a similar comment in #151056. I've created a new class, similar to the various `*_DWARF_Registers` classes to centralize the virtual register handling.
https://github.com/llvm/llvm-project/pull/151010
More information about the lldb-commits
mailing list