wasm-coredump-rewriter

Crates.iowasm-coredump-rewriter
lib.rswasm-coredump-rewriter
version0.2.1
sourcesrc
created_at2023-01-24 21:48:01.623803
updated_at2024-11-25 19:29:32.21328
descriptionRewrite Wasm binaries to add coredump support
homepage
repositoryhttps://github.com/xtuc/wasm-coredump/tree/main/bin/rewriter
max_upload_size
id766948
size60,851
Sven Sauleau (xtuc)

documentation

README

wasm-coredump-rewriter

wasm-coredump-rewriter is used to add Coredump generation to a compiled Wasm module.

Installation

cargo install wasm-coredump-rewriter

Usage

Step 1: rewrite the Wasm module

Rewrite the source Wasm module to inject the Coredump runtime code. The runtime will catch traps (excluding traps in host functions or memory violations) and generate a coredump.

Use the following command:

wasm-coredump-rewriter < source.wasm > output.wasm

The Coredump runtime has a performance cost.

Step 2: Wasm execution trapped

Your program entered a trap and a Coredump was generated.

To extract the Coredump write the Wasm instance memory to a file, for instance in JavaScript:

const instance = await WebAssembly.instantiate(...);

try {
    wasi.start(instance);
} catch(err) {
    const image = new Uint8Array(instance.exports.memory.buffer);
    writeFile("coredump." + Date.now(), image);
}

Step 3: analyzing / debugging the coredump

See wasmgdb for analyzing / debugging the coredump.

Commit count: 0

cargo fmt