-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support DWARF in wasm-bindgen #2389
Comments
Just hoping for an update as this would be really handy for debugging WASM performance issues. Thx |
After some experiments, I find it's possible to show Rust code in the Chrome DevTools with the following steps:
Then the rust code can show up in the dev tools, but other functionalities such as setting breakpoints and evaluating rust code, are broken: It seems the DWARF info is kept when using wasm-bindgen with |
It seems more like the debug info is "broken" after wasm-bindgen processes it, as in enough to make the source show up, but not enough for Chrome to handle it. |
The extension is for C++ only, and you can see when I try to evaluate |
Yeah, calling methods and stuff almost definitely won't work, but local variables and their fields, and breakpoints are all things that should work and last I tested DO work... if you don't use wasm-bindgen. So that still seems like a strong indication that the dwarf is broken. |
@CryZe did breakpoints work for you?? The devtools find my rust code but none of the standard library or cargo packages. They are all prefixed like |
It's expected and happens because standard library in Rust is prebuilt on CI with those paths hardcoded. You can remap them to either github or your local rust-src paths via the extension settings. But, either way, the breakpoints won't work at the moment because, as mentioned above, DWARF remapping is not implemented in wasm-bindgen. |
got it! thankyou for the quick response 🙏 |
Should probably clarify that this is only if you use wasm-bindgen. If you use raw Wasm, it will work (but that's uncommon on the web). |
ah i got. because wasm-bindgen is actually changing the wasm when it generates the bindings but its not changing the DWARF so nothing matches up. Regular wasm doesnt do that so its not a problem |
Note: with a few changes, I managed to successfully step through However, that fix is very much non-production ready. As I mentioned in the comment linked above, it requires several forks of existing libraries, including Note: I'd like to get more involved with |
Someone has now built this, and playing around with it locally it seems like it works well: https://github.com/mtolmacs/wasm2map |
@Cldfire FWIW that comment above was mistaken, DWARF does work well with Chrome directly: rustwasm/walrus#231 (comment) |
Yea, I can also confirm that DWARF works well for me with Chrome, at least on macOS (M1). |
VS Code's JavaScript debugger is also now DWARF aware (nightly build today, and to stable in 2 weeks). Support here would make targeting wasm from Rust much more pleasant for VS/Code folks 🙂 |
Just for visibility: this is currently only blocked on rustwasm/walrus#247. |
for visibility: rustwasm/walrus#247 has been fixed. |
Awesome! Can't wait to give this a shot on Monday... so I'll probably try it this weekend 😄 |
Well..... @connor4312 ????? I'm on tenterhooks and I believe this is more important than Thanksgiving because if it works I can give thanks! |
How is it decided when new wasm-bindgen versions are released? On demand? |
At cursory investigation, things work with a few caveats:
|
@haraldreingruber-dedalus I think this should be released. Or maybe I am mistaken. |
@connor4312 It looks like the call stack name is not taken from DWARF but rather from the names section? Is that a currently known limitation? |
that's formed from asking the worker for |
Ah weird, could be. It's been couple of years since I tried Rust-produced Wasm in DevTools. I guess they'd need Rust-specific demangling to omit it. Not a big deal either way, thanks for working on this! |
@connor4312 thanks so much for the work on this! I kind of expected this to be released to vscode-insiders but maybe not yet? rustwasm/walrus dependency upgrades are now in the 0.2.89 release (diff) |
It's in tomorrow's Insiders |
Motivation
Chrome, Firefox and now also Sentry support DWARF for WebAssembly as debug format. In particularly for crash reporting systems like Sentry DWARF is a very important tool to create accurate stack traces for production builds of web assembly applications.
This issue was previously brought up in #1981.
Proposed Solution
Most likely the bulk of the implementation will be in walrus (see rustwasm/walrus#67).
The text was updated successfully, but these errors were encountered: