whamm!
is a tool for "Wasm Application Monitoring and Manipulation"1, a DSL inspired by the D language.
Take a look at the official whamm!
book for how to get started with this language.
cargo build
In order to run the tests, a WebAssembly interpreter must be configured. The supported interpreters are:
- the Wizard engine interpreter. https://github.com/titzer/wizard-engine/tree/master
- the Wasm reference interpreter. https://github.com/WebAssembly/spec/tree/main/interpreter
How to build the Wizard GH project to acquire these binaries:
- Install OCaml
- Download
progress
and ensure theprogress
binary is on yourPATH
- Download and build
wizeng
- After running
make -j
, the binariesspectest.*
should be located atwizard-engine/bin/spectest.*
- After running
- Build the Wasm reference interpreter through the Wizard repo, after running the below commands, the binary
wasm
should be located atwizard-engine/test/wasm-spec/repos/spec/interpreter/wasm
# Configure OCaml opam init eval $(opam env) opam install dune opam install menhir # Build the wasm ref interpreter ./wizard-engine/test/wasm-spec/update.sh pushd wizard-engine/test/wasm-spec/repos/spec/interpreter make popd
The interpreter binaries must be runnable using the following commands (this can be done by placing symbolic links to the respective binaries):
- For Wizard:
./output/tests/interpreters/wizard-spectest
- For Wasm-Ref:
./output/tests/interpreters/wasm
To run tests:
cargo test
cargo test parser # Only run the tests for the `parser` module
cargo test -- --nocapture # With stdout tracing
To run project (there are example Scripts in tests/scripts
folder):
cargo run -- instr --app <path_to_app_wasm> --script <path_to_script> <path_for_compiled_output>
To specify log level:
RUST_LOG={ error | warn | info | debug | trace | off } cargo run -- --app <path_to_app_wasm> --script <path_to_script> <path_for_compiled_output>
To use the utility that provides information about match rule globals/functions that can be leveraged by a probe's logic/predicate:
cargo run -- info --rule "<match_rule_glob>" # e.g. "wasm:opcode:br*"
To run a script that uses special var types, at the moment this is map
and report
variables, do the following:
cd <project to instrument>
# debug mode does not optimize the code when compiling (could be helpful when testing to avoid optimizing away event targets)
cargo build --target wasm32-wasip1
cargo run -- instr --app path/to/app.wasm --script path/to/whamm/script.mm -o path/to/output.wasm
cd wasmtime-runner
# change WASM_MODULE to: path/to/output.wasm
vi src/main.rs
# Should print the report data as the app is executing
cargo run
NOTE: There was discussion for moving the probe mode
to the front of the match rule (e.g. mode:provider:package:event
);
however, after thinking through this, I don't think it makes sense until I have a firmer grasp on the types of modes we will
have in this language. If there are more than before/after/alt (that are event-specific), then it would be confusing from a
language-intuition perspective. This is primarily because reading through the spec implies a movement from higher-to-lower
levels of granularity, everything being provided by what proceeds it. If we were to move mode
to the front, but then have
event-specific options, this property would no longer hold.
Currently available:
wasm:bytecode
To be added:
thread
operation eventsgc
operation eventsfunction
enter/exit/unwind eventsmemory
access (read/write) eventstable
access (read/write) eventscomponent
operation eventsBEGIN
/END
eventstraps
exception
throw/rethrow/catch events
Example:
wasi:http:send_req:alt
wasm:opcode:call:alt
wasm:fn:enter:before
If you are wanting to deploy the book locally, use the following commands:
# Install the mdbook cargo package
cargo install mdbook
# Start the mdbook server and open the URL
cd docs
mdbook serve --open
This can be useful for offline learning OR for debugging documentation while doing updates (any local changes will automatically be updated in the served book pages).
Footnotes
-
The 'h' is silent. ↩