[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 20 22:11:16 PST 2024
================
@@ -2595,6 +2604,37 @@ bool DWARFExpression::Evaluate(
break;
}
+ case DW_OP_WASM_location: {
+ uint8_t wasm_op = opcodes.GetU8(&offset);
+ uint32_t index;
+
+ /* LLDB doesn't have an address space to represents WebAssembly locals,
+ * globals and operand stacks.
+ * We encode these elements into virtual registers:
+ * | tag: 2 bits | index: 30 bits |
+ * where tag is:
+ * 0: Not a WebAssembly location
+ * 1: Local
+ * 2: Global
+ * 3: Operand stack value
+ */
+ if (wasm_op == 3) {
+ index = opcodes.GetU32(&offset);
+ wasm_op = 2; // Global
+ } else {
+ index = opcodes.GetULEB128(&offset);
+ }
+
+ reg_num = (((wasm_op + 1) & 0x03) << 30) | (index & 0x3fffffff);
----------------
clayborg wrote:
Why are we adding 1 to the wasm_op? Can't we just set it correctly above?
Also it would be nice to have an enum or constant for `0x03` like `kWasmOpMask`, and for `30` like `kWasmOpShift'
https://github.com/llvm/llvm-project/pull/77949
More information about the lldb-commits
mailing list