Skip to content

feat(stdlib): add breakpoint and span to program-image execution - #170

Open
kaihsin wants to merge 1 commit into
mainfrom
feat/program-breakpoint-span
Open

kaihsin wants to merge 1 commit into
mainfrom
feat/program-breakpoint-span

Conversation

@kaihsin

@kaihsin kaihsin commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

With program-image-execution enabled, the CPU's Span and Breakpoint instructions are compiled out, and ExecutionState had no replacement for them. This PR adds both to the program dialect.

  • program::breakpoint suspends the invocation after the instruction. execute/resume return Ok(()) with the new ExecutionState::is_paused() set, and pc() points at the following instruction. The next resume clears the pause and continues from there.
  • A paused invocation is still active (not halted). start/execute and Loadable::replace_image are rejected until it completes or reset() is called, which also clears the pause.
  • program::span file start end records a source span on the current frame, readable through ExecutionState::span(). Callee frames start at (0, 0, 0) and returning restores the caller's span.

The execute/resume return types are unchanged (eyre::Result<()>), so this change is not breaking. Callers check is_paused() to tell a breakpoint from completion.

Test plan

  • New integration tests in crates/vihaco-stdlib/tests/execution_integration.rs: pause/resume at breakpoints, rejection of re-entry while paused, reset, and span recording and restoration across call/return
  • cargo fmt --all -- --check
  • cargo clippy in the default and vihaco/program-image-execution configurations
  • cargo test --workspace --all-targets and --doc
  • cargo test --workspace --exclude vihaco-doctests --all-targets --features vihaco/program-image-execution: all pass except the trybuild fixture vihaco-runtime/tests/compile_fail/dialect/out-of-line.rs, which fails the same way on main (unrelated to this PR)

🤖 Generated with Claude Code

Add `program::breakpoint` and `program::span` to the ExecutionState
dialect. A breakpoint suspends the invocation after the instruction:
execute/resume return Ok(()) with `is_paused()` set and the PC at the
following instruction; the next resume continues from there. A paused
invocation stays active, so start and `Loadable::replace_image` are
rejected until it completes or is reset.

`span` records a source span on the current frame, readable through
`ExecutionState::span()`. Callee frames start at (0, 0, 0) and returning
restores the caller's span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:45
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/vihaco/pr-preview/pr-170/

Built to branch gh-pages at 2026-11-09 14:46 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues blocking the breakpoint suspension and per-frame source-span changes.

No open issues 🎉

What changed in this PR

Adds breakpoint suspension and per-frame source spans to the program dialect for program-image execution, replacing capabilities unavailable from the CPU in this mode.

Changes:

  • Adds breakpoint with pause/resume behavior and an is_paused() accessor, without changing runner return types.
  • Adds span recording and inspection, with fresh spans for callees and restoration on return.
  • Documents the behavior and adds integration tests for pauses, re-entry rejection, reset, and span tracking.
File Description
README.md Documents breakpoint and source-span behavior.
crates/​vihaco-stdlib/​tests/​execution_integration.rs Tests pause/resume, reset, re-entry rejection, and frame spans.
crates/​vihaco-stdlib/​src/​program/​dialect.rs Defines Breakpoint and Span instructions.
crates/​vihaco-stdlib/​src/​loadable.rs Documents paused invocation restrictions and resumption.
crates/​vihaco-stdlib/​src/​execution_state/​storage.rs Exposes pause/span accessors and clears pauses on start/reset.
crates/​vihaco-stdlib/​src/​execution_state/​runner.rs Stops execution at breakpoints and clears pauses on resume.
crates/​vihaco-stdlib/​src/​execution_state/​execution.rs Implements breakpoint and span instruction execution.
crates/​vihaco-stdlib/​src/​execution_state.rs Adds pause state with default and clone support.

Review effort: Balanced

This branch has not been deployed

No deployments
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