# Using Wasm coredump
The following steps describe how to debug using Wasm coredump in Wasmtime:
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 Wasmtime and Wasm coredump enabled:
```sh
$ wasmtime -D coredump=/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
...
...
```
[wasmgdb]: https://crates.io/crates/wasmgdb