Skip to content

feat(tui,trace): trace-replay search, jump-to-cycle, side-by-side diff#411

Merged
nkane merged 1 commit into
mainfrom
feat/391-trace-replay-nav
Jun 3, 2026
Merged

feat(tui,trace): trace-replay search, jump-to-cycle, side-by-side diff#411
nkane merged 1 commit into
mainfrom
feat/391-trace-replay-nav

Conversation

@nkane
Copy link
Copy Markdown
Owner

@nkane nkane commented Jun 3, 2026

Trace-replay navigation polish for accuracy work (v1.3.0, Theme A). Builds on -trace-replay (#64).

What

Command / key Effect
:find EXPR / :rfind EXPR Jump to next / previous frame matching EXPR (:find PC=$8042, :find A=$10 && X=0)
:find / :rfind (bare) Repeat last expression — sweep matches
:cycle N Jump to first frame at/after absolute cycle N
-diff PATH Load a second trace; mark first divergence cycle
d / D Toggle side-by-side diff view / jump both cursors to divergence

How

  • Search: framePredicate compiles the expression with the existing breakpoint expr package and evaluates it against a scratch cpu.CPU loaded from each frame. normalizeFindExpr rewrites a bare = to == so the issue-spec form (PC=$ADDR) works; ==/!=/<=/>= pass through. Memory derefs read live RAM (stale in replay) — register/flag predicates are the supported path, documented.
  • Jump-by-cycle: Replay.SeekCycle binary-searches the monotonic cycle column — O(log N) on a 1M-frame trace (acceptance criterion).
  • Diff: trace.Diff walks both replays by index, returns the first Frame.Equal mismatch (or a length-mismatch divergence at the shorter trace) as trace.Divergence{Index, Cycle, Found}. Computed eagerly in WithReplayDiff, surfaced in the status line on open. Frame.Equal compares PC + registers + cycles, ignoring the PC-derived mnemonic/opbytes and interrupt tag.
  • Diff view: diffModal — double-bordered overlay (same idiom as the help modal) centred on the primary cursor, left column -trace-replay, right -diff, mismatched frames red, gutter at the divergence, at the cursor.

Tests

  • trace: SeekCycle (boundaries, duplicate cycles, past-end), FindFunc (fwd/back, cursor untouched), Diff (first divergence, length mismatch), Frame.Equal.
  • tui: :cycle (landing frame, between-cycles, past-end, bad input), :find/:rfind (forward, backward, repeat, PC expr, errors, not-in-replay), normalizeFindExpr table, WithReplayDiff divergence + identical, diffModal render.

Docs

README flag table (-diff) + new Trace-replay command table; help modal Trace-replay page; docs/context.md merged-PR entry.

Closes #391

Navigation for `-trace-replay` (issue #391):

- `:find EXPR` / `:rfind EXPR` jump to the next/previous frame matching
  an expression over the frame's registers/flags (reuses the breakpoint
  `expr` grammar against a scratch CPU). Bare `=` is normalised to `==`
  so `:find PC=$8042` works as typed; bare `:find` repeats the last
  expression to sweep matches.
- `:cycle N` binary-searches the monotonic cycle column to the first
  frame at/after N (O(log N) via Replay.SeekCycle).
- `-diff PATH` loads a second trace; trace.Diff reports the first
  frame where the two runs disagree (Frame.Equal mismatch, or a
  length-mismatch divergence). The cycle is marked in the status line.
- `d` toggles a side-by-side diff overlay centred on the cursor with
  mismatched frames highlighted and a marker at the divergence; `D`
  jumps both cursors there.

Pure-trace logic (SeekCycle / FindFunc / Diff / Frame.Equal) is unit
tested separately from the TUI wiring. No state-format change.

Closes #391
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

TUI smoke renders

Rendered from 81c073c by the smoke CI job. Replaced on every push to this PR.

chippy-source-scroll (#227)

chippy-source-scroll

chippy-syms (#226)

chippy-syms

chippy-bp-and-run (#225)

chippy-bp-and-run

chippy-console (#232)

chippy-console

@nkane nkane merged commit 0aad7cd into main Jun 3, 2026
13 checks passed
@nkane nkane deleted the feat/391-trace-replay-nav branch June 3, 2026 11:49
@nkane nkane mentioned this pull request Jun 3, 2026
5 tasks
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.

v1.3.0: trace replay — search, jump-to-cycle, side-by-side diff

1 participant