Debugging Rust code
There's been some work in this area and it does appear possible to debug code built with wasm-pack using the Chrome DevTools C++ DWARF debugging extension: https://github.com/haraldreingruber-dedalus/rust-wasm-dwarf-debugging
So I have 2 questions - first, is this doable right now? I have been trying to get debugging to work and nothing has worked so far.
Second question is, if it doesn't work yet, is this something that could be put on the radar?
I added a note a while back about preserving DWARF debugging symbols in CPU profiling at https://developers.cloudflare.com/workers/observability/dev-tools/cpu-usage/#taking-a-profile.
For setting breakpoints in VSCode with rust-analyzer, I haven't been able to get it working myself but @zebp said at one point he was able to get something like this to work:
- Enable dwarf debug symbols in
Cargo.toml npx wrangler dev- In VSCode do
cmd + shift + pand runDebug: Attach to node processand then you should be able to select breakpoints (but when I tried this breakpoints still showed up as unattached, so not quite working).
If you do manage to get breakpoints working, do feel free to submit a docs PR like https://github.com/cloudflare/cloudflare-docs/pull/21347.
You might also find https://blog.cloudflare.com/wasm-coredumps/ useful for debugging production code.
Yep I had the same experience, I was able to attach to the node process but wasn't able to attach breakpoints. In the sources section of the chrome debug window it doesn't show the rust code, so something is missing I think, whether it's just some source maps or something else.
Actually never mind - in VSCode with this extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.wasm-dwarf-debugging and the configuration needed to include DWARF symbols in the wasm did allow me to debug Rust code from VSCode.
It's not a great experience since I can't really run anything in the console, but it's something.
I generally prefer Jetbrains products so I was trying to do it in RustRover, but that doesn't seem to be supported unfortunately: https://youtrack.jetbrains.com/issue/RUST-15886/Cant-debug-rust-compiled-to-wasm-with-attached-chrome
RustRover
I went down the exact same path, with the same outcome. Really wish RustRover would have been a full solution as I really liked it, but Cursor changed the game.