#wasm #rewrite #coredump

bin+lib wasm-coredump-rewriter

Rewrite Wasm binaries to add coredump support

8 releases

0.1.12 Mar 6, 2023
0.1.11 Feb 24, 2023
0.1.7 Jan 31, 2023

#742 in WebAssembly

Download history 42/week @ 2023-01-22 39/week @ 2023-01-29 33/week @ 2023-02-05 35/week @ 2023-02-12 76/week @ 2023-02-19 35/week @ 2023-02-26 29/week @ 2023-03-05 6/week @ 2023-03-12 3/week @ 2023-03-19

80 downloads per month
Used in wasmgdb

MIT license

135KB
3.5K 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

~3MB
~66K SLoC