-
Notifications
You must be signed in to change notification settings - Fork 6
Description
As discussed at the February in-person meeting, I have been trying to implement translating WebAssembly DWARF to native DWARF debugging that can be used by a debugger like GDB to accurately step through and display the contents of variables.
This is problematic, because some implementations have relocatable linear memory sections, which means the value in memory after compilation is not an actual pointer. Instead, it is an offset from the linear memory section pointer, which must be looked up. This requires accessing a global variable from a DWARF expression using DW_OP_addr, but LLVM does not seem to allow this.
If it were possible to emit DW_OP_addr, then one could construct a workaround by replacing pointers with structs that have a custom member offset. wasmtime says they have managed to do this, but their debugging code doesn't actually seem to use LLVM to emit DWARF information. If they are bypassing LLVM, it would explain how they were able to use DW_OP_addr, and reinforces the need to update LLVM to support this use-case.
If it is possible to convince LLVM to emit the necessary DWARF expressions, I am eager to know how to achieve this. Otherwise I'd like to open a feature request in LLVM to support emitting them.