home / skills / multiversx / mx-ai-skills / mvx_wasm_debug
This skill analyzes WASM binaries and maps DWARF debug info to Rust sources to help diagnose size, panics, and debugging.
npx playbooks add skill multiversx/mx-ai-skills --skill mvx_wasm_debugReview the files below or copy the command above to add this skill to your agents.
---
name: mvx_wasm_debug
description: Analyzing WASM binaries and debugging via DWARF.
---
# MultiversX WASM Debugging
This skill helps you analyze the compiled `output.wasm` file.
## 1. Binary Size Analysis
- **Twiggy**: Use `twiggy top output.wasm` to see what takes up space.
- **Bloat**: Heavy JSON deserialization code? Large static strings?
## 2. Panic Analysis
- **Abort Messages**: By default, `sc_panic!` adds a string message.
- **Optimization**: `wasm-opt` removes these in production builds (`--opt-level z`).
- **Debugging**: If the contract traps with `unreachable`, check if it ran out of gas or hit a panic without a message.
## 3. DWARF Info
- MultiversX supports building with debug symbols (`mxpy contract build --debug`).
- This allows mapping WASM instructions back to Rust source lines in the debugger.
This skill helps analyze MultiversX WebAssembly binaries and debug contracts using DWARF debug symbols. It guides binary size inspection, panic root-cause analysis, and how to build with debug info for source-level debugging. The goal is faster diagnosis of size bloat, runtime traps, and mapping runtime behavior back to Rust source.
The skill inspects the compiled output.wasm to reveal size contributors and common bloat sources using tools like twiggy. It examines trap patterns and abort messages to distinguish panics, out-of-gas conditions, and optimized-away messages. It explains how to enable DWARF debug symbols during build so a debugger can map WASM offsets to Rust lines for step-through debugging.
How do I enable source-level debugging for my contract?
Build with debug symbols using the debug build command (mxpy contract build --debug). This emits DWARF info that a WASM-aware debugger can use to map instructions back to Rust source.
Why do I see unreachable without a panic message?
Optimizers like wasm-opt can strip string messages in production builds. Also an out-of-gas condition or an explicit unreachable can produce the same trap; check both gas accounting and debug symbols to pinpoint the cause.