DAP Debugging
The Miden client supports interactive debugging via the Debug Adapter Protocol (DAP). You can debug both raw Miden Assembly scripts and Rust programs compiled to Miden via midenc. This lets you step through execution, set breakpoints, and inspect stack/memory state using any DAP-compatible client (e.g. VS Code, the miden-debug TUI).
Feature Flags
Two feature flags control debugging support:
| Feature | Crate | What it enables |
|---|---|---|
dap | miden-client, miden-client-cli | Compiles in DAP support (execute_program_with_dap, --start-debug-adapter CLI flag). Enabled by default. |
testing | miden-client-cli | Enables the --offline flag on new-wallet/new-account commands for node-less account creation. Not available in production builds. |
Building with features
# Default build (DAP enabled)
cargo build -p miden-client-cli
# With offline mode for testing
cargo build -p miden-client-cli --features testing
# Without DAP (smaller binary)
cargo build -p miden-client-cli --no-default-features
If you build from source with default features disabled, include the dap feature to use
--start-debug-adapter.
Quick Start
1. Create an account
With a running node:
miden-client init
miden-client new-wallet
miden-client sync
Or without a node (requires testing feature):
miden-client init
miden-client new-wallet --offline
2. Write a test script
Create a file test_debug.masm:
begin
push.1.2
add
push.3
mul
end
3. Start the DAP server
miden-client exec \
--script-path test_debug.masm \
--start-debug-adapter 127.0.0.1:4711
The client will compile the script and wait for a DAP client to connect before executing.
4. Connect a debugger
In a separate terminal, connect the miden-debug TUI:
miden-debug --dap-connect 127.0.0.1:4711
You can now step through execution, inspect the stack, and set breakpoints.
How it Works
When --start-debug-adapter is passed:
- The client compiles the transaction script normally.
- Instead of using the default
FastProcessor, it creates aDapExecutor(from themiden-debugcrate) which implements theProgramExecutortrait. - The
DapExecutorbinds a TCP listener on the specified address and waits for a DAP client connection. - Once connected, the DAP client controls execution (continue, step, breakpoints, inspect state).
- If the DAP client requests a restart, the client recompiles the script from disk and re-executes — enabling an edit-and-continue workflow.