Skip to content

Emit per-step linear-memory snapshots in the execution trace#123

Merged
RaoulSchaffranek merged 3 commits into
masterfrom
feat/memory-tracing
Jul 17, 2026
Merged

Emit per-step linear-memory snapshots in the execution trace#123
RaoulSchaffranek merged 3 commits into
masterfrom
feat/memory-tracing

Conversation

@RaoulSchaffranek

Copy link
Copy Markdown
Member

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 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.

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.
@RaoulSchaffranek
RaoulSchaffranek merged commit e898e5b into master Jul 17, 2026
3 of 6 checks passed
@RaoulSchaffranek
RaoulSchaffranek deleted the feat/memory-tracing branch July 17, 2026 13:36
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