Skip to content

Improve debugging support for the VM - #1142

Merged
ImTheSquid merged 4 commits into
mainfrom
jack/grain-vm-debugger
Aug 20, 2026
Merged

Improve debugging support for the VM#1142
ImTheSquid merged 4 commits into
mainfrom
jack/grain-vm-debugger

Conversation

@ImTheSquid

@ImTheSquid ImTheSquid commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Add hooks to pass the debugging tests that previously failed. Also adds a disassembly example.

`call_compiled_body` mirrored `call_script_fn` except for the frame
push/pop, so `back_trace()` saw nothing under the VM.

Per-statement `dbg` calls, the `FunctionExit*` events and the
`Terminate` callback are still absent — breakpoints and stepping
remain inert under the VM.
`call_compiled_body` kept the debugger's call stack and nothing else, so
break-points and stepping were inert. A `debugging` build now marks every
statement, the VM stops at the markers, and leaving a body and reaching the
end of a run are reported.

A statement is the grain of it: `grain/mod.rs` says what an expression-level
stop and a break-point on a name cost. A callback that declares a variable
would move every slot after it, so what it declares does not outlive the stop.
@ImTheSquid
ImTheSquid requested a review from schungx August 19, 2026 22:49
@schungx

schungx commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

LGTM... But need to fix the CI.

I wasn't expecting to support the debugger interface with Grain, but if it can, why not!

Kudos!

@schungx schungx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, but fix CI.

Without the manifest entry, cargo builds the example in every configuration
and it fails to compile wherever `rhai::grain` does not exist — which is every
CI job that does not enable the feature.
@ImTheSquid
ImTheSquid merged commit ff25e1c into main Aug 20, 2026
51 checks passed
@ImTheSquid
ImTheSquid deleted the jack/grain-vm-debugger branch August 20, 2026 05:15
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