Emit per-step linear-memory snapshots in the execution trace#123
Merged
Conversation
Debuggers need linear memory to resolve Rust variables that live in the shadow
stack (the majority at -O0, e.g. any fbreg-located local or parameter). Extend
the instruction trace record with a `mem` field: a full sparse snapshot of the
current module's linear memory, emitted only when it changed since the previous
snapshot (a `<prevMem>` cell holds the last one), else `null`.
The snapshot is a JSON array of `{ "addr", "bytes" }` runs — one per concrete
SparseBytes chunk, `bytes` lowercase hex via the Bytes2Hex hook — so only
written regions are carried; a consumer folds the most recent snapshot at or
before a step and treats unwritten bytes as 0. A `[traceInstr-nomem]` fallback
keeps tracing total for programs with no linear memory.
test_memory_tracing.py deploys the increment example and asserts the field is
present, snapshots are emitted on change (and omitted otherwise), and the folded
image is consistent.
bbyalcinkaya
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Debuggers need linear memory to resolve Rust variables that live in the shadow stack (the majority at optimization level
-O0, e.g., any fbreg-located local or parameter). Extend the instruction trace record with amemfield: a full sparse snapshot of the current module's linear memory, emitted only when it changed since the previous snapshot (a<prevMem>cell holds the last one), elsenull.The snapshot is a JSON array of
{ "addr", "bytes" }runs — one per concrete SparseBytes chunk,byteslowercase hex via the Bytes2Hex hook — so only written regions are carried; a consumer folds the most recent snapshot at or before a step and treats unwritten bytes as 0. A[traceInstr-nomem]fallback keeps tracing total for programs with no linear memory.test_memory_tracing.py deploys the increment example and asserts the field is present, snapshots are emitted on change (and omitted otherwise), and the folded image is consistent.