wabt
wabt copied to clipboard
Source maps for wasm2c?
Does it... make any sense to have source maps for wasm2c?
It would be nice to have something like this, because it's pretty challenging to debug a program that's been compiled from, e.g., C++ (via g++) to Wasm (and then, via wasm2c) to C (and then, via gcc) to ELF. See #1210 & #432.
An MVP might be to make wasm2c include little comments next to each line of a function body, giving a Wat version of the Wasm instruction, so that if you then compile wasm2c's output with -g, a debugger that speaks DWARF can show the Wat for each line. That seems like a one-day project.
But it would be really nice to plumb it all the way through somehow so that a debugger of the final object file can show the original high-level source code.
I think we could use C pre-processor directives: https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html
yup, the C-preprocessor debug directives was something I was hoping to do for several months now, but I don't think I have time on my roadmap. I would love to see support for something like this too!
In w2c2 we parse the DWARF debug info (if provided) from the module, and generate C #line directives. It works fairly well
(Sorry for the delay in responding was traveling) Ah this is good to know. I will add it to my todo list to see if we can get something like this as well. Assuming the licenses are compatible, and there are no objections, I am hoping we can borrow some of the implementation from w2c2 for this effort.