[Lldb-commits] [lldb] [lldb] Record the value type and mutability of Wasm globals (PR #236586)

via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 15:02:16 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

<details>
<summary>Changes</summary>

ParseGlobals read both and discarded them. Keep them in WasmGlobal, in preparation for telling which exported globals hold the address of a variable in linear memory.

---
Full diff: https://github.com/llvm/llvm-project/pull/236586.diff


2 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp (+3-2) 
- (modified) lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h (+3) 


``````````diff
diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index a266464e49aabb..4b89e44a18d9da 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -620,8 +620,9 @@ ParseGlobals(DataExtractor &data) {
           "global section holds %zu of its %u globals", globals.size(), *count);
 
     WasmGlobal global;
-    global.size = GetWasmValueTypeSize(data.GetU8(&offset));
-    data.GetU8(&offset); // mutability
+    global.value_type = data.GetU8(&offset);
+    global.size = GetWasmValueTypeSize(global.value_type);
+    global.is_mutable = data.GetU8(&offset) != 0;
     global.init_expr_value = ParseGlobalInitValue(data, offset);
     globals.push_back(global);
   }
diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
index 22472f3ad2008e..cdfe6e41bab84d 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -20,6 +20,9 @@ namespace wasm {
 /// A global declared by the module itself. Imported globals occupy the low
 /// indices of the same index space and have no entry here.
 struct WasmGlobal {
+  uint8_t value_type = 0;
+  bool is_mutable = false;
+
   /// Size of the global's value type, which bounds what a read can produce.
   /// Absent for a value type whose values cannot be read.
   std::optional<uint32_t> size;

``````````

</details>


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


More information about the lldb-commits mailing list