Skip to content

Add debug variable locations tracking#17

Draft
djolertrk wants to merge 6 commits into0xMiden:nextfrom
walnuthq:feature/debug-variable-locations
Draft

Add debug variable locations tracking#17
djolertrk wants to merge 6 commits into0xMiden:nextfrom
walnuthq:feature/debug-variable-locations

Conversation

@djolertrk
Copy link
Collaborator

This enables us to use :vars in the debugger and it will print variables values.

@djolertrk
Copy link
Collaborator Author

djolertrk commented Jan 19, 2026

cc @greenhat @bitwalker

Please note that this has some commits that I will remove from the PR (like the ones that point to the local miden-vm, and some commits for porting it to miden-vm v20 needed for the assert debugging feature -- those are just leftovers from local).

But, when using https://github.com/walnuthq/miden-vm/tree/feature/debug-variable-locations-v0.19.1 and 0xMiden/compiler#820, it is able to print real values during debugging session!

Test the source_location_test from the lit tests:

$ ./target/release/miden-debug /tmp/source_location_test.masp \                                                                                                                                              
    --entrypoint "root_ns:root@1.0.0::source_location_test::entrypoint" -- 150
...
# step several times
# type :vars
x=150

@djolertrk
Copy link
Collaborator Author

Part of it ready for review at: #18

@djolertrk djolertrk mentioned this pull request Feb 13, 2026
Replace the old VmStateIterator/VmState/Process API with the new
FastProcessor + ResumeContext stepping API. Key changes:

- Rewrite DebugExecutor to use FastProcessor::step() with noop-waker
  polling, so we avoid tokio runtime conflict in TUI
- Rewrite DebuggerHost to implement the unified Host trait
- Replace MemoryChiplet with direct Memory type from processor
- Update Felt API
- Update StackInputs::new() to take &[Felt] slice
- Remove AssemblyOp::cycle_idx() usage
Implement debug variable inspection by querying the MAST forest directly
at each step:
- Add DebugVarTracker that records variables from forest.debug_vars_for_operation()
- Add resolve_variable_value() for Stack/Memory/Const/Local/Expression locations
- Add format_variables() with FMP-based local variable resolution
- Add :vars/:variables/:locals commands to TUI
- Add REPL mode (--repl flag) with rustyline for interactive debugging
- Add REPL commands: step, next, continue, finish, break, stack, vars, etc.
@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from b960a98 to e850d05 Compare February 26, 2026 09:44
@djolertrk
Copy link
Collaborator Author

it depends on #30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant