Skip to content

Add debug variable locations tracking#17

Open
djolertrk wants to merge 12 commits into0xMiden:nextfrom
walnuthq:feature/debug-variable-locations
Open

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

Conversation

@djolertrk
Copy link
Copy Markdown
Collaborator

@djolertrk djolertrk commented Jan 19, 2026

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

Also adds REPL mode to the debugger.

@djolertrk
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Part of it ready for review at: #18

@djolertrk djolertrk mentioned this pull request Feb 13, 2026
@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from b960a98 to e850d05 Compare February 26, 2026 09:44
@djolertrk
Copy link
Copy Markdown
Collaborator Author

it depends on #30.

@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from e850d05 to dce8e4b Compare April 1, 2026 12:01
@djolertrk djolertrk marked this pull request as ready for review April 1, 2026 12:06
@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from dce8e4b to 10030f3 Compare April 1, 2026 12:55
@djolertrk djolertrk requested a review from bitwalker April 1, 2026 12:55
@djolertrk
Copy link
Copy Markdown
Collaborator Author

note that it still depends on the local miden-vm (0xMiden/miden-vm#2955 is needed).

Implement debug variable tracking and display in the debugger:

- Add DebugVarTracker to track variables throughout execution
- Add DebugVarSnapshot for variable state at specific clock cycles
- Add stub types for DebugVarInfo and DebugVarLocation (pending new miden-core)
- Add resolve_variable_value (currently returns None, pending new miden-core)
- Add :vars/:variables/:locals commands to display current variables

The vars command shows variables in format "name=value" or "name=location"
if the value cannot be resolved.
Also filter compiler locals and fix light terminal rendering
@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from 10030f3 to 833f873 Compare April 14, 2026 14:10
@djolertrk
Copy link
Copy Markdown
Collaborator Author

NOTE: It uses https://github.com/walnuthq/miden-vm/tree/fix/debug-var-dedup-crash -- but 0xMiden/miden-vm#2955 should be merged soon.

@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from 833f873 to 20cf72f Compare April 14, 2026 14:15
Three UX/correctness fixes for the debugger session:

1. `b in <pat>` now matches procedures called via `exec` (not just
   `call`). CallFrame.procedure is sticky — it's set when a new frame
   is pushed (by FrameStart trace events from `call`) and never
   updated afterwards, so for Rust programs that use `exec` internally
   the entire run appears to stay in the first seen procedure (e.g.
   `init`). Extract the live procedure from the current AsmOp's
   context_name instead of the frame, falling back to the frame's
   cached procedure when no asm op is present.

2. Continue past a terminated program now shows "program has
   terminated — use :r to restart" instead of silently doing nothing.

3. Add `:r` and `:restart` as aliases for the existing `:reload`
   command so the restart workflow is discoverable.

Applied to both the TUI home page and the REPL session.
@djolertrk djolertrk force-pushed the feature/debug-variable-locations branch from 20cf72f to 279bb6e Compare April 14, 2026 20:13
@bitwalker
Copy link
Copy Markdown
Collaborator

I think once we can migrate this to the actual VM release on crates.io, we can merge this - but we're blocked on doing so until then.

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.

2 participants