This commit implements support to emit DWARF debugging information when the WebAssembly text format is converted to binary. Currently there is otherwise no means of translating a binary offset in a WebAssembly file back to the text format that it came from. This support is implemented with a few API knobs here and there as well as two new CLI flags for all the commands that support the text format as input: -g and --generate-dwarf lines|full.
The original motivation of this commit is that I was curious to learn more about DWARF and it seemed like a neat little feature that wouldn't be too hard to maintain. The inspiration was bytecodealliance/wasmtime#8658 which this does not implement as-is (e.g. not custom DWARF, just wasm-text-DWARF). Otherwise though I've realized that this can be useful for development in a few situations:
Wasmtime's backtraces can now mention filenames/line numbers of the WebAssembly text format.
Validation errors can use addr2line to print a filename/line number of a WebAssembly text file.
Wasmtime doesn't have a native debugger nor does LLDB/GDB know about WebAssembly. Through Wasmtime's DWARF transformation this enables debugging WebAssembly text files.
This commit implements knobs for "full" or "line" support in DWARF. The "line" support should be as complete as it can be (DWARF can only provide information for the code section). The "full" support is somewhat basic still but my hope is that it can be expanded in the future as needed.
This commit implements support to emit DWARF debugging information when the WebAssembly text format is converted to binary. Currently there is otherwise no means of translating a binary offset in a WebAssembly file back to the text format that it came from. This support is implemented with a few API knobs here and there as well as two new CLI flags for all the commands that support the text format as input:
-g
and--generate-dwarf lines|full
.The original motivation of this commit is that I was curious to learn more about DWARF and it seemed like a neat little feature that wouldn't be too hard to maintain. The inspiration was bytecodealliance/wasmtime#8658 which this does not implement as-is (e.g. not custom DWARF, just wasm-text-DWARF). Otherwise though I've realized that this can be useful for development in a few situations:
addr2line
to print a filename/line number of a WebAssembly text file.This commit implements knobs for "full" or "line" support in DWARF. The "line" support should be as complete as it can be (DWARF can only provide information for the code section). The "full" support is somewhat basic still but my hope is that it can be expanded in the future as needed.