wasmi-labs / wasmi

WebAssembly (Wasm) interpreter.

Home Page:https://wasmi-labs.github.io/wasmi/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make it possible to debug and pretty print Wasmi bytecode

Robbepop opened this issue · comments

Currently it is not easily possible to debug or pretty print Wasmi bytecode as generated by the wasmi::Engine.
However, for debugging or inspection purposes or simply for learning how Wasmi produces bytecode it would be very helpful if Wasmi provided an out-of-the-box way to print Wasmi bytecode of a specified function or maybe even the entire compiled Wasm module.

For this we ideally have 2 different mode as is the standard in Rust: Debug and Display

  • Debug would try to stay as close as possible to the underlying Wasmi bytecode data structures while being a bit more readable to the user.
  • Display would optimize on readability and provide a mostly assembly-like reading experience. This could include costly turning branch offsets into labels dividing basic blocks etc.

The Wasmi CLI should expose this functionality in some way.
It must be noted that these print representations might change over time and thus are not a choice for (de)serialization.

If the resulting code to support this feature is very large we might want to put this entire functionality behind a crate feature debug or printing.