forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds a basic coredump generation after a WebAssembly trap was entered. The coredump includes rudimentary stack / process debugging information. A new CLI argument is added to enable coredump generation: ``` wasmer --coredump-on-trap=/path/to/coredump/file module.wasm ``` See docs/en/examples-coredump.md. Refs wasmerio#3578
- Loading branch information
Showing
4 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Using Wasm coredump | ||
|
||
The following steps describe how to debug using Wasm coredump in Wasmer: | ||
|
||
1. Compile your WebAssembly with debug info enabled; for example: | ||
|
||
```sh | ||
$ rustc foo.rs --target=wasm32-wasi -C debuginfo=2 | ||
``` | ||
|
||
<details> | ||
<summary>foo.rs</summary> | ||
|
||
fn c(v: usize) { | ||
a(v - 3); | ||
} | ||
|
||
fn b(v: usize) { | ||
c(v - 3); | ||
} | ||
|
||
fn a(v: usize) { | ||
b(v - 3); | ||
} | ||
|
||
pub fn main() { | ||
a(10); | ||
} | ||
</details> | ||
|
||
2. Run with Wasmer and Wasm coredump enabled: | ||
|
||
```sh | ||
$ wasmer --coredump-on-trap=/tmp/coredump foo.wasm | ||
thread 'main' panicked at 'attempt to subtract with overflow', foo.rs:10:7 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
Error: failed to run main module `foo.wasm` | ||
Caused by: | ||
0: Core dumped at /tmp/coredump | ||
1: failed to invoke command default | ||
2: error while executing at wasm backtrace: | ||
... | ||
``` | ||
3. Use [wasmgdb] to debug: | ||
```sh | ||
$ wasmgdb foo.wasm /tmp/coredump | ||
wasmgdb> bt | ||
... | ||
#13 000175 as panic () at library/core/src/panicking.rs | ||
#12 000010 as a (v=???) at /path/to/foo.rs | ||
#11 000009 as c (v=???) at /path/to/foo.rs | ||
#10 000011 as b (v=???) at /path/to/foo.rs | ||
#9 000010 as a (v=???) at /path/to/foo.rs | ||
#8 000012 as main () at /path/to/foo.rs | ||
... | ||
``` | ||
[wasmgdb]: https://crates.io/crates/wasmgdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters