Skip to content

Debugging: edit breakpoints and watchpoints through BreakpointState. - #15185

Merged
cfallin merged 2 commits into
bytecodealliance:mainfrom
cfallin:breakpoint-state
Nov 6, 2026
Merged

cfallin merged 2 commits into
bytecodealliance:mainfrom
cfallin:breakpoint-state

Conversation

@cfallin

@cfallin cfallin commented Nov 6, 2026

Copy link
Copy Markdown
Member

In order to prepare for record/replay and reversible debugging, we need a little more discipline about read-only vs. read-write access to the Store. The breakpoint/watchpoint state in the store is a logically separate thing that has more to do with execution strategy than the actual Wasm state (i.e., cannot affect Wasm state).

Also, separately, breakpoints and watchpoints have a somewhat distributed API surface: breakpoints are edited via the existing Store::edit_breakpoints that returns a BreakpointEdit view struct, while watchpoints are edited via Memory::debug_watch. Watchpoints are really a kind of breakpoint (if you squint enough) and both should be managed in the same way.

This PR introduces a BreakpointState view struct in the API returned from Store::edit_breakpoints that manages both breakpoints and watchpoints. This solves both problems: we can now treat BreakpointState as a thing that we can hand out mutably in future record/replay debug APIs (when the overall store is read-only), providing access to exactly and only the bit of execution-control state we want to be mutable.

In order to prepare for record/replay and reversible debugging, we
need a little more discipline about read-only vs. read-write access to
the `Store`. The breakpoint/watchpoint state in the store is a
logically separate thing that has more to do with execution strategy
than the actual Wasm state (i.e., cannot affect Wasm state).

Also, separately, breakpoints and watchpoints have a somewhat
distributed API surface: breakpoints are edited via the existing
`Store::edit_breakpoints` that returns a `BreakpointEdit` view struct,
while watchpoints are edited via `Memory::debug_watch`. Watchpoints
are really a kind of breakpoint (if you squint enough) and both should
be managed in the same way.

This PR introduces a `BreakpointState` view struct in the API returned
from `Store::edit_breakpoints` that manages both breakpoints and
watchpoints. This solves both problems: we can now treat
`BreakpointState` as a thing that we can hand out mutably in future
record/replay debug APIs (when the overall store is read-only),
providing access to exactly and only the bit of execution-control
state we want to be mutable.
@cfallin
cfallin requested a review from fitzgen November 6, 2026 17:26
@cfallin
cfallin requested a review from a team as a code owner November 6, 2026 17:26
Comment thread crates/wasmtime/src/runtime/debug.rs Resolved
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Nov 6, 2026
@cfallin
cfallin enabled auto-merge November 6, 2026 22:30
@cfallin
cfallin added this pull request to the merge queue Nov 6, 2026
Merged via the queue into bytecodealliance:main with commit 5b7ebf2 Nov 6, 2026
52 checks passed
@cfallin
cfallin deleted the breakpoint-state branch November 6, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants