1# Debugging WebAssembly 2 3The following steps describe a common way to debug a WebAssembly module in 4Wasmtime: 5 61. Compile your WebAssembly with debug info enabled, usually `-g`; for 7 example: 8 9 ```sh 10 clang foo.c -g -o foo.wasm 11 ``` 12 132. Run Wasmtime with the debug info enabled; this is `-g` from the CLI and 14 `Config::debug_info(true)` in an embedding (e.g. see [debugging in a Rust 15 embedding](./examples-rust-debugging.md)) 16 173. Use a supported debugger: 18 19 ```sh 20 lldb -- wasmtime run -D debug-info foo.wasm 21 ``` 22 ```sh 23 gdb --args wasmtime run -D debug-info foo.wasm 24 ``` 25 26If you run into trouble, the following discussions might help: 27 28- On MacOS with LLDB you may need to run: `settings set 29 plugin.jit-loader.gdb.enable on` 30 ([#1953](https://github.com/bytecodealliance/wasmtime/issues/1953)) 31- With LLDB, call `__vmctx.set()` to set the current context before calling any 32 dereference operators 33 ([#1482](https://github.com/bytecodealliance/wasmtime/issues/1482)): 34 ```sh 35 (lldb) p __vmctx->set() 36 (lldb) p *foo 37 ``` 38- The address of the start of instance memory can be found in `__vmctx->memory` 39- On Windows you may experience degraded WASM compilation throughput due to the 40 enablement of additional native heap checks when under the debugger by default. 41 You can set the environment variable `_NO_DEBUG_HEAP` to `1` to disable them. 42