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!:

  1. is high-level and intuitive
  2. instrumentation is easy-to-build, testable, and debuggable
  3. express instrumentation in terms of predicated probes
  4. can instrument events of different granularity
  5. provide behavior as Wasm functions, say where to call them in whamm!
  6. 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:

  1. WebAssembly is growing to use cases beyond the browser.
  2. Many languages can compile to Wasm.
  3. 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:

Some helpful terms and concepts

  1. 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.
  2. 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.
  3. 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.).
  4. 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.