Introduction
Debugging Wasm? Put some whamm!
on it!
whamm!
is a tool for "Wasm Application Monitoring and Manipulation"1, a domain-specific language (DSL) inspired by Dtrace's D
language.
If you're building a new dynamic analysis for Wasm and are looking for a framework to support you, you're in the right place!
This book will help you get on the right track when working with the language.
whamm!
enables Wasm tool implementers to express their instrumentation using high-level abstractions of program events or locations at various levels of granularity, increasing the expressiveness, intuitiveness, and maintainability of the tool.
Here are some of the goals of whamm!
:
- is high-level and intuitive
- instrumentation is easy-to-build, testable, and debuggable
- express instrumentation in terms of predicated probes
- can instrument events of different granularity
- provide behavior as Wasm functions, say where to call them in
whamm!
- write instrumentation once,
whamm!
takes care of the injection strategy.
Let's take a moment to consider the scale of impact that this DSL could have on developer tooling by considering the following facts:
- WebAssembly is growing to use cases beyond the browser.
- Many languages can compile to Wasm.
- With
whamm!
write instrumentation once to support wide domain of apps.- Use engine instrumentation capabilities as available.
- Use bytecode rewriting to support everything else.
This means that developer tools written in whamm!
could support a vast domain of applications, making WebAssembly the future target platform for debugging.
Resources
Injection strategies:
- Paper describing the non-intrusive injection strategy used by
whamm!
: Flexible Non-intrusive Dynamic Instrumentation for WebAssembly - The library used to do the intrusive injection strategy (bytecode rewriting): orca
Some helpful terms and concepts
- WebAssembly (Wasm): WebAssembly is a binary instruction format for a stack-based virtual machine. It is designed as a portable compilation target for programming languages.
- Instrumentation: When we say we are "instrumenting a program," at a high-level we mean we are "injecting some code into a program’s execution to do some operation." This definition is intentionally generic since instrumentation can really do anything we can imagine! You can use instrumentation to build debuggers, dynamic analyses, telemetry generators, and more.
- Dynamic analysis: A dynamic analysis is something that analyzes a program as it is executing (in contrast to a static analysis which analyzes a program that is not running). This type of analysis can gain useful insights into a program as it is able to access information that is not available statically (such as hot code locations, memory accesses over time, code coverage of test suites, etc.).
- Bytecode rewriting: This is an example strategy for injecting instrumentation logic into the application. It injects instrumentation through literally inserting new instructions into the application bytecode.
1: The 'h' is silent.