-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source Maps to Aid Debuggability? #2684
Comments
Thanks for the report! Out of curiosity, do you have a language that compiles to WebAssembly with source maps in mind already? For Rust/C/C++ Wasmtime already supports this feature with DWARF debug information:
and the API provides this information through Wasmtime doesn't currently support source maps but that's not because we don't want to, it's just because no one's gotten to it yet! |
I do! A language that compiles to C, namely V, so from wasmtime's perspective it's just normal C code I'm compiling. How should I tell WASI-enabled clang to have the resulting .wasm file include DWARF debug info? (Thanks!) More broadly, unfortunately I couldn't get my C code code to compile with wasi-sdk-12 due to
and didn't know what needed to be recompiled nor which compiler I needed to pass those flags to. I just created an issue for this: WebAssembly/wasi-sdk#174 |
AFAIK it's the typical debuginfo flags in clang, e.g. |
wasi-sdk/llvm's "llvm-dwarfdump" allows to inspect wasm files DWARF sections too. |
I'm going to close this since I think we're pretty unlikely to implement source maps literally. Instead backtraces today already have filenames and line numbers and there's also DWARF info support too. |
Feature
Source maps, to help us debug WASM modules that were written in another language.
That is, it'd be great if WASM errors told us on what line and in what file an exception was thrown in the original source code before it was compiled to WASM.
Benefit
Debuggability. I'm worried that the dream of making WASM the ultimate cross-language compatibility layer will die if debugging our apps remains significantly harder after compiling them to WASM than before. Automatic (though optional) generation of a source map file seems like one reasonable way to solve this problem.
Implementation
I am imagining a file that is generated when the initial $language-to-WASM compilation occurs that maps error strings in the program (that remain in the WASM version) to file names and line numbers in the original source files, or similar. Then, when an error occurs and the source map file (just described) is present, perhaps the stack trace shown could contain code or at least line numbers from the original source so that it's easier to figure out where in the original program the bug lies.
Alternatives
The source map could potentially be built into the compiled WASM module itself, kind of like an unstripped binary, rather then being a separate file, but this would monkey with the WASM file format so I assume you folks won't like that version as much.
The text was updated successfully, but these errors were encountered: