WebAssembly has begun to establish itselfoutside of the browservia dedicated runtimes like Mozilla’sWasmtimeand Fastly’sLucet. While the promise of a new, universal format for programs is appealing, it also comes with new challenges. For instance, how do you debug .wasm binaries?
Thescreencastbelow shows an example debugging session. Specifically, it demonstrates using Wasmtime and LLDB to inspect a program originally written in Rust, but compiled to WebAssembly.
This type of source-level debugging was previously impossible. And while the implementation details are subject to change, the developer experience — attaching a normal debugger to Wasmtime — will remain the same.
By allowing developers to examine programs in the same execution environment as a production WebAssembly program, Wasmtime’s debugging support makes it easier to catch and diagnose bugs that may not arise in a native build of the same code. For example, theWebAssembly System Interface(WASI) treats filesystem access more strictly than traditional Unix-style permissions. This could create issues that only manifest in WebAssembly runtimes.
Mozilla is proactively working to ensure that WebAssembly’s development tools are capable, complete, and ready to go as WebAssembly expands beyond the browser.
Please try it out and let us know what you think.
Note:Debugging using Wasmtime and LLDB should work out of the box on Linux with Rust programs, or with C / C projects built via theWASI SDK.
Debugging on macOS currently requiresbuilding and signinga more recent version of LLDB.
Unfortunately, LLDB for Windows does not yet supportJIT debugging.
Thanks to Lin Clark, Till Schneidereit, and Yury Delendik for their assistance on this post, and for their work on WebAssembly debugging.
Engineer with Mozilla Developer Relations, former Mozilla Persona developer.