Failed to generate native debug information for optimized C code with debug info about dead functions #3403
Labels
wasmtime:debugging
Issues related to debugging of JIT'ed code
wasmtime
Issues about wasmtime that don't fall into another label
I've been attempting to debug some C code recently but unfortunately I keep running into an error that indicates "failed to emit DWARF debug information" when passing the
-g
flag to thewasmtime
CLI. The reproduction of this is:Inspecting the results of
llvm-dwarfdump
I see:With some digging the issue appears to be this:
where gimli is doing addition in the 32-bit address space for ranges which means that from gimli's perspective the start address of this variable is 0xfffffffe and the end address is 0x2, hence the error from gimli itself.
This appears to come about with DWARF debug information for dead code in a program. It appears that LLD specifically uses the value of -2 for representing relocations against dead functions that don't actually show up in the output. The
DW_AT_location
attribute here I believe is encoded as a offset/length which means that the offset receives the relocation of -2 and when gimli adds the length it gets the error that the range is messed up.I believe the real fix here is to basically avoid generating native DWARF debugging information for dead code, or code that comes at the address of -1.
llvm-dwarfdump
already itself prints:and for something like that we should probably just skip over that and not copy over any other attributes related to this subprogram (function). I unfortunately don't know the dwarf code well enough in Wasmtime to know of a great place to put this.
The text was updated successfully, but these errors were encountered: