#wasm-module #coredump #rewrite

bin+lib wasm-coredump-rewriter

Rewrite Wasm binaries to add coredump support

20 releases

0.2.1 Nov 25, 2024
0.1.24 Nov 14, 2024
0.1.22 Aug 7, 2023
0.1.20 Jul 27, 2023
0.1.7 Jan 31, 2023

#1057 in WebAssembly

Download history 7/week @ 2024-09-21 5/week @ 2024-09-28 203/week @ 2024-11-09 48/week @ 2024-11-16 146/week @ 2024-11-23 48/week @ 2024-11-30

445 downloads per month
Used in wasmgdb

MIT license

170KB
4K SLoC

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.

Dependencies

~5–14MB
~159K SLoC