Skip to content

Local variable tracking: emit, decode, and render values in the tracer#270

Open
gnidan wants to merge 3 commits into
mainfrom
ui-local-value-reduce
Open

Local variable tracking: emit, decode, and render values in the tracer#270
gnidan wants to merge 3 commits into
mainfrom
ui-local-value-reduce

Conversation

@gnidan

@gnidan gnidan commented Jul 16, 2026

Copy link
Copy Markdown
Member

This PR adds end-to-end local-variable value tracking to the tracer, from
compiler emission through decoding to the rendered value in the drawer. It
reassembles three pieces the team is reviewing as one coherent change.

Format / packages

  • pointers: add a scalar-first, type-directed value decoder — resolves a
    region's bytes to a typed value (uint, EIP-55-checksummed address, bool,
    intN, bytesN).
  • bugc: emit a sound per-instruction local-variable debug snapshot —
    variables contexts naming each in-scope local and a pointer to the
    memory word holding its current value. A sub-word scalar points at its
    full 32-byte word (the decoder type-aligns within it), gated on sole
    occupancy: a byte-packed sub-word local carries no recoverable value and
    lists as type-only rather than a wrong one.

Implementation

  • web / programs-react: resolve each local to the region holding its
    current value (not every region it has occupied), narrow the trace
    drawer's rendering to that region, and decode the resolved bytes to a
    typed value. Adds an address round-trip trace-playground example so a
    decoded, checksummed address is visible when stepping into the call.

Together these render a local's live value as a single decoded value that
persists across the call, rather than a raw region dump.

Scope (O0): a value pointer is emitted for frame-spilled values —
parameters and memory-homed locals. A let that stays stack-resident has
no memory home, so it lists as type-only ("in scope, no value") regardless
of occupancy — intended at O0, not a gap.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ethdebug.github.io/format/pr-preview/pr-270/

Built to branch gh-pages at 2026-07-16 23:51 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@gnidan gnidan changed the title web/programs-react: render local variables as decoded, single values Local variable tracking: emit, decode, and render values in the tracer Jul 16, 2026
@gnidan
gnidan force-pushed the ui-local-value-reduce branch from 8cbe0b0 to 2a69399 Compare July 16, 2026 21:54
gnidan added 2 commits July 16, 2026 18:21
Emit a `variables` context at each instruction naming the in-scope
locals and, for each, a pointer to the memory word holding its current
value — a per-instruction snapshot the tracer resolves and decodes.

A sub-word scalar (address, bool, intN/uintN, bytesN) is homed by a
full-word MSTORE, so its value occupies the whole 32-byte word. Name the
full word and let the type-directed decoder extract the meaningful bytes,
rather than the type's narrow byte width at the word start — which, for a
right-aligned value, is the zero padding, so an address or bool would
otherwise resolve to zero. uint256 was already correct (its width is a
full word).

Attach the pointer only when the local solely occupies its word: the
allocator byte-packs several sub-word scalars into one word and their
full-word stores clobber each other, so a packed sub-word local has no
recoverable value — it is emitted type-only ("in scope, no value") until
codegen stops byte-packing sub-word scalars.
@gnidan
gnidan force-pushed the ui-local-value-reduce branch from 2a69399 to a1d63c1 Compare July 16, 2026 22:38
Resolve each local to the pointer region holding its current value
rather than every region it has occupied, narrow the trace drawer's
local rendering to that region, and decode the resolved bytes to a
typed value (replacing the raw formatAsDecimal fallback).

Add an address round-trip trace-playground example (`idn(owner:
address)`) so a decoded, EIP-55-checksummed non-uint value is visible
when stepping into the call.
@gnidan
gnidan force-pushed the ui-local-value-reduce branch from a1d63c1 to a682ed6 Compare July 16, 2026 23:22
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.

1 participant