summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anim/README.md265
-rw-r--r--anim/build.zig21
-rw-r--r--anim/scenes/gallery.zig4
-rw-r--r--anim/scenes/heap.zig114
-rw-r--r--anim/scenes/list.zig14
-rw-r--r--anim/scenes/sqlite.zig2
-rw-r--r--anim/scenes/zoom.zig7
-rw-r--r--anim/src/array.zig9
-rw-r--r--anim/src/calls.zig61
-rw-r--r--anim/src/context.zig198
-rw-r--r--anim/src/cursor.zig95
-rw-r--r--anim/src/descent.zig12
-rw-r--r--anim/src/disasm.zig16
-rw-r--r--anim/src/hexdump.zig24
-rw-r--r--anim/src/loupe.zig15
-rw-r--r--anim/src/map.zig360
-rw-r--r--anim/src/nodes.zig18
-rw-r--r--anim/src/root.zig6
-rw-r--r--anim/src/rows.zig114
-rw-r--r--anim/src/source.zig56
-rw-r--r--anim/src/stage.zig2
-rw-r--r--anim/src/theme.zig9
-rw-r--r--anim/src/ties.zig9
-rw-r--r--anim/src/words.zig1
-rw-r--r--anim/test/gallery/atoms.pngbin104255 -> 104248 bytes
-rw-r--r--anim/test/gallery/loupe.pngbin237157 -> 237233 bytes
-rw-r--r--anim/test/gallery/none.pngbin226437 -> 226569 bytes
-rw-r--r--anim/test/gallery/rest.pngbin232782 -> 233094 bytes
-rw-r--r--anim/test/gallery/rows.pngbin140407 -> 140339 bytes
-rw-r--r--anim/test/gallery/step.pngbin232046 -> 232214 bytes
-rw-r--r--anim/test/gallery/subject.pngbin208454 -> 208638 bytes
-rw-r--r--anim/tools/chart.py13
-rw-r--r--design/motion/motion.py37
-rw-r--r--src/trace/Debugger.zig2
34 files changed, 1125 insertions, 359 deletions
diff --git a/anim/README.md b/anim/README.md
index 27b0983..f4a5a2b 100644
--- a/anim/README.md
+++ b/anim/README.md
@@ -17,6 +17,7 @@ zig build gallery # the gallery's pictures drawn anew int
zig build bench # what a recording costs a frame
zig build bench -- NAME BY [FUNCTION] # a recording's steps (BY: moment, line, over), with what each changed
python3 tools/chart.py chart out/fib-1080.mp4 --out out/motion/fib # the designer's timing chart and checks (POP, CROWD, METRONOME, CAPTION, AIR)
+CANIM_MAP=1 zig build export -Dscene=fib -- DIR --size 3840x2160 # every frame the scene's map filling it, as `list` opens on it: a map at 1:1
```
Needs what sketchbook and ztrace need, and `setarch`, `clang` (the pass
@@ -81,9 +82,10 @@ breakpoint): the line it leaves fires, the registers it changed strike in
a wave 2 f apart in pwndbg's order (fill 6 f, no arm, no pulse), then
memory and the idea, a 36 f hold, the mark out and in (6 f each, the
source fading through first if far), a 24 f rest. Components read it
-through `Cursor.now(at)`; the minimap reads the same values 6 f behind
-(`Cursor.lag`, `time.minimap_lag`), so nothing on it starts on a primary
-onset's frame.
+through `Cursor.now(at)`; the minimap reads the same values 6 f behind and
+five more mirrors a frame apart (`Cursor.lags`, `time.minimap_lag`,
+`time.minimap_fade`: its drawings are averaged), so nothing on it starts
+on a primary onset's frame and nothing on it changes in one.
## The scenes
@@ -94,9 +96,9 @@ onset's frame.
| `list` | a list reversed: each `next` turned; it opens on the map and dives into the frame; after the first load the pointer loaded opens in a loupe, and the `next` in it one deeper | `subject`, `nodes` | `list` |
| `sort` | insertion sort: compares and swaps | `subject`, `array` | `sort` |
| `syscalls` | glibc's `hello`, by instruction from main: `open` followed down (main's call ringed, the PLT's stub passed, libc's wrapper run to its last three instructions and those walked, the kernel's window at the floor with the call in C's form and `returns`, and back up), then `read`, `close`, `write` stepped over, each in three parts: the instructions before the call a cascade onto the call row, the crossing from that row with the kernel's window opening under it (the rows after it making room), the stores after it 18 f after rax | `beside`, `syscalls` (the calls so far, as strace writes them); the disassembly a `descent` (`Context.Options.descent`) | `hello` |
-| `heap` | glibc's malloc under a list of three: three pushes, two pops, a push, told by motion.md's storyboard (nine captions; pushes 2 and 3 at a run; each `free` and the `malloc` that takes the head back walked); the chunks by fields (`size`, `protected`, `key`), the program's list over the tcache's free list with its `bin` (a chunk in neither list drawn in the program's row, unarrowed), the tcache in a loupe over the stack, its stem down the gutter from its chunk's row, opened in each step that changes the tcache and closed at its advance | `subject`, the scene's own drawing (`nodes` in two rows) and view | `heap` |
-| `zoom` | one line of C as its instructions, the call's bytes | `none`, the camera at x2 | `steps` |
-| `sqlite` | a row's way to disk in SQLite: from `sqlite3_step` to `sqlite3BtreeInsert` (three continues, the row's struct on the stack), the commit's `unixWrite` nine calls under `main`, `pwrite64` of page 2 into the kernel, and the page read as a B-tree leaf | `subject`, `backtrace` (`Context.Options.backtrace`), then `syscalls`; its view a `hexdump.Dump` | `sqlite` |
+| `heap` | glibc's malloc under a list of three: three pushes, two pops, a push, told by motion.md's storyboard (nine captions; pushes 2 and 3 at a run; each `free` and the `malloc` that takes the head back walked; what the storyboard does not narrate runs: the calls into push and pop with their prologues, the returns to main but the one under the second free's long caption); the chunks by fields (`size`, `protected`, `key`), the program's list over the tcache's free list with its `bin` (a chunk in neither list drawn in the program's row, unarrowed), the tcache in a loupe over the stack, its stem down the gutter from its chunk's row, opened in each step that changes the tcache and closed at its advance | `subject`, the scene's own drawing (`nodes` in two rows) and view, both on its map too | `heap` |
+| `zoom` | one line of C as its instructions, the call's bytes | `none`, the camera at x2; the map's drawing the calls of `fib` (`Map.drawing`) | `steps` |
+| `sqlite` | a row's way to disk in SQLite: from `sqlite3_step` to `sqlite3BtreeInsert` (three continues, the row's struct on the stack), the commit's `unixWrite` nine calls under `main`, `pwrite64` of page 2 into the kernel, and the page read as a B-tree leaf | `subject`, `backtrace` (`Context.Options.backtrace`), then `syscalls`; its view a `hexdump.Dump`; the backtrace lens drawn on its map | `sqlite` |
| `gallery` | every block in its states | all three | `gallery` |
## The blocks
@@ -110,20 +112,20 @@ every state the code has in the `gallery` scene.
| 1 atom | `address` (`lead`, `name`, `rwx`), `value` (and `Ui.typed`: `fd`, `bool`, `char`), `arrow` (`points`, `holds`, `more`), `mark`s, `plaque` (`chip`), `pin` (`row`, `under`), `bracket` (`quiet`, `tie`, `thread`), `tag` | `src/ui.zig` (`Ui.address`, `.value`, `.arrow`, `.written`, `.corner`, `.read`, `.cellWritten`, `.cellRead`, `.current`, `.trail`, `.unknown`, `.chip`, `.pinRow`, `.pinUnder`, `.bracket`, `.panel`) | marks as mock 15's column B: `current` the white wash (`color.wash`) and the gold plaque; `struck` the softened paper (`color.struck`) with bold bright digits; `held` a turned corner (9; 12 on a lens's cell), in over the cool's last 6 f (`Heat.corner`, `time.strike.corner`); `armed`, `read` |
| | `byte` | `src/rows.zig` `bytes` | `number`, `pointer`, `text` (a string's ink), `loose` (a byte of no field: the allocator's, padding, past what a dump is of), `unread`; `pad`; `bytesAt` moves the bytes right of a long (stack) address, by the dump's widest; a write's arm, strike and held corner cover the bytes whose value changed, first to last (`Run.changed`, `Now.changedBytes`), struck a byte a frame from the low address (what a read fills, 2 f apart) |
| 2 row | `chain`, `reg` (and `rip` with the flags), `slot`, `line`, `bytes`, `call` (`span`, `callRow`) | `src/rows.zig` | `chain` follows `zt.telescope.chase`; cut at its far end, `more`. `slot`: pins from 16, the offset from rsp ranged right to 172, the address at 184, the chain, its role ranged right where the room ends, from `zt.telescope.slots` (`saved rbx`, a local's name in primary, `n, high half` for a narrower local in the word's top four bytes, `argc`, `argv[0]`, `argv end`, `envp end`, `auxv`; nothing for a return address or `.none`). `bytes`: the bracket at 24, the address at 34, the bytes 12 after it and at 132 at least |
-| | `arc` | `src/rows.zig` (`Arcs`), `src/hexdump.zig` (`pointerArcs`) | a pointer to a row of its own panel: lanes at 4, 10, 16 in a dump or a loupe, 4 and 10 on the stack; longest outermost, a chain in one lane; standing at 60% toward the page, full in the step that writes or reads it and always in a loupe; rewritten: the old dashed with the arm, fading from 6 f after the strike as the new draws (12 f), quieting with the cool; a stub to the rule for a target in the region past the window, only in its step; a saved rbp's only in its step; a dump withholds the arcs an open loupe carries |
+| | `arc` | `src/rows.zig` (`Arcs`), `src/hexdump.zig` (`pointerArcs`) | a pointer to a row of its own panel: lanes at 4, 10, 16 in a dump or a loupe, 4 and 10 on the stack; longest outermost, a chain in one lane; standing at 60% toward the page, full in the step that writes or reads it and always in a loupe; rewritten: the old dashed with the arm, fading from 6 f after the strike as the new draws (12 f), quieting with the cool; a lane change glides while the arc that causes it draws or fades (`Arcs.assign`, with and without the arcs on their way); a stub to the rule for a target in the region past the window, only in its step; a saved rbp's only in its step, going with its advance (18 f); a dump withholds the arcs an open loupe carries |
| | `insn` | `src/disasm.zig` | columns at 2, 31, 40, 134, 180, 264, 564; size words dropped from every operand, a `width` of byte cells (`metric.width`) after the `]` where no register outside the brackets has the access's size and the mnemonic does not fix it; `nop` and `endbr64` faint; a PLT target named (`401070 open@plt`); the annotation from 564 or a character after the operands, then the operands give way, never inside `[]`; `current`, `ran` (every instruction of the last three steps), `ahead`, `outside`, `waiting`, `pass`; the jump lane from the jump just before the pc's moment. The row's detail, every value the recording's at that moment: a compare's two values and the flags it leaves as chips (those the conditional after it reads; CF ZF SF OF when none); a conditional's `taken`/`not taken · reads` and its flags, `→ target` when it leaves the window, and while it runs the setting row's chips and rip's framed as read (an echo); `lea`'s `= value`; a call through memory or a register `→ target name · read from open@got, 403fd8` (out of room the slot goes, then the digits); a call through a PLT stub by the function it reaches (`the resolver` while its slot is lazy); `fs:[0x28]` as the stack's canary (`canary` where the row has no room); a `rep`'s count and step; `syscall` with its name and number, its arguments under it by register, typed (`-100 AT_FDCWD`, `O_RDONLY`), the rows they hang over giving up their own annotation; a call that has run in C's form with its result (`read(3, …) = 15`: out of room the arguments go from the right, the result stays); a memory access narrower than a word read at its width (`rows.narrow`: `7fffffffecc4 ◂ 15`) |
| | `descent` | `src/descent.zig` (`Descent`, `step`) | the disassembly a call deep: the root's window on top (main), each callee's under the row that called it (that row `waiting`, ringed, its annotation the call in C's form), a PLT stub gone through kept as its `jmp`, `pass`; a head row over each window (the name at 40, Go Medium 18; what it is ranged right: `libc.so.6 · no source`, `the PLT · its jmp reads open@got, 403fd8`, `the PLT, jumped through`); the call lane at x 14; the nearest caller takes the rows the deepest does not use, all above its call row (one row after it, the return row, the callee's head directly under that), and where its function starts first the rest go back to the deepest window; three code windows at most, the rest one `more` row; each window's addresses its own width; the tag the deepest function and its module (`open · libc.so.6`); at a `syscall` (and the stop after it) the floor's three rows are the kernel's: in a crossing the lane down from the plaque (3, vellum), the window filling down, `the kernel` and `openat, system call 257`, the call in C's form, `returns` struck, `rcx, r11: clobbered`, the answer climbing the lane (24 f, `glide`), the window drawing back at the advance. A crossing stepped over opens the same window under the call row, past the arguments hanging under it, the rows after them making room (18 f) and closing up with the window. Every row keyed (an address, a head), so a step is the rows both stops have gliding and the rest leaving or arriving on its verb's timetable, in two moves, never at once: `descend` (2.9 s: the given-up rows fade 66–78, the kept ones glide 78–96, ring 84–96, lane 96–114, head 108–120, rows 114–138), on through a stub's `jmp` (2.2 s), `ascend` (2.5 s: the window closes 48–72, lane back 72–84, the kept rows glide 84–102, the given-up ones fade in 102–114), `cross` (`syscalls.step`); a row whose state the verb changes (the call row to `waiting` with its hanging arguments, a jmp to `pass`, a waiting call taking its result) crossfades; with it the source's line `waiting` (ringed, the tag `main waits at line 6 · the pc is in libc's open`, crossfading over the 12 f before the advance, as a stack span's name does) and the thread waiting (primary, 2) |
-| 3 panel | `registers`, `stack`, `backtrace` | `src/context.zig` | the backtrace newest at the bottom, `#0` last, the oldest dropped from the top (`newest at the bottom · 2 more above`), as a panel, the calls lens's view, the backtrace lens and on the map; the stack's window on `[rsp, rbp+16)` keeping the touched word in view, its tag the first and last word shown (`rsp+20 to rsp+48`), rsp and rbp's pins travelling 18 f after rsp's strike (`time.pin`, keeping their place among the names they leave and join), at rest only where the register points; a window that moves farther than its own height (six or eight slots) fades out and in round memory's strike, and what it brings, and what changed before it, is plain; a frame's name longer than the spans' room shortens the chains beside it; `call` spans and the backtrace (`#n`, name, arguments at 384, file and line) from `zt.telescope.frames`, the frames two stops share sliding to their new depth; the backtrace as a lens's drawing with `Context.Options.backtrace` |
-| | `source` | `src/source.zig` | the whole file in a window, its middle third; numbers as wide as the program's largest line (SQLite's six digits), the text moved right by as much; a window going farther than its own height fades out and in |
-| | `disasm` | `src/disasm.zig` | 17 rows (9 as subject), fewer above near a function's start; the line column as wide as the source's; two windows that overlap scroll, others fade out and in |
-| | `hexdump` | `src/hexdump.zig` | malloc's words: a field read as `size` (`0x20 a m P`, the bits as rip's flags) or `protected` (`→ 405050 ^ 405`, `NULL ^ 405`, its arc to the pointer it protects), and a field's `note` (Go 18 faint: `key`, `top`, `slots left`); a lens's view (`hexdump.panel`): `bytes` rows and their reading, veiled at a sprint; one reading for every dump (`hexdump.reading`), a list a character apart, a typed number as its type reads (`char` quoted, `bool` by name); the address room once a dump, by its widest; `Dump`, a view of a region by the fields a scene gives it (`Field`: where, how long, read as a number, big-endian or not, a pointer, text, or left to the eye), the rows that hold a field and a `more` row for each stretch left out, and where those rows outnumber the window, a window kept round the first row a mark or the step is on, the rest folded into `more` rows; marks the scene plays, and the step's only from the stop it came in at (`since`); the bytes a syscall was given as the kernel took them (`given`), and only what the debugger read at the stop (`seen`) |
+| 3 panel | `registers`, `stack`, `backtrace` | `src/context.zig` | rip's value crossfading over the advance, a flag set or cleared over the 6 f it lands in (`rows.RipWas`); the backtrace newest at the bottom, `#0` last, the oldest dropped from the top (`newest at the bottom · 2 more above`), as a panel, the calls lens's view, the backtrace lens and on the map, all one block (`backtraceRows`: frames leave, slide and arrive; what a kept row says that changes, its depth, its pc's offset, its line, and the tag's count, crossfades, 12 f before the advance); the stack's window on `[rsp, rbp+16)` keeping the touched word in view, its tag the first and last word shown (`rsp+20 to rsp+48`), a word's role and offset, and the tag, crossfading (12 f from memory's strike) where the step changes them, rsp and rbp's pins travelling 18 f after rsp's strike (`time.pin`, keeping their place among the names they leave and join), at rest only where the register points; a window that moves farther than its own height (six or eight slots) fades out and in round memory's strike, and what it brings, and what changed before it, is plain; a frame's name longer than the spans' room shortens the chains beside it; `call` spans and the backtrace (`#n`, name, arguments at 384, file and line) from `zt.telescope.frames`, the frames two stops share sliding to their new depth; the backtrace as a lens's drawing with `Context.Options.backtrace` |
+| | `source` | `src/source.zig` | the whole file in a window, its middle third; the trail's bars crossfading with the advance; numbers as wide as the program's largest line (SQLite's six digits), the text moved right by as much; a window going farther than its own height fades out and in |
+| | `disasm` | `src/disasm.zig` | 17 rows (9 as subject), fewer above near a function's start; the line column as wide as the source's; two windows that overlap scroll, others fade out and in; its tag's function (a descent's tag too) crossfading with the advance |
+| | `hexdump` | `src/hexdump.zig` | malloc's words: a field read as `size` (`0x20 a m P`, the bits as rip's flags) or `protected` (`→ 405050 ^ 405`, `NULL ^ 405`, its arc to the pointer it protects), and a field's `note` (Go 18 faint: `key`, `top`, `slots left`); a lens's view (`hexdump.panel`): `bytes` rows and their reading, veiled at a sprint; a row whose bytes the step changed where the recording saw no write (memory nothing watches, read anew at a stop), or that became known, crossfading over 12 f (`rowPasses`); one reading for every dump (`hexdump.reading`), a list a character apart, a typed number as its type reads (`char` quoted, `bool` by name); the address room once a dump, by its widest; `Dump`, a view of a region by the fields a scene gives it (`Field`: where, how long, read as a number, big-endian or not, a pointer, text, or left to the eye), the rows that hold a field and a `more` row for each stretch left out, and where those rows outnumber the window, a window kept round the first row a mark or the step is on, the rest folded into `more` rows; marks the scene plays, and the step's only from the stop it came in at (`since`); the bytes a syscall was given as the kernel took them (`given`), and only what the debugger read at the stop (`seen`) |
| | `loupe` | `src/loupe.zig` (`canim.loupe`, `Loupe.open`, `.close`) | from a register, a loupe's field, or a dump's row read by the scene's fields (`.row`: malloc's tcache, `num_slots[0]` and `entries[0]`, the rest `more`); five rows round a pointer's target, lifted (`color.lift`, `lift_tag`, `shade` 12 and 16; 20 and 26 deeper), hanging from its pointer (its tag on the row's foot, 92 left of the digits, clamped to the stage), a 4-high bracket under the digits its stem, the target's fields framed bright; one opened from the band's view lies over the stack, never the registers, its stem down the gutter's right lane (x 962), its fields struck once it has opened (6 f after, 6 f apart: `Fields.struck`); a deeper one with no room to the right hangs under the one it opens from, its stem down to its tag; a note that does not fit is cut at a word with `…`; `open` 36 f (read 6, stem and rise 18 with the shadow, the frame 6 f after), `close` 12 f; it opens again after a close |
-| | lenses: `nodes`, `array`, `calls`, `syscalls`, `backtrace` | `src/nodes.zig`, `src/array.zig`, `src/calls.zig` (`Tree`), `src/syscalls.zig` (`Crossing`), `src/context.zig` (`Backtrace`, `lens`) | the drawing in `band` (over the program column), its view in `view` (over the state column): `nodes` and `array` a dump (`hexdump.panel`), `calls` the backtrace with arguments, `syscalls` the calls so far as strace writes them (oldest on top, the newest coming in once it is back, held) over the bytes the call crossing in the step is given or fills (in with the argument framing, 12 f out and 12 f in; what a read fills landing a byte every 2 f, struck, the stack's words with them; a write's buffer framed as read while the kernel takes it; cleared with the log's new row: between crossings `no call crossing now`), `backtrace` (eleven rows as subject, five beside) a `Dump` the scene gives; an `under` pin's names in the order they came, the first left |
+| | lenses: `nodes`, `array`, `calls`, `syscalls`, `backtrace` | `src/nodes.zig`, `src/array.zig`, `src/calls.zig` (`Tree`), `src/syscalls.zig` (`Crossing`), `src/context.zig` (`Backtrace`, `lens`) | the drawing in `band` (over the program column), its view in `view` (over the state column): `nodes` and `array` a dump (`hexdump.panel`), `calls` the backtrace with arguments, `syscalls` the calls so far as strace writes them (oldest on top, the newest coming in once it is back, held) over the bytes the call crossing in the step is given or fills (in with the argument framing, 12 f out and 12 f in; what a read fills landing a byte every 2 f, struck, the stack's words with them; a write's buffer framed as read while the kernel takes it; cleared with the log's new row: between crossings `no call crossing now`), `backtrace` (eleven rows as subject, five beside) a `Dump` the scene gives; an `under` pin's names in the order they came, the first left, faded out through the middle of a register's joining or leaving (`Pins.text`); a call node's look (gold, ringed, done) crossfading as the tree's moment changes (6 f), and at a sprint a new node coming in over its step |
| 4 tie | `thread`, `link` (and its `pin`), `projection`, `echo` | `src/ties.zig` | panels publish places (`anchor`); `Ties`, added last, draws in the channels: a link climbs to a node by the gutter's left lane and goes down to a slot by the right, its name riding its head, a target past the stack's window a stub and a row count; a projection from the view's bytes, or from a frame's return address to its call's node |
-| 5 frame | `map`, `minimap`, `dive`, `surface` | `src/map.zig` (`Map`, `split`, `minimap`), `Context.map` | the working frame's panels bound to a stage of 3840 by 2160 (`map.split`, packed by content: each box as long as the most rows its panel has wanted, `measure`; the drawing, the source and under it the backtrace; the disassembly; the view, the registers, and in the column's rest the stack going on, `stack, continued`; the stack from 16 words above rsp); its rows published while `ui.mapping`; the working windows outlined (2 `dim`, 4 out); the thread across the gutter (x 1008), gold; the minimap the same at a twentieth under the clock (text as 1-unit strokes at 45% toward the page, marks as blocks; `ui.strokes`), 6 f behind the frame, a stack word struck outside the stack's window flashing on it (a ring 8 to 14, 12 f), the count ranged right at 1648; `Map.show`, `.dive` (outlines bright 6 f, veil to 24, each panel from its window to its place 60 f, 6 f apart, a panel drawn over another setting off first (drawing, view, disassembly, stack, source, registers) so that none in its place is crossed by one on its way, opaque on the way, its rows on the window's rows, its tag and rules in at the end; the map falls into the minimap's corner over 72 f, its scale on the logarithm, its corner going toward the minimap's as the scale does, small it is drawn over the panels with its edge, and crossfades into the minimap's drawing at 90–96; 120 f and 30 f still), `.surface` (the dive back, 84 f, then 30 f still); per-panel transforms through `context.at` (`context.zoomed`) |
+| 5 frame | `map`, `minimap`, `dive`, `surface` | `src/map.zig` (`Map`, `split`, `minimap`), `Context.map` | the working frame's panels bound to a stage of 3840 by 2160 (`map.split`, packed by content: each box as long as the most rows its panel has wanted, `measure`, the backtrace's as long as the deepest call chain of the scene's way, so that it is packed once; the drawing, the source and under it the backtrace; the disassembly; the view (none where nothing draws one), the registers, and in the column's rest the stack going on, `stack, continued`; the stack from 16 words above rsp; and the first two columns' rest (`Split.spare`) given, in the catalogue's order, to `map.Spare`: a five-row dump round each place the registers (pwndbg's order, not rsp or rbp) and the 64 words up from rsp point at outside the stack and the code, none within another's rows, then the loupes open (`Map.loupes`, lifted, nine rows), then the key (the recording and the moment, the marks as drawn, the inks); only then page); its rows published while `ui.mapping` (the dumps' too); the working windows outlined (2 `dim`, 4 out), each window published with where its step took it from and how far its scroll has gone, so its outline glides; the thread across the gutter (x 1008), gold; a scene without a band can put a drawing on its map (`Map.drawing`); the minimap the same at a twentieth under the clock (text as 1-unit strokes at 45% toward the page, marks as blocks; `ui.strokes`), drawn six times into the host's images, each from the cursor's mirror a frame later (6 to 11 f behind: `Cursor.lagInto`, `time.minimap_fade`) and averaged, so that every change on it fades in over 6 f and nothing on it changes in a frame; its outlines on whole pixels at rest and between them only as they glide; a mark no working window shows (a word struck or read on the stack or in a dump the map draws) flashing on it (a ring 8 to 14 in the mark's colour, 12 f), the count ranged right at 1648; `Map.show`, `.dive` (outlines bright 6 f, veil to 24, each panel from its window to its place 60 f, 6 f apart, a panel drawn over another setting off first (drawing, view, disassembly, stack, source, registers) so that none in its place is crossed by one on its way, opaque on the way, its rows on the window's rows, its tag and rules in at the end; the map falls into the minimap's corner over 72 f, its scale on the logarithm, its corner going toward the minimap's as the scale does, small it is drawn over the panels with its edge, and crossfades into the minimap's drawing at 90–96; 120 f and 30 f still), `.surface` (the dive back, 84 f, then 30 f still); per-panel transforms through `context.at` (`context.zoomed`) |
| | `stage` and `relayout` | `src/stage.zig` | splits `none`, `beside`, `subject` (`theme.layout.split`): the band is `band` (the drawing) and `view`; `relayout` fades the drawing round its move; `holdStack` holds the stack's window for the camera, with `free` slots |
| | `clock`, `caption`, `veil`, `card` | `src/words.zig`, `src/root.zig` (`Narrator`, `Camera`) | the clock still while a step plays, its piece fading in once the mark lands; a caption stays its reading time; the title card is `scenes/title.zig` |
-| 6 verb | `fire`, `arm`, `strike`, `cool`, `read`, `extend`, `link`, `project`, `travel` (pins), `advance`, `cascade`, `continue` (`Cursor.continue`, `Plan.wave`), `run`, `sprint`, `establish` (`Context.establish`: a drawing's elements fade in rising, no lines), `scroll`, `relayout`, `visit`, `say` | `src/cursor.zig` (the timetable), the blocks (each draws its state at the instant) | tokens in `theme.time`; a level gives up its slot when nothing it touched is drawn (`Recording.drawn`) |
+| 6 verb | `fire`, `arm`, `strike`, `cool`, `read`, `extend`, `link`, `project`, `travel` (pins), `advance`, `cascade`, `continue` (`Cursor.continue`, `Plan.wave`), `run`, `sprint`, `establish` (`Context.establish`: a drawing's elements fade in rising, no lines), `scroll`, `relayout`, `visit`, `say` | `src/cursor.zig` (the timetable), the blocks (each draws its state at the instant) | tokens in `theme.time`; a level gives up its slot when nothing it touched is drawn (`Recording.drawn`); a label that changes in place with a step crossfades over the 12 f before the advance, or from the step's start where that is sooner (`Now.renaming`); at a run what marked a value goes with the run's ease (8 f) and a pin changes over it; at a sprint an ember and what grows come in over the step (4 f), never in a frame |
`Recording` (`src/Recording.zig`) is the index every block reads: lines,
calls, syscalls, allocations, which registers and bytes each moment changed
@@ -148,9 +150,9 @@ and no canary stepped through that the source does not say.
| --- | --- | --- | --- | --- |
| `steps` | `fib.c`, static musl, `-O0` | every instruction | 1999, 431 KB (336 KB before) | |
| `hello` | `hello.c`, the system's clang and glibc, dynamic: `-O0 -g -no-pie -fstack-protector-strong -Wl,-z,now` (a PLT bound at load, no resolver; the canary) | every instruction, `--from main`, `--steps 132` (to main's return) | 166 (30 of them the loader's syscalls before main), 83 KB (233, 126 KB: static musl by line) | reads `tools/note`; PLT stubs and GOT slots named (`open@plt`, `open@got`) |
-| `heap` | `heap.c` (design/mock/heap.c), the system's clang and glibc, dynamic, as `hello` | every line, `--from main` | 75, 59 KB | `--heap` (`ztrace.heap.glibc`: chunks, the tcache, bins, the arena); `-w 0x405000,1024` (the chunks' bodies) and `-w head` (the global the list hangs from: unwatched, a recording keeps a global as last seen) |
+| `heap` | `heap.c` (design/mock/heap.c), the system's clang and glibc, dynamic, as `hello` | every line, `--from main`, and pop's `call free@plt` (`break_call`: a breakpoint objdump finds, which a line-stepping recorder now stops at) | 77, 59 KB | `--heap` (`ztrace.heap.glibc`: chunks, the tcache, bins, the arena); `-w 0x405000,1024` (the chunks' bodies) and `-w head` (the global the list hangs from: unwatched, a recording keeps a global as last seen) |
| `sort` | `sort.c`, `ztrace cc --instr vars --only sort,a` | every instruction, `--from main` | 4396, 751 KB (5154, 799 KB at `--stack 256`) | `--ring`: the variables' names and types; each `__zt_var` call is stepped (4 of them) |
-| `list` | `list.c`, `ztrace cc --instr vars --only push,reverse,head` | every instruction, `--from reverse` | 2913, 742 KB (3369, 782 KB at `--stack 256`) | `--alloc --preload` the agent: allocator headers are read; the pushes (the agent's and the runtime's first calls) run through |
+| `list` | `list.c`, `ztrace cc --instr vars --only push,reverse,head` | every instruction, `--from reverse` | 2920, 743 KB (2913 the pass before: the count differs by a few moments from one recording to the next, not looked into; 3369, 782 KB at `--stack 256`) | `--alloc --preload` the agent: allocator headers are read; the pushes (the agent's and the runtime's first calls) run through |
| `gallery` | the old `list` by line, kept in `test/gallery/list.ztrace` | | 134, 88 KB | the gallery's pictures depend on the drawing only |
| `sqlite` | `sqlite.c` (three rows into a table, committed) with SQLite 3.50.4's amalgamation, system clang `-O2 -g -fno-omit-frame-pointer -no-pie -fno-stack-protector -Wl,-z,now`, glibc | `--by break`: `sqlite3_step`, `sqlite3BtreeInsert`, `unixWrite`, and the instruction after its `pwrite64` (found by objdump); every syscall recorded, `-s 4096` | 181 (42 stops, 138 syscalls), 233 KB (139 KB) | made only with `-Dsqlite=DIR` (default `~/05-genizah/sqlite/sqlite-amalgamation-3500400`), in a new temporary directory each time; `sqlite3.c` is embedded as the source |
@@ -171,54 +173,121 @@ panels are; the clock, ranged right at 1648, its own region, whose count
changing in a frame is no POP; the caption's box from 940, under the
clock's count and a run's step counter; the minimap its own region,
secondary action, and its one-frame changes POPs). POP: any region still
-for 12 f that changes in one frame and is still again. CAPTION: up over
-720 f, up under 90 f + 3.6 f a character (chart.py counts the characters
-of the scene's `says.line` strings as shown; where the video's arrivals
-and the scene's captions do not pair up it says so and checks no reading
-time), or the picture moving within 60 f of its arrival. Encoded with
-`-g 600`: x264's keyframe at 10, 20, 30 s is a one-frame fade the
-instrument sees. "Before" is the last pass's exports charted by this
-instrument (the old scenes' captions are not the sources' now:
-syscalls' and heap's reading times not checked); "after" this pass's.
+for 12 f that changes in one frame and is still again. A one-frame change
+that is right is counted apart by name (`POP exempt`), never dropped:
+`keyframe`, x264's I frame (`-g 600`: 10, 20, 30 s) re-quantizing a still
+region, under 200 pixels moved (motion.py reads the video's I frames with
+ffprobe; the caption check skips such a frame and the one after it too);
+`cut`, the gallery's pages, which are the catalogue's pictures cut one to
+the next (chart.py names their times). CAPTION: up over 720 f, up under
+90 f + 3.6 f a character (chart.py counts the characters of the scene's
+`says.line` strings as shown; where the video's arrivals and the scene's
+captions do not pair up it says so and checks no reading time), or the
+picture moving within 60 f of its arrival; chart.py does not count the
+list's dive (150 to 300 f) as a caption's change: the falling map passes
+under the caption, which does not change. "Before" is the last pass's
+exports (as the brief counted them; the same exports by this instrument
+in brackets: the keyframes and cuts apart); "after" this pass's.
| | fib | list | sort | syscalls | zoom | sqlite | heap | gallery |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
-| POP, before / after | 43 / 44 | 52 / 43 | 41 / 32 | 72 / 66 | 19 / 22 | 11 / 14 | 83 / 72 | 13 / 10 |
-| of them the minimap's, before / after | 13 / 16 | 31 / 26 | 17 / 15 | 45 / 47 | 12 / 14 | 5 / 8 | 49 / 48 | 6 / 5 |
-| CROWD, before / after | 2 / 2 | 6 / 8 | 4 / 5 | 5 / 2 | 3 / 3 | 0 / 0 | 10 / 7 | 3 / 4 |
-| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 9 / 9 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 |
-| CAPTION up over 720 f, before / after | 0 / 0 | 3 / 2 | 0 / 0 | 0 / 0 | 1 / 1 | 0 / 0 | 4 / 1 | 0 / 0 |
-| CAPTION under its reading time, after | 0 | not paired | 0 | 0 | 0 | 0 | 0 | |
-| CAPTION picture moving within 60 f, before / after | 0 / 0 | 1 / 1 | 0 / 0 | 1 / 1 | 0 / 0 | 2 / 2 | 1 / 1 | 0 / 0 |
-| AIR, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 2 / 2 | 1 / 1 | 5 / 5 | 2 / 0 | 0 / 0 |
-| seconds, before / after | 41.5 / 42.0 | 70.9 / 71.1 | 42.0 / 42.2 | 76.0 / 89.2 | 32.0 / 32.0 | 64.6 / 64.6 | 100.4 / 96.8 | 11.0 / 11.0 |
+| POP, before / after | 44 (44) / 14 | 43 (40) / 14 | 32 (32) / 8 | 66 (65) / 26 | 22 (22) / 7 | 14 (13) / 7 | 72 (71) / 21 | 10 (7) / 5 |
+| of them the minimap's, before / after | 16 / 5 | 26 / 7 | 15 / 2 | 47 / 16 | 14 / 4 | 8 / 3 | 48 / 9 | 5 / 3 |
+| POP exempt, after | | keyframe 3 | | keyframe 2 | | keyframe 2 | | cut 3 |
+| CROWD, before / after | 2 / 4 | 8 / 8 | 5 / 6 | 2 / 3 | 3 / 3 | 0 / 0 | 7 / 15 | 4 / 4 |
+| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 9 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 |
+| CAPTION up over 720 f, before / after | 0 / 0 | 2 / 0 | 0 / 0 | 0 / 0 | 1 / 0 | 0 / 0 | 1 / 0 | 0 / 0 |
+| CAPTION under its reading time, after | not paired | 0 | 0 | 0 | 0 | 0 | 0 | |
+| CAPTION picture moving within 60 f, before / after | 0 / 1 | 1 / 0 | 0 / 0 | 1 / 0 | 0 / 0 | 2 / 0 | 1 / 0 | 0 / 0 |
+| AIR, before / after | 0 / 0 | 0 / 2 | 0 / 0 | 2 / 2 | 1 / 1 | 5 / 5 | 0 / 0 | 0 / 0 |
+| seconds, before / after | 42.0 / 42.0 | 71.1 / 84.5 | 42.2 / 42.2 | 89.2 / 89.2 | 32.0 / 33.6 | 64.6 / 64.6 | 96.8 / 78.1 | 11.0 / 11.0 |
-What fires, and why it is left, by kind (examined this pass):
+The kinds of one-frame change, each fixed at its block (every scene that
+draws the block gets it), counted on the last pass's exports:
-- POP, the minimap (about half of every scene's): it follows the frame
- 6 f behind, but a row's stroke or a mark's block changes in one frame;
- a fade of each change is not built.
-- POP, registers, stack, view: a read frame that goes in one frame, a
- value changing at a run (registers and stack are veiled then), a
- stack window going farther than its height; the heap's drawing: a
- node's value turning at the middle of its travel. The heap's pins
- crossfade now; its dump comes in faded at the first malloc.
+- The minimap (about half of every scene's): its strokes, blocks and gold
+ rows followed the cursor 6 f late but changed in one frame. Now it is the
+ average of six drawings from the cursor's mirrors 6 to 11 f behind
+ (`map.minimap`, `Cursor.lagInto`), so every change on it fades in over
+ 6 f; its windows' outlines glide with their scrolls (`map.window` takes
+ where the window was and how far it has gone), on whole pixels at rest;
+ the backtrace's box is packed once, by the deepest chain of the scene's
+ way, not grown under the eye.
+- rip's value swapped at the advance: it crossfades over the advance; a
+ flag set or cleared crossfades over the 6 f it lands in (`rows.RipWas`).
+- A held corner dropped when a run rewrote its value, a sprint's ember
+ coming at once, the last ember's fade cut off by a short step: the
+ corner goes with the run's ease, the ember comes in over the step, the
+ fade fits its step (`Now.heat`, `left`).
+- The backtrace: in the calls lens's view the chain swapped in a frame;
+ everywhere a kept row's depth, pc offset or line, and the tag's count,
+ changed in place. One block now (`backtraceRows`): leave, slide, arrive,
+ and what a row says crossfading over the 12 f before the advance
+ (`Now.renaming`: from the step's start where that is sooner, a run's).
+- The calls tree: a node gold, ringed or done switched with the tree's
+ moment; at a sprint a node came at once. Crossfaded (6 f), and over its
+ step at a sprint (`Now.moving` at a sprint).
+- A tag's note changed in place: the disassembly's function, a descent's
+ tag, the stack's range: crossfaded with the advance or memory's strike.
+- A stack word's role (`saved rbp`, a local's name) and its offset from
+ rsp changed in place: crossfaded from memory's strike (12 f,
+ `rows.Role`); a saved rbp's arc vanished at the next step: it goes with
+ its own step's advance.
+- A pin's names swapped as a register joined or left (the `+1`, a name
+ taking the other's side): the names fade through the middle of the
+ change (`Pins.text`); at a run a pin changes over 8 f (`ties.pinShows`).
+- At a run a register's or a stack word's value changed in a frame: they
+ crossfade (8 f), as a dump's did.
+- A dump row whose bytes changed with no write the recording saw (memory
+ nothing watches, read anew at a stop) or that became known: crossfaded
+ (12 f, `rowPasses`).
+- The source's trail bars moved in a frame: crossfaded with the advance.
+- The heap's own drawing: a node's look as it changed lists, its value
+ and its link: crossfaded (it lands, then turns, 12 f).
+- An arc's lane: it glides while the arc that moves it draws or fades.
+
+Right in one frame, and exempted by name: the encoder's keyframes and the
+gallery's cuts (above).
+
+What fires still, by kind (looked at on the exports):
+
+- The minimap: a repack of the map (a panel that wants more rows than so
+ far, a frame behind: the disassembly's box, a loupe opening that moves
+ the key) lands in one frame for all six drawings; heap 9, syscalls'
+ descent the most. Packing every box once from the whole scene would end
+ them.
+- The stack (fib 7): at fib 6.50 two roles (`saved rbp`, `saved rbx`)
+ and the saved rbp's arc go together in one frame, which the roles'
+ crossfade and the arc's fade with its advance should have caught (not
+ found); the rest are a few pixels in the arcs' lanes and the spans'
+ names (8.20, 19.50, 21.70, 24.90, 35.93, 39.13).
+- Registers: a held corner (fib 21.10; sort 14.88, 32.62), a few pixels
+ at a value's top left.
+- The drawing: the calls tree's badge corner (fib 33.63), sort's index
+ pins sliding (21.98, 30.43), the heap's `+1` and a pin's name over a
+ travelling tag.
+- The view: sqlite's row (21.12, 23.75): bytes the dump's marks do not
+ strike (its marks begin at the stop it came in at) changing at a
+ continue; heap 13.48 and 36.68, the tcache's row as malloc rewrites it.
+- The source: sort 24.18 and 24.52, its line numbers' column as the
+ window goes farther than its height (out and in through the advance);
+ syscalls 13.42 and 61.02, the line going `waiting` and back; not looked
+ at further.
+- fib's caption: a 1-pixel column at the panels' left edge (x 66 and
+ 978) flickers in the caption band as the hurry begins (7.45 s; also in
+ the last pass's export, smaller): the instrument takes it for a sixth
+ caption, so fib's captions are not paired and 7.50 is "the picture
+ moving". Not found.
- CROWD: the advance (thread, plaques and rip as one mark, the source and
- the disassembly scrolling with it), the veil coming over three panels
- at a run's first step, x264's keyframes; list 0.02 and 2.52, the map
- coming in and the dive's first frame.
-- METRONOME: syscalls 36.77 to 39.17 is the run through libc's `open`
- to its last three instructions, 0.30 s a step by design (a run).
-- CAPTION over 720 f: heap 9.83, malloc's caption over its five walked
- steps (12.9 s); list 21.75 and 46.58 and zoom 8.38, the captions of
- their walked trips. Picture moving within 60 f: the step firing 60 f
- after the caption by the narrator's lead, which the check counts from
- the frame after (heap 9.83), x264's keyframe (syscalls 9.95), and
- list 3.63, the falling map crossing the caption band in the dive (it
- also makes list's arrivals 7 to the scene's 6).
+ the disassembly scrolling with it), the veil coming over three panels at
+ a run's first step; heap's runs (the calls and returns it does not
+ narrate) are its 15. METRONOME is gone from syscalls: the run through
+ libc's `open` crossfades its values now.
- AIR: syscalls 13.72 and 20.10, the stage still under the two captions
- that recount the descend and lead the stub's `jmp` (the review's
- split); sqlite's four dense captions and its last; zoom's last.
+ that recount the descend and lead the stub's `jmp`; sqlite's four dense
+ captions and its last; zoom's last; list 21.87 and 30.32, the loop's
+ caption read over its one step and the loupes held under theirs (list is
+ 84.5 s now: four captions more, so that none is up over 12 s).
## What is not done
@@ -226,8 +295,9 @@ What fires, and why it is left, by kind (examined this pass):
`syscall` to the stop after it, so the rows under the call move up again
a step later. The fold past three windows (`2 calls: fib fib`), a lazy
PLT's resolver row and the vDSO's window are written but no recording
- shows them; the descent on the map is the same component at 69 rows, not
- checked. At a run the windows do not open and close in 8 f with no lane
+ shows them; on the map the descent's box is as long as the rows it has
+ wanted, so opening a callee's window there repacks the map (the most of
+ syscalls' remaining minimap POPs). At a run the windows do not open and close in 8 f with no lane
(the syscalls scene walks every step of the descent).
- `open("note", O_RDONLY) = 3` does not fit 880 from 564 (27
characters): the arguments go from the right, `open("note", …) = 3`.
@@ -236,29 +306,40 @@ What fires, and why it is left, by kind (examined this pass):
function with no system call of its name has its arguments in hex.
- The heap scene's drawing and view are the scene's own components
(`Lists`, `Chunks` in `scenes/heap.zig`), not blocks of `src/`: no
- second scene needs them. It is 96 s, not the storyboard's 79.4: its
- steps are the engine's cascades (a call 3.1 s, a prologue 2.9 s), longer
- than the storyboard's budget; its captions keep their order and leads.
- `free` is stepped over as one step from its line (a continue's wave),
- not as a cascade onto its call row and then the call (mock 18's
- `free in libc, stepped over`). A `size` bit that changes is not struck
- on its chip. The heap's map shows no arena panel and no drawing (the
- scene adds its lens to the working frame only).
-- The map is packed by content, but a column's rest after the
- disassembly is page: the 5-row dumps round what the registers' and the
- stack's pointers point at, loupes as panels on the map (and lifted
- blocks on the minimap) and the map's key are not built; `continued` is
- built for the stack alone. The boxes are as long as the most rows each
- panel has wanted so far (`map.measure`, process-wide, a frame behind):
- a scene's first frame packs by the defaults. The sqlite scene's lenses
- (the backtrace, the calls so far), the heap's and the zoom scene's have
- no drawing on their map.
-- The minimap follows the frame 6 f behind, but its changes are not
- faded: a row's stroke or a mark's block changes in one frame (most of
- the instrument's POPs). A struck word outside every window flashes on
- it only for the stack. Its windows are outlined a frame behind the
- panels that publish them after the clock (the lens's view). The scene's
- focus is not set on it.
+ second scene needs them. It is 78 s against the storyboard's 79.4: the
+ seconds over it went to steps the storyboard does not narrate, walked as
+ cascades (the calls into push and pop, 3.1 s, and their prologues, 2.9 s,
+ four times; the returns to main); those now run, and the return under
+ the second free's caption is walked again (its reading time is longer
+ than its steps, and the picture would stand still 3.5 s). Each `free`
+ is now mock 18's: its line's instructions a cascade onto its call row
+ (the recording stops there: `break_call` in build.zig, a breakpoint at
+ pop's `call free@plt` found by objdump, which `--by line` now honours),
+ then the call stepped over from that row (a continue's wave, the line
+ not fired again). A `size` bit that changes is not struck on its chip.
+ The heap's map has its drawing and view but no arena panel.
+- The map: `continued` is built for the stack and the source (which
+ goes on under the disassembly when its column cannot hold its 69 lines;
+ in no scene now, since the disassembly fills its column wherever the
+ source is that long). The stack continued shows the words past what the
+ recording holds as unknown rows (`··`), not folded into one `more` row
+ after the process's start. A dump round a pointer is the bytes, typed
+ by the objects the recording knows, its target not framed. Loupes are
+ map panels only where the scene names them (`Map.loupes`: list, heap),
+ and on the minimap they are strokes, not lifted blocks. The disassembly's
+ and the view's boxes are still as long as the most rows wanted so far
+ (`map.measure`, a frame behind; the backtrace's is now packed once, by
+ the scene's deepest chain, so its box can be taller than the frames of
+ the moment). The sqlite map draws the backtrace lens, not the calls so
+ far it changes to, and no view.
+- The minimap is the average of six drawings a frame apart (6 to 11 f
+ behind): every change on it fades over 6 f, at the cost of drawing the
+ map six times a frame while anything moves (once at rest). Its images
+ are a process-wide cache of the host's. A repack of the map (a panel
+ that wants more rows, a frame behind) is averaged like any change but
+ still lands in one frame for all six drawings: the remaining minimap
+ POPs are those and the windows of panels that publish them after the
+ clock. The scene's focus is not set on it.
- `dive`: every panel travels 60 f (the catalogue's 72 f is the map's
fall), so that seven of them 6 f apart land by 120 f; the drawing does
not crossfade between sizes (the list's are the same, subject on both).
@@ -268,11 +349,9 @@ What fires, and why it is left, by kind (examined this pass):
past the current marks or a changed row; on the 1920 stage a deeper one
hangs under the first, not 120 to its right. The catalogue's stem is 3
in its strokes and 4 in the loupe's anatomy: it is 4 here.
-- An `arc`'s lane change does not glide (12 f): a lane is given each
- frame from the arcs then present.
-- At a run only a dump's values crossfade (8 f); a register's, a slot's
- and a node's change in a frame (the registers and the stack are veiled
- at a run).
+- At a run a dump's values, a register's and a stack word's crossfade
+ (8 f); a node's value in `nodes` and a cell's in `array` still change
+ in a frame (the heap's drawing crossfades its own).
- The gallery keeps the old recording of the list
(`test/gallery/list.ztrace`): on the build's list (by instruction) its
loupe page has no second loupe, the nodes being 32 bytes apart and a
@@ -317,10 +396,14 @@ What fires, and why it is left, by kind (examined this pass):
- The map's and minimap's drawing flags (`ui.mapping`, `ui.strokes`,
`ui.chrome`), a dive's per-panel transforms (`context.zoomed`), the
map's measured rows (`map.held`), the ties' table and the thread's
- waiting are process-wide globals, set and read in one frame's drawing
- (the measured rows a frame behind); two players at once would want them
- on the frame. Not moved this pass: each is read by components that the
- frame reaches only through `anim.Placed`, which carries no frame state.
+ waiting are still process-wide globals, set and read in one frame's
+ drawing (the measured rows a frame behind); two players at once would
+ want them on the frame. Only the minimap's lag is passed down now: its
+ drawings get the frame's values with the cursor's replaced by a lagging
+ mirror's (`Cursor.lagInto`), and `Cursor.now` no longer reads
+ `ui.strokes`. The rest is read by components the frame reaches only
+ through `anim.Placed`, which carries no frame state; moving them means a
+ `Ui` that carries them from every component's first `context.at`.
- A recording holds the bytes it has seen, each as last seen: it cannot
tell a byte read again and unchanged from one not read since. Memory
nothing watches (SQLite's page cache) is read at a stop only where a
diff --git a/anim/build.zig b/anim/build.zig
index d12912d..5601e39 100644
--- a/anim/build.zig
+++ b/anim/build.zig
@@ -87,6 +87,10 @@ pub fn build(b: *std.Build) void {
/// Also glibc's heap at every stop (`--heap`), and memory watched (`-w`).
heap: bool = false,
watch: []const []const u8 = &.{},
+ /// Also a stop at the call, in function [0], of function [1] through
+ /// its PLT stub (found by objdump: there is no name for it): the row
+ /// a line's cascade lands on before the call is stepped over.
+ break_call: ?[2][]const u8 = null,
};
for ([_]Recording{
.{ .name = "steps", .source = "fib.c", .by = "insn" },
@@ -94,7 +98,7 @@ pub fn build(b: *std.Build) void {
// the kernel and back: the descent; to main's return.
.{ .name = "hello", .source = "hello.c", .by = "insn", .from = "main", .steps = "132", .glibc = true, .reads = "note" },
// A line a stop, malloc and free run through; glibc's heap at each.
- .{ .name = "heap", .source = "heap.c", .by = "line", .from = "main", .glibc = true, .heap = true, .watch = &.{ "0x405000,1024", "head" } },
+ .{ .name = "heap", .source = "heap.c", .by = "line", .from = "main", .glibc = true, .heap = true, .watch = &.{ "0x405000,1024", "head" }, .break_call = .{ "pop", "free" } },
// By instruction, as `steps` is: the registers are the program's
// own, so they strike and link. Only the variables the scenes name
// are told by the instrumentation (each a call into its runtime,
@@ -135,13 +139,24 @@ pub fn build(b: *std.Build) void {
const where = b.addWriteFiles();
_ = where.addCopyFile(program, r.name);
if (r.reads) |name| _ = where.addCopyFile(b.path(b.fmt("tools/{s}", .{name})), name);
- const run = b.addSystemCommand(&.{ "env", "-i", "setarch", "-R" });
+ const run = if (r.break_call) |call| blk: {
+ // The call's address, from the program as built, then the recorder with a breakpoint there.
+ const sh = b.addSystemCommand(&.{ "sh", "-c", b.fmt(
+ \\p=$0 z=$1; shift
+ \\at=$(objdump -d --no-show-raw-insn "$p" | awk '/<{s}>:/ {{ f = 1 }} f && /call.*<{s}@plt>/ {{ sub(":", "", $1); print "0x" $1; exit }}')
+ \\[ -n "$at" ] || {{ echo "no call of {s} in {s}" >&2; exit 1; }}
+ \\exec env -i setarch -R "$z" record -b "*$at" "$@"
+ , .{ call[0], call[1], call[1], call[0] }) });
+ sh.addFileArg(program);
+ break :blk sh;
+ } else b.addSystemCommand(&.{ "env", "-i", "setarch", "-R" });
run.addArtifactArg(ztrace);
// More round each stop than the working frame shows: the map of
// the whole context wants the words of the stack, 256 bytes round
// what a pointer leads to and what a step touches, and 69
// instructions round the pc.
- run.addArgs(&.{ "record", "--by", r.by, "--stack", r.stack, "--around", "256", "--disasm", "69", "-s", "64" });
+ if (r.break_call == null) run.addArg("record");
+ run.addArgs(&.{ "--by", r.by, "--stack", r.stack, "--around", "256", "--disasm", "69", "-s", "64" });
if (r.from) |place| run.addArgs(&.{ "--from", place });
if (r.steps) |n| run.addArgs(&.{ "--steps", n });
if (r.heap) run.addArg("--heap");
diff --git a/anim/scenes/gallery.zig b/anim/scenes/gallery.zig
index 9852125..bd363d5 100644
--- a/anim/scenes/gallery.zig
+++ b/anim/scenes/gallery.zig
@@ -230,7 +230,7 @@ fn rowsPage(u: ui.Ui, p: *const Pages) void {
_ = rows.reg(panel, row, 880, "rdi", m, regs.rdi, .{ .first = .struck });
_ = rows.reg(panel, 2 * row, 880, "rax", m, regs.rax, .{ .first = .ember });
_ = rows.reg(panel, 3 * row, 880, "rbp", m, regs.rbp, .{ .read = 1, .read_shows = 1 });
- rows.rip(panel, 4 * row, 880, m, regs.rip, regs.eflags, 1 << 6, 1, 0, 1 << 6, 1);
+ rows.rip(panel, 4 * row, 880, m, regs.rip, regs.eflags, 1 << 6, 1, 0, 1 << 6, 1, null);
y = 380;
title(u, 64, y, "slot");
@@ -239,7 +239,7 @@ fn rowsPage(u: ui.Ui, p: *const Pages) void {
panel = u.moved(64, y);
for (0..4) |i| {
const addr = regs.rsp + 8 * i;
- _ = rows.slot(panel, @as(f32, @floatFromInt(i)) * row, 880, m, addr, @intCast(8 * i), if (i == 0) &.{ "rsp", "rbp" } else &.{}, 1, .{ .lead = ui.shared(&.{ regs.rsp, regs.rsp + 24 }), .first = if (i == 2) .ember else .none }, if (i == 0) "saved rbp" else if (i == 1) "cur" else "", i == 1);
+ _ = rows.slot(panel, @as(f32, @floatFromInt(i)) * row, 880, m, addr, @intCast(8 * i), if (i == 0) &.{ "rsp", "rbp" } else &.{}, 1, .{ .lead = ui.shared(&.{ regs.rsp, regs.rsp + 24 }), .first = if (i == 2) .ember else .none }, if (i == 0) "saved rbp" else if (i == 1) "cur" else "", i == 1, null);
}
rows.span(panel, 880, 0, 2 * row, "reverse", true, false);
rows.span(panel, 880, 2 * row, 4 * row, "main", false, true);
diff --git a/anim/scenes/heap.zig b/anim/scenes/heap.zig
index e7f70f7..544ae91 100644
--- a/anim/scenes/heap.zig
+++ b/anim/scenes/heap.zig
@@ -133,8 +133,7 @@ const Lists = struct {
pub fn draw(l: *const Lists, f: *sk.Frame, placed: anim.Placed) void {
const box = l.stage.box(placed, .band);
if (box.h < cm.tag + 24) return;
- const u = canim.ui.Ui{ .f = f, .at = placed };
- const v = u.moved(box.x, box.y).faded(placed.value(l.stage.drawing));
+ const v = canim.panelAt(f, placed, box).faded(placed.value(l.stage.drawing));
v.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
defer v.unclip();
const now = l.cursor.now(placed);
@@ -220,41 +219,62 @@ const Lists = struct {
const xy = canim.ui.Vec{ std.math.lerp(at(s0)[0], at(s1)[0], p), std.math.lerp(at(s0)[1], at(s1)[1], p) };
const shows: f32 = if (from == null) after(now, 0, 12) else if (to == null) 1 - after(now, 0, 12) else 1;
const nv = v.faded(shows);
- const freed = (if (p >= 0.5) s1 else s0).row == 1;
const r: canim.Rect = .{ .x = xy[0], .y = xy[1], .w = w, .h = h };
- const m = if (p >= 0.5) now.moment() else now.before();
_ = nv.address(r.x + 16, r.y - 8, node, .{ .ink = ui.rgb(theme.color.region.heap) });
- if (freed) {
- // Freed: dashed, its first word the link (where the value was), the second hatched, `key`.
- nv.dashedFrame(r, theme.color.region.heap, theme.stroke.rule);
- nv.fill(.{ .x = r.x + 2, .y = r.y + 2, .w = w / 2 - 2, .h = h - 4 }, theme.color.well);
- for (0..4) |k| {
- const x0 = r.x + w / 2 + 8 + @as(f32, @floatFromInt(k)) * 14;
- nv.line(.{ x0, r.y + h - 4 }, .{ x0 + 12, r.y + 4 }, theme.color.rule, theme.stroke.rule);
+ // Nothing turns in a frame: a node that changes lists turns as it lands (its last 12 f),
+ // and its value and link, where they change and are not struck, crossfade with the idea (12 f).
+ const lands = after(now, 36, 12);
+ const turns = after(now, 0, 12);
+ for ([2]Spot{ s0, s1 }, 0..) |spot, side| {
+ const freed = spot.row == 1;
+ const other_freed = (if (side == 0) s1 else s0).row == 1;
+ const look = if (freed == other_freed) @as(f32, if (side == 1) 1 else 0) else if (side == 1) lands else 1 - lands;
+ if (look <= 0) continue;
+ const lv = nv.faded(look);
+ if (freed) {
+ // Freed: dashed, its first word the link (where the value was), the second hatched, `key`.
+ lv.dashedFrame(r, theme.color.region.heap, theme.stroke.rule);
+ lv.fill(.{ .x = r.x + 2, .y = r.y + 2, .w = w / 2 - 2, .h = h - 4 }, theme.color.well);
+ for (0..4) |k| {
+ const x0 = r.x + w / 2 + 8 + @as(f32, @floatFromInt(k)) * 14;
+ lv.line(.{ x0, r.y + h - 4 }, .{ x0 + 12, r.y + 4 }, theme.color.rule, theme.stroke.rule);
+ }
+ lv.text(.mono, theme.size.mono.context, r.x + w - 40, r.y + 16, "key", t.faint);
+ } else {
+ lv.fill(.{ .x = r.x, .y = r.y, .w = w - well, .h = h }, theme.color.raised);
+ lv.fill(.{ .x = r.x + w - well, .y = r.y, .w = well, .h = h }, theme.color.well);
+ // A node changing hands is not struck: its words are the other list's now (the dump strikes them).
+ const heat = if (s0.row == s1.row) now.written(node, 8, .idea, 0) else canim.ui.Heat.none;
+ const cell: canim.Rect = .{ .x = r.x, .y = r.y, .w = w - well, .h = h };
+ const ink = lv.cellWritten(cell, heat, theme.color.raised);
+ // Struck, the digits change under the strike's fill; else they crossfade.
+ const values = [2]u64{ (canim.Recording.word(now.before(), node, 8) catch null) orelse 0, (canim.Recording.word(now.moment(), node, 8) catch null) orelse 0 };
+ const struck = heat.level >= 1;
+ const turned = if (struck) @as(f32, if (now.since(.idea, 0) >= theme.time.strike.in / 2.0) 1 else 0) else turns;
+ for (values, [2]f32{ if (values[0] != values[1]) 1 - turned else 0, if (values[0] != values[1]) turned else 1 }) |value, k| {
+ if (k <= 0) continue;
+ // Taken back before the program writes it: the old link, faint, as stored.
+ const stale = value != 0 and value >> 12 == node >> 12;
+ if (stale) lv.faded(k).label(.mono, theme.size.mono.context, cell, .center, lv.print("{x}", .{value}), t.faint) else lv.faded(k).label(ink.face, theme.size.mono.small, cell, .center, lv.print("{d}", .{@as(i64, @bitCast(value))}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
+ }
+ }
+ // Its link: the next node in its row, as the pointer protects or holds it.
+ const sq: canim.Rect = .{ .x = if (freed) r.x + 18 else r.x + w - well / 2 - 5, .y = r.y + h / 2 - 5, .w = 10, .h = 10 };
+ var links: [2]u64 = undefined;
+ for (&links, [2]canim.Recording.Moment{ now.before(), now.moment() }) |*link, lm| {
+ const word = (canim.Recording.word(lm, node + if (freed) @as(u64, 0) else 8, 8) catch null) orelse 0;
+ link.* = if (freed) word ^ (node >> 12) else word;
+ }
+ for (links, [2]f32{ if ((links[0] == 0) != (links[1] == 0)) 1 - turns else 0, if ((links[0] == 0) != (links[1] == 0)) turns else 1 }) |next, k| {
+ if (k <= 0) continue;
+ if (next == 0) {
+ lv.faded(k).line(.{ sq.x - 6, sq.y + 16 }, .{ sq.x + 16, sq.y - 6 }, t.dim, theme.stroke.rule);
+ } else if (spotOf(program[shown], free[shown], next)) |ns| {
+ lv.faded(k).fill(sq, theme.color.region.heap);
+ const nx = at(ns);
+ if (@abs(nx[1] - r.y) < 1 and nx[0] > r.x) lv.faded(k).route(&.{ .{ sq.x + 10, r.y + h / 2 }, .{ nx[0] - 2, r.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
+ }
}
- nv.text(.mono, theme.size.mono.context, r.x + w - 40, r.y + 16, "key", t.faint);
- } else {
- nv.fill(.{ .x = r.x, .y = r.y, .w = w - well, .h = h }, theme.color.raised);
- nv.fill(.{ .x = r.x + w - well, .y = r.y, .w = well, .h = h }, theme.color.well);
- const value = (canim.Recording.word(m, node, 8) catch null) orelse 0;
- // A node changing hands is not struck: its words are the other list's now (the dump strikes them).
- const heat = if (s0.row == s1.row) now.written(node, 8, .idea, 0) else canim.ui.Heat.none;
- const cell: canim.Rect = .{ .x = r.x, .y = r.y, .w = w - well, .h = h };
- const ink = nv.cellWritten(cell, heat, theme.color.raised);
- // Taken back before the program writes it: the old link, faint, as stored.
- const stale = value != 0 and value >> 12 == node >> 12;
- if (stale) nv.label(.mono, theme.size.mono.context, cell, .center, nv.print("{x}", .{value}), t.faint) else nv.label(ink.face, theme.size.mono.small, cell, .center, nv.print("{d}", .{@as(i64, @bitCast(value))}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
- }
- // Its link: the next node in its row, as the pointer protects or holds it.
- const sq: canim.Rect = .{ .x = if (freed) r.x + 18 else r.x + w - well / 2 - 5, .y = r.y + h / 2 - 5, .w = 10, .h = 10 };
- const word = (canim.Recording.word(m, node + if (freed) @as(u64, 0) else 8, 8) catch null) orelse 0;
- const next = if (freed) word ^ (node >> 12) else word;
- if (next == 0) {
- nv.line(.{ sq.x - 6, sq.y + 16 }, .{ sq.x + 16, sq.y - 6 }, t.dim, theme.stroke.rule);
- } else if (spotOf(program[shown], free[shown], next)) |ns| {
- nv.fill(sq, theme.color.region.heap);
- const nx = at(ns);
- if (@abs(nx[1] - r.y) < 1 and nx[0] > r.x) nv.route(&.{ .{ sq.x + 10, r.y + h / 2 }, .{ nx[0] - 2, r.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
}
// Who points here: `head`, the local `n`, and the registers.
var names: [2][4][]const u8 = undefined;
@@ -317,6 +337,8 @@ const Chunks = struct {
stage: *const canim.Stage,
pub fn draw(c: *const Chunks, f: *sk.Frame, placed: anim.Placed) void {
+ // On the map its box is as long as its rows.
+ canim.map.measure(.view, (view_len + 15) / 16);
const v = canim.hexdump.panel(f, placed, c.stage, "the heap, 405000 to 40506f", &.{});
defer v.u.unclip();
if (v.rows == 0) return;
@@ -367,9 +389,14 @@ fn lineIn(rec: *canim.Recording, function: []const u8, n: usize, line: u32) u64
/// the idea; it closes with the advance. Never open over a step it does not concern.
fn tcacheStep(at: canim.Cursor, s: *anim.Frame, tcache: *const canim.Loupe, wave: bool) void {
const tm = theme.time;
+ // A free: its line's instructions first, a cascade onto the call row (the recording stops there,
+ // `break_call`); then the call, stepped over, goes on from that row without firing the line again.
+ const onto = wave and at.rec.own[at.moment(s) + 1] == at.rec.own[at.moment(s)];
+ if (onto) at.walk(s, .moment, at.moment(s) + 1);
const from = at.moment(s);
const to = at.rec.next(.line, from);
var plan = at.planned(from, to, wave);
+ plan.fires = !onto;
const opens = plan.at[1] + 3 * 6.0 / 60.0 + 12.0 / 60.0;
const idea = opens + tm.loupe.open + 24.0 / 60.0;
const later = @max(idea - plan.at[2], 0);
@@ -399,6 +426,9 @@ fn frame(s: *anim.Frame) void {
const head_at = globalOf(rec, lineIn(rec, "push", 0, 13));
const lists = canim.add(s, Lists{ .cursor = at, .stage = ctx.stage, .head_at = head_at });
const chunks = canim.add(s, Chunks{ .cursor = at, .stage = ctx.stage });
+ // On the map too: the drawing over the source, the heap's bytes over the registers.
+ ctx.map.add(s, Lists{ .cursor = at, .stage = ctx.map.stage, .head_at = head_at });
+ ctx.map.add(s, Chunks{ .cursor = at, .stage = ctx.map.stage });
// The tcache, once there is one: a loupe from the row of the chunk it lives in, over the stack.
const tc = tcacheOf(rec);
const tcache = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .row = .{
@@ -411,6 +441,7 @@ fn frame(s: *anim.Frame) void {
.{ .at = 0x98, .len = 8, .reads = .pointer, .note = "the head of 0x20" },
} },
} } });
+ ctx.map.loupes = .{ tcache, null };
var says: canim.Narrator = .{};
const joins = ctx.ties(s);
canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, chunks, lists, joins });
@@ -418,25 +449,30 @@ fn frame(s: *anim.Frame) void {
// design/motion.md, "A scene: libc's heap from the inside": each caption
// leads the steps it is about, and changes only in a rest.
says.line(s, "Three pushes and two pops: what malloc and free\ndo to the heap.");
- at.walk(s, .line, lineIn(rec, "push", 0, 11));
+ at.hurry(s, .line, lineIn(rec, "push", 0, 11), .{});
says.line(s, "malloc(16) cut a chunk of 0x20 off the top: its size word,\n0x21, then the 16 bytes rax points at. The top is 0x20 smaller.");
- at.walk(s, .line, rec.lineMoment(25, main.enter));
+ at.walk(s, .line, lineIn(rec, "push", 0, 15));
+ // The return to main runs with the two pushes after it.
says.line(s, "Two more pushes, at a run: three chunks in a row, each\nwith P set, the chunk before it in use.");
at.hurry(s, .line, rec.lineMoment(27, main.enter), .{});
says.line(s, "pop takes the head off the list: head = n->next.");
+ at.hurry(s, .line, lineIn(rec, "pop", 0, 19), .{});
at.walk(s, .line, lineIn(rec, "pop", 0, 20));
says.line(s, "free gave 9's chunk to the tcache, malloc's bin for 0x20.\nIts first word is the link now: 405, which is NULL, safe-linked.");
tcacheStep(at, s, tcache, true);
- at.walk(s, .line, rec.lineMoment(28, main.enter));
+ at.hurry(s, .line, rec.lineMoment(28, main.enter), .{});
says.line(s, "The second pop: head moves on, to 7's node.");
+ at.hurry(s, .line, lineIn(rec, "pop", 1, 19), .{});
at.walk(s, .line, lineIn(rec, "pop", 1, 20));
says.line(s, "The second free chains to the first: 405455 is 405050 xor 405,\nthe chunk's own address shifted 12. The arc is the pointer it hides.");
tcacheStep(at, s, tcache, true);
+ // Walked, the return: this caption's reading time is longer than its steps, and the picture would stand still.
at.walk(s, .line, rec.lineMoment(29, main.enter));
says.line(s, "malloc(16) took the bin's head, 405030: the tcache points\nat 405050 again, the key is wiped, the old link stays.");
- at.walk(s, .line, lineIn(rec, "push", 3, 11));
+ at.hurry(s, .line, lineIn(rec, "push", 3, 11), .{});
tcacheStep(at, s, tcache, false);
says.line(s, "push writes 25 over the old link: the list is 25, then 7.");
- at.walk(s, .line, rec.lineMoment(30, main.enter));
+ at.walk(s, .line, lineIn(rec, "push", 3, 15));
+ at.hurry(s, .line, rec.lineMoment(30, main.enter), .{});
says.close(s);
}
diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig
index b7e6c4a..39d413b 100644
--- a/anim/scenes/list.zig
+++ b/anim/scenes/list.zig
@@ -42,6 +42,8 @@ fn frame(s: *anim.Frame) void {
const loaded = rec.lineMoment(22, rec.lineMoment(21, reverse.enter));
const near = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .register = "rax" } });
const deeper = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .field = .{ .loupe = near, .at = rec.register(loaded, "rax") + 8 } } });
+ // Open, they are panels of their own on the map too.
+ ctx.map.loupes = .{ near, deeper };
const joins = ctx.ties(s);
// It opens on the map, the whole context unfolded: the first caption at
// 1 s, the dive into the working frame at 2.5 s, the first step at 5 s.
@@ -50,8 +52,10 @@ fn frame(s: *anim.Frame) void {
says.line(s, "A list is nodes on the heap, each holding the address of the next.\nReversing it moves no node: it rewrites every `next`.");
s.cursor = 2.5;
ctx.map.dive(s);
- // Three names are set up.
+ // Three names are set up, under a caption of their own (the first is up 12 s at most).
const first_trip = rec.lineMoment(21, reverse.enter);
+ at.walk(s, .line, rec.lineMoment(19, reverse.enter));
+ says.line(s, "`cur` takes the head, and the loop begins\nat the first node.");
at.walk(s, .line, first_trip);
// The loop's caption leads the loop.
says.line(s, "`next` remembers the way on, `cur->next` is turned round,\nand `prev` and `cur` each step along.");
@@ -67,13 +71,19 @@ fn frame(s: *anim.Frame) void {
near.close(s);
s.wait(t.beat);
const second_trip = rec.lineMoment(21, rec.lineMoment(24, first_trip));
+ // The rest of the trip under captions of its own: a caption is up 12 s at most.
+ says.line(s, "`cur->next` takes `prev`, NULL:\nthe first node is now the end of the list.");
+ at.walk(s, .line, rec.lineMoment(23, loaded));
+ says.line(s, "Then `prev` and `cur` each step one node along,\nand the loop comes round to the second node.");
at.walk(s, .line, second_trip);
// Pacing: the second trip is the same, so hurried; it keeps its rest.
says.line(s, "The second node, the same way, faster:\nits `next` turns back to the first.");
const third_trip = rec.lineMoment(21, rec.lineMoment(24, second_trip));
at.hurry(s, .line, third_trip, .{});
// The third in full again: the last `next` turns, and `cur` runs off the end.
- says.line(s, "The last node: its `next` turns too,\nand `cur` runs off the end of the list.");
+ says.line(s, "The last node: its `next` turns too,\nback to the node before it.");
+ at.walk(s, .line, rec.lineMoment(23, third_trip));
+ says.line(s, "`prev` takes the last node, and `cur` runs off the end\nof the list: NULL, so the loop ends.");
at.walk(s, .line, rec.lineMoment(26, third_trip));
says.line(s, "`head` takes the last node: the same three nodes,\nin the same places, read the other way.");
at.walk(s, .line, end);
diff --git a/anim/scenes/sqlite.zig b/anim/scenes/sqlite.zig
index e7d103e..db0e6d9 100644
--- a/anim/scenes/sqlite.zig
+++ b/anim/scenes/sqlite.zig
@@ -108,6 +108,8 @@ fn frame(s: *anim.Frame) void {
// state column the bytes the newest call is handed.
const ctx = canim.context(s, at, .{ .split = canim.layout.split.subject, .syscalls = true, .backtrace = true });
const kernel = canim.crossing(s, .{ .cursor = at, .stage = ctx.stage, .view = false });
+ // The map's drawing: how the program came to be here, the backtrace lens.
+ ctx.map.add(s, canim.Backtrace{ .cursor = at, .stage = ctx.map.stage, .lens = true });
// What the opening stop's rbx points at: the SQL sqlite3_exec is running.
const sql = canim.add(s, canim.hexdump.Dump{
.cursor = at,
diff --git a/anim/scenes/zoom.zig b/anim/scenes/zoom.zig
index ee24e7d..1f23c05 100644
--- a/anim/scenes/zoom.zig
+++ b/anim/scenes/zoom.zig
@@ -27,6 +27,8 @@ fn frame(s: *anim.Frame) void {
at.levels = .{ .fire = .disasm, .source_rows = 14 };
const split = canim.layout.split.none;
const ctx = canim.context(s, at, .{ .split = split });
+ // The map's drawing: the calls of fib so far, as the fib scene draws them.
+ ctx.map.drawing(s, rec, canim.CallTree{ .cursor = at, .stage = ctx.map.stage, .function = "fib" });
var cam: canim.Camera = .{};
var says: canim.Narrator = .{};
@@ -36,11 +38,14 @@ fn frame(s: *anim.Frame) void {
// The CPU's level: an instruction a step. The argument is worked out in `rdi`.
at.walk(s, .moment, call.enter - 1);
- says.line(s, "`call` writes eight bytes on the stack: the way back.\nThe new frame saves `rbp` under them, then its own `n`.");
+ says.line(s, "`call` writes eight bytes on the stack: the way back.");
// Nearer, for the bytes: the stack alone, twice the size.
cam.go(s, split.stack, 2, .{ ctx.source, ctx.disasm, ctx.registers, ctx.backtrace });
// Under the camera the stack holds still: six free words above rsp for the new frame.
ctx.stage.holdStack(s, at.moment(s), 6);
+ at.walk(s, .moment, call.enter);
+ // The frame built under them, under a caption of its own (12 s at most).
+ says.line(s, "The new frame saves `rbp` under them,\nthen stores its own `n`.");
at.walk(s, .moment, call.enter + 4);
s.wait(canim.theme.time.beat);
ctx.stage.releaseStack(s);
diff --git a/anim/src/array.zig b/anim/src/array.zig
index 8bb0a52..8d53fb8 100644
--- a/anim/src/array.zig
+++ b/anim/src/array.zig
@@ -81,7 +81,7 @@ pub const Array = struct {
const dump = hexdump.panel(f, at, g.stage, u.print("{x} to {x}, an element a run", .{ v.addr, v.addr + v.size - 1 }), &.{});
const rows_n = @min(dump.rows, (v.addr + v.size - first + 15) / 16);
if (rows_n > 0) hexdump.draw(dump.u, now, 0, m.tag + m.pad, first, rows_n, .{ .array = .{ .addr = v.addr, .len = v.size, .elem = @intCast(elem), .type = elem_type }, .region = context.ink(context.regionOf(moment, v.addr)) });
- if (rows_n > 0) @import("map.zig").window(.view, first, first + 16 * (rows_n - 1));
+ if (rows_n > 0) @import("map.zig").window(.view, .{ first, first + 16 * (rows_n - 1) }, .{ first, first + 16 * (rows_n - 1) }, 1);
dump.veil(now);
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
}
@@ -211,6 +211,8 @@ pub const Array = struct {
ties.anchor(u, .{ .node_pin = addr }, .{ .x = cx - 1, .y = top + cell[1], .w = 2, .h = label + 10 });
const indices = names.items.len;
var shows: f32 = 1;
+ // A register joining or leaving: the names cross the middle of its change faded out (`Nodes.Pins.text`).
+ var text: f32 = 1;
for (theme.metric.all_registers[0..16]) |name| {
const i = context.index(name).?;
const before = was_regs.named(name) == addr;
@@ -218,6 +220,7 @@ pub const Array = struct {
if (!before and !after) continue;
const s = ties.pinShows(now, i, .node);
const this = if (before and after) 1 else if (after) s.new else s.old;
+ if (before != after and indices > 0) text = @min(text, @abs(2 * this - 1));
if (this < 0.5) continue;
names.append(f.scratch, name) catch {};
if (indices == 0) shows = @min(shows, this);
@@ -229,7 +232,9 @@ pub const Array = struct {
// An index lives on the stack: its name in stack's ink; a register's primary.
var inks: [8]u24 = @splat(t.primary);
for (inks[0..@min(indices, inks.len)]) |*i_ink| i_ink.* = theme.color.region.stack;
- u.faded(shows * ties.rise(rising, k, count).element).pinUnderInked(x, top + cell[1], names.items, inks[0..@min(names.items.len, inks.len)], if (names.items.len > indices) ink else t.primary, label);
+ const pv = u.faded(shows * ties.rise(rising, k, count).element);
+ pv.pinUnderInked(x, top + cell[1], &.{}, &.{}, if (names.items.len > indices) ink else t.primary, label);
+ pv.faded(text).pinNames(x, top + cell[1], names.items, inks[0..@min(names.items.len, inks.len)], label);
}
}
diff --git a/anim/src/calls.zig b/anim/src/calls.zig
index 4a669f3..9c3df04 100644
--- a/anim/src/calls.zig
+++ b/anim/src/calls.zig
@@ -92,6 +92,17 @@ pub const Tree = struct {
u.line(from, to, if (live or n.call.enter > moment) ui.rgb(t.primary) else ui.rgb(theme.color.rule), theme.stroke.line);
}
const deepest = deepestActive(nodes, moment);
+ // A node's look before the step: one that changes (the gold going on
+ // to the new call, a ring to done) crossfades as the new one comes in.
+ const deepest_was = deepestActive(nodes, now.stops[1]);
+ // From the frame the tree's moment changes (a return's, its badge's).
+ const turned = if (now.plan.gait == .sprint) appears else std.math.clamp((since - (if (returned) @as(f32, time.badge_after) else 0)) / time.snap, 0, 1);
+ const Look = enum { gold, ring, done };
+ const look = struct {
+ fn of(n: Node, i: usize, at_moment: u64, deep: ?usize) Look {
+ return if (deep == i) .gold else if (n.call.active(at_moment)) .ring else .done;
+ }
+ }.of;
for (nodes, 0..) |n, i| {
const c = at_of(left, pitch, top, n);
// Where a projection from its frame's way back (the word its
@@ -99,12 +110,11 @@ pub const Tree = struct {
// there before the node, which comes when it arrives.
if (n.call.enter <= now.stops[0]) ties.anchor(u, .{ .node_address = n.call.sp }, .{ .x = c[0] - m.radius, .y = c[1] - m.radius, .w = 2 * m.radius, .h = 2 * m.radius });
if (n.call.enter > moment) continue;
- const v = if (n.call.enter > now.stops[1]) u.faded(appears) else u;
- if (deepest == i) {
- v.disc(c, m.radius, ui.rgb(theme.mark(.current).solid), null, 0);
- } else if (n.call.active(moment)) {
- v.disc(c, m.radius - theme.stroke.line / 2, ui.rgb(theme.color.page), ui.rgb(t.primary), theme.stroke.line);
- } else v.disc(c, m.radius, ui.rgb(theme.color.raised), null, 0);
+ const is = look(n, i, moment, deepest);
+ const was = if (n.call.enter > now.stops[1]) is else look(n, i, now.stops[1], deepest_was);
+ const shows = if (n.call.enter > now.stops[1]) appears else if (was != is) turned else 1;
+ if (was != is) disc(u.faded(1 - shows), c, was);
+ disc(u.faded(shows), c, is);
}
// Then the words, so shapes and text each go in one run.
const size = theme.size.mono.small;
@@ -114,10 +124,15 @@ pub const Tree = struct {
const active = n.call.active(moment);
const words = if (n.call.arg) |arg| u.print("{d}", .{@as(i64, @bitCast(arg))}) else "?";
const cell: Rect = .{ .x = c[0] - m.radius, .y = c[1] - m.radius, .w = 2 * m.radius, .h = 2 * m.radius };
- const v = if (n.call.enter > now.stops[1]) u.faded(appears) else u;
- if (deepest == i) {
- v.label(.mono_bold, size, cell, .center, words, theme.mark(.current).on_solid);
- } else v.label(.mono, size, cell, .center, words, t.primary);
+ const is = look(n, i, moment, deepest) == .gold;
+ const was = n.call.enter <= now.stops[1] and look(n, i, now.stops[1], deepest_was) == .gold;
+ const shows = if (n.call.enter > now.stops[1]) appears else if (was != is) turned else 1;
+ for ([2]bool{ was, is }, [2]f32{ if (was != is) 1 - shows else 0, shows }) |gold, amount| {
+ if (amount <= 0) continue;
+ if (gold) {
+ u.faded(amount).label(.mono_bold, size, cell, .center, words, theme.mark(.current).on_solid);
+ } else u.faded(amount).label(.mono, size, cell, .center, words, t.primary);
+ }
if (active) continue;
// Done: what it returned, on its shoulder; struck as it lands.
const badge: Rect = .{ .x = c[0] + m.badge_at[0], .y = c[1] - m.badge_at[1], .w = m.badge, .h = m.badge };
@@ -139,26 +154,22 @@ pub const Tree = struct {
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
defer u.unclip();
const now = k.cursor.now(at);
- const rec = k.cursor.rec;
- // A frame is its words on the stack: the view changes with memory.
- const moment = now.stop(.memory);
- var buf: [24]context.Frame = undefined;
- const chain = context.frames(rec, moment, &buf);
- const room = theme.layout.rowsIn(box.h);
- const body = u.panel(box.w, box.h, "backtrace", .{ .note = u.print("the calls waiting \u{00b7} {s}", .{context.newestAtBottom(u, chain.len, room)}) });
- const open = rec.stack(f.scratch, moment);
// Newest at the bottom, as the tree grows down beside it; the oldest go from the top.
- const shown = @min(chain.len, room);
- for (chain[0..shown], 0..) |frame, i| {
- const y = body.y + cm.pad + @as(f32, @floatFromInt(shown - 1 - i)) * cm.row;
- const name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc}));
- // The call this frame is, by its place on the chain: its arguments.
- rows.callRow(u, y, box.w, i, name, context.callArguments(u, rec, open, i, frame.pc), context.frameWhere(u, rec, now.marked(), i, frame.pc), i == 0);
- }
+ context.backtraceRows(u, now, k.cursor.rec, box, false, "the calls waiting \u{00b7} ");
context.veiled(u, box, now.sprint_veil);
}
};
+/// A node of the tree as it looks: the deepest call gold, one waiting ringed, one done raised.
+fn disc(u: ui.Ui, c: ui.Vec, look: anytype) void {
+ const m = metric;
+ switch (look) {
+ .gold => u.disc(c, m.radius, ui.rgb(theme.mark(.current).solid), null, 0),
+ .ring => u.disc(c, m.radius - theme.stroke.line / 2, ui.rgb(theme.color.page), ui.rgb(t.primary), theme.stroke.line),
+ .done => u.disc(c, m.radius, ui.rgb(theme.color.raised), null, 0),
+ }
+}
+
/// A call's arguments as its backtrace row and its span say them: its
/// parameter's name and value, `n=4`; "" for one that takes nothing.
pub fn arguments(u: ui.Ui, rec: *const Recording, c: Recording.Call) []const u8 {
diff --git a/anim/src/context.zig b/anim/src/context.zig
index f551aa8..37a95a6 100644
--- a/anim/src/context.zig
+++ b/anim/src/context.zig
@@ -62,6 +62,8 @@ pub fn at(f: *sk.Frame, placed: anim.Placed, box: Rect) ui.Ui {
ui.chrome = zz.chrome;
return u;
};
+ // Looking at the map alone (`map.looking`): the working panels stand aside.
+ if (!ui.mapping and map.looking(f)) p.pose.opacity = 0;
return (ui.Ui{ .f = f, .at = p }).moved(box.x, box.y);
}
@@ -126,12 +128,10 @@ pub const Registers = struct {
/// disassembly's; it moves with them, at the advance.
fn rip(r: *const Registers, u: ui.Ui, now: cursors.Now, y: f32, w: f32, is: Shown, was: Shown) void {
const rec = r.cursor.rec;
- const moment = now.marks[if (now.advancing() >= 0.5) 1 else 0];
// The flags' corners are secondary: 6 f after the registers strike,
// not with them; in a continue's wave, in its place after r15.
const delay = if (now.plan.wave) ties.strikeDelay(now, index("eflags").?) else cursors.write_apart;
const landed = now.landed(.cpu, delay);
- const flags = (if (landed) is else was).regs.eflags;
// The flags a step changed have a turned corner, for three steps.
const eflags_index = comptime index("eflags").?;
// Until this step's change lands, the corners are the last one's: no effect before its cause.
@@ -142,7 +142,9 @@ pub const Registers = struct {
const held = if (r.quiet) 0 else heat.level * heat.corner;
// While a conditional jump runs, the flags it reads are framed (an echo of the row that set them).
const reads: u64 = if (now.resting() or now.advancing() >= 0.5) 0 else @import("disasm.zig").readsFlags(rec, now.stops[1]);
- rows.rip(u, y, w, rec.moment(moment), rec.register(moment, "rip"), flags, changed, held, 0, reads, now.reading(.cpu, 0));
+ // rip crossfades with the advance; a flag set or cleared, over the 6 f it lands in.
+ const flip = std.math.clamp(now.since(.cpu, delay) / time.strike.in, 0, 1);
+ rows.rip(u, y, w, rec.moment(now.marks[1]), rec.register(now.marks[1], "rip"), is.regs.eflags, changed, held, 0, reads, now.reading(.cpu, 0), .{ .moment = rec.moment(now.marks[0]), .pc = rec.register(now.marks[0], "rip"), .eflags = was.regs.eflags, .going = now.advancing(), .flip = if (now.resting()) 1 else flip });
}
fn row(r: *const Registers, u: ui.Ui, now: cursors.Now, line_is: Shown, line_was: Shown, name: []const u8, y: f32, w: f32) void {
@@ -205,7 +207,10 @@ pub const Registers = struct {
const since = now.since(.cpu, delay);
if (age == 0 and now.walking() and since >= 0) marks.extend = since;
}
- const hops = rows.reg(u, y, w, name, if (landed) is.moment else was.moment, if (landed) value_now else value_was, marks);
+ // At a run a value changes in place under an 8 f crossfade, unmarked, never in a frame.
+ const ran = runFade(now, .cpu);
+ if (ran < 1 and value_was != value_now) _ = rows.reg(u.faded(1 - ran), y, w, name, was.moment, value_was, marks);
+ const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, if (landed or ran < 1) is.moment else was.moment, if (landed or ran < 1) value_now else value_was, marks);
fdNote(u, hops, y, note);
anchor(u, i, hops, y);
}
@@ -220,6 +225,12 @@ pub const Registers = struct {
}
};
+/// How far (0 to 1) a run's step has crossfaded its values at `level` (8 f from it); 1 at any other pace.
+fn runFade(now: cursors.Now, level: cursors.Level) f32 {
+ if (now.plan.gait != .run or now.resting()) return 1;
+ return std.math.clamp(now.since(level, 0) / time.run_ease, 0, 1);
+}
+
/// A register's place in `Regs.names`.
pub fn index(name: []const u8) ?usize {
for (zt.Regs.names, 0..) |known, i| if (std.mem.eql(u8, known, name)) return i;
@@ -340,6 +351,8 @@ pub const Stack = struct {
// each with the memory of its own stop.
const landed = now.landed(.memory, 0);
const jumped = far(window[0], window[1], slots);
+ // On the minimap the window glides there, whether it scrolls or fades here.
+ const ways = window;
const since_memory = now.since(.memory, 0);
const jump_shows: f32 = if (!jumped or now.resting()) 1 else if (!landed) 1 - std.math.clamp((since_memory + time.quick) / time.quick, 0, 1) else std.math.clamp((since_memory - time.strike.in / 2.0) / time.quick, 0, 1);
if (jumped) window = if (landed) .{ window[0], window[0] } else .{ window[1], window[1] };
@@ -350,7 +363,6 @@ pub const Stack = struct {
const hold_scroll: f32 = if (held) @as(f32, @floatFromInt(@as(i64, @bitCast(held_at -% natural)))) / 8 * (1 - cursors.glide(placed.value(k.stage.hold_in))) else 0;
// From rsp, or the range shown when the window is elsewhere: in
// bytes from rsp, as the catalogue writes it (`rsp+20 to rsp+48`).
- const from_rsp: i64 = if (landed) @bitCast(window[0] -% is.rsp) else @bitCast(window[1] -% was.rsp);
const offset = struct {
fn of(u_: ui.Ui, d: i64) []const u8 {
return if (d == 0) "rsp" else if (d > 0) u_.print("rsp+{x}", .{@as(u64, @intCast(d))}) else u_.print("rsp-{x}", .{@as(u64, @intCast(-d))});
@@ -363,8 +375,20 @@ pub const Stack = struct {
else => u.print("{d}", .{slots}),
};
// The first word shown and the last.
- const range = if (from_rsp == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, from_rsp), offset(u, from_rsp + 8 * (@as(i64, @intCast(slots)) - 1)) });
- const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) });
+ // The range before memory lands and after: one that changes crossfades (12 f), as a role does.
+ const recast = if (now.resting()) 1 else std.math.clamp(since_memory / time.quick, 0, 1);
+ const ranges = [2]i64{ @bitCast(ways[1] -% was.rsp), @bitCast(ways[0] -% is.rsp) };
+ var notes: [2][]const u8 = undefined;
+ for (ranges, &notes) |r_, *note| {
+ const range = if (r_ == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, r_), offset(u, r_ + 8 * (@as(i64, @intCast(slots)) - 1)) });
+ note.* = u.print("{s} \u{00b7} the frames they belong to", .{range});
+ }
+ const renote = !std.mem.eql(u8, notes[0], notes[1]) and recast < 1;
+ const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = if (renote) "" else notes[1] });
+ if (renote) {
+ u.faded(1 - recast).tagNote(box.w, notes[0]);
+ u.faded(recast).tagNote(box.w, notes[1]);
+ }
const p = cursors.glide(now.moving(.memory, 0, time.move));
const moved = @as(f32, @floatFromInt(@as(i64, @bitCast(window[0] -% window[1])))) / 8;
const slide: f32 = (if (jumped) 0 else moved * (1 - p)) + hold_scroll;
@@ -408,7 +432,7 @@ pub const Stack = struct {
}.at;
const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool, was: ?[]const u8 = null };
// A frame whose name changes in place (on through a stub) crossfades over the 12 f before the advance.
- const renamed = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ const renamed = now.renaming();
const calls_was = rec.stack(u.f.scratch, now.stops[1]);
const calls_is = rec.stack(u.f.scratch, now.stops[0]);
var spans: [16]Span = undefined;
@@ -453,8 +477,12 @@ pub const Stack = struct {
// What each word is, where the recording says (`zt.telescope.slots`):
// a register saved for the caller, a local, the process's first stack.
const roles_from = window[0] -% 16;
- var roles_buf: [80]zt.telescope.Slot = undefined;
- const roles = zt.telescope.slots(memory, if (landed) &is else &was, roles_from, roles_buf[0..@min(slots + 4, roles_buf.len)]) catch roles_buf[0..0];
+ // Before the step and after it: a role that changes crossfades as memory strikes (12 f).
+ var roles_buf: [2][80]zt.telescope.Slot = undefined;
+ const roles = [2][]zt.telescope.Slot{
+ zt.telescope.slots(now.before(), &was, roles_from, roles_buf[0][0..@min(slots + 4, roles_buf[0].len)]) catch roles_buf[0][0..0],
+ zt.telescope.slots(now.moment(), &is, roles_from, roles_buf[1][0..@min(slots + 4, roles_buf[1].len)]) catch roles_buf[1][0..0],
+ };
// The words that point at other words of the window: `arc`s.
var at_rows: std.ArrayList(hexdump.RowAt) = .empty;
var pointers: std.ArrayList(struct { hexdump.RowAt, bool }) = .empty;
@@ -470,8 +498,8 @@ pub const Stack = struct {
marks.read = 0;
marks.read_shows = now.reading(.memory, 0);
}
- const below_rsp: i64 = @bitCast(addr -% rsp_shown);
- if (k.part == .stack) map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
+ const below_rsp: i64 = @bitCast(addr -% if (held) rsp_shown else is.rsp);
+ map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
// `free`: above rsp, not yet reached: its address at 60%, its word faint.
if (held and addr < rsp_shown) {
rows.free(v, y, memory, addr, below_rsp, lead);
@@ -492,9 +520,21 @@ pub const Stack = struct {
const gapped = gap > 0 and names.names.len > 0 and names.shows > 0;
if (gapped) pinGap(v.faded(names.shows), y, names.names, lone.?, gap);
const k_role = (addr -% roles_from) / 8;
- const what: zt.telescope.Role = if (k_role < roles.len) roles[k_role].role else .none;
- const role = roleName(u, what, (Recording.word(memory, addr, 8) catch null) orelse 1);
- const hops = rows.slot(v, y, room_w, now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local);
+ var role_at: [2]@TypeOf(roleName(u, .none, 0)) = undefined;
+ for (&role_at, roles, [2]Recording.Moment{ now.before(), now.moment() }) |*r, of, mem| {
+ const what: zt.telescope.Role = if (k_role < of.len) of[k_role].role else .none;
+ r.* = roleName(u, what, (Recording.word(mem, addr, 8) catch null) orelse 1);
+ }
+ const what: zt.telescope.Role = if (k_role < roles[1].len) roles[1][k_role].role else .none;
+ const role = role_at[1];
+ const role_was: rows.Role = .{ .name = role_at[0].name, .local = role_at[0].local, .going = recast, .from_rsp = @bitCast(addr -% was.rsp) };
+ // At a run a word changes in place under an 8 f crossfade, as a register does.
+ const ran = runFade(now, .memory);
+ const word_was = Recording.word(now.before(), addr, 8) catch null;
+ const word_is = Recording.word(now.moment(), addr, 8) catch null;
+ const fades = ran < 1 and !std.meta.eql(word_was, word_is);
+ if (fades) _ = rows.slot(v.faded(1 - ran), y, room_w, now.before(), addr, below_rsp, &.{}, 0, marks, role.name, role.local, role_was);
+ const hops = rows.slot(if (fades) v.faded(ran) else v, y, room_w, if (fades) now.moment() else now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was);
at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {};
pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, what == .saved and std.mem.eql(u8, what.saved, "rbp") }) catch {};
// Only a row on show is a place a tie can land.
@@ -503,13 +543,16 @@ pub const Stack = struct {
ties.anchor(u, .{ .slot_pin = addr }, .{ .x = theme.metric.slot.lane, .y = y, .w = theme.metric.slot.lane_end - theme.metric.slot.lane, .h = m.row });
}
}
- map.window(.stack, shown_at, shown_at + 8 * (@as(u64, slots) -| 1));
+ if (k.part == .stack) map.window(.stack, .{ ways[0], ways[0] + 8 * (@as(u64, slots) -| 1) }, .{ ways[1], ways[1] + 8 * (@as(u64, slots) -| 1) }, p);
// A frame's saved rbp is drawn by its span: its arc only in a step that touches it.
var arcs: rows.Arcs = .{};
for (pointers.items) |p_| {
const word, const saved = p_;
if (saved and !(now.writeAge(word.addr, 8) == 0 or now.wasRead(word.addr, 8))) continue;
+ const before = arcs.n;
hexdump.pointerArcs(&arcs, now, word.addr, word.y, at_rows.items, 8, .{ top - m.pad, box.h - m.pad }, false, false);
+ // Its step's alone: it goes with the advance (18 f), not in the next step's first frame.
+ if (saved and arcs.n > before) arcs.items[before].shows *= 1 - std.math.clamp((now.time - now.plan.advance) / time.read.out, 0, 1);
}
arcs.draw(v, theme.metric.arc.stack_lanes);
// Where the window is, for a link to a word outside it.
@@ -666,59 +709,84 @@ pub const Backtrace = struct {
if (box.h < m.tag) return;
const u = if (b.lens) at(f, placed, box).faded(placed.value(b.stage.drawing)) else at(f, placed, box);
const now = b.cursor.now(placed);
- const rec = b.cursor.rec;
- // A frame is its words on the stack: the chain changes with memory.
- // The frames both chains have (the same way back, counted from the
- // oldest) slide to their new depth, as rows making room; those that
- // end fade out first, those that begin fade in after.
- var new_buf: [24]Frame = undefined;
- var old_buf: [24]Frame = undefined;
- const chains = [2][]Frame{ frames(rec, now.stops[1], &old_buf), frames(rec, now.stops[0], &new_buf) };
- var shared: usize = 0;
- while (shared < @min(chains[0].len, chains[1].len) and chains[0][chains[0].len - 1 - shared].pc == chains[1][chains[1].len - 1 - shared].pc) shared += 1;
- const since = if (now.walking()) now.since(.memory, 0) else if (now.landed(.memory, 0)) std.math.inf(f32) else -std.math.inf(f32);
- const leave = std.math.clamp(since / time.quick, 0, 1);
- const slide = cursors.glide(std.math.clamp((since - time.quick / 2.0) / time.move, 0, 1));
- const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1);
- const room = rowsOf(box);
- const total = chains[if (slide >= 0.5) 1 else 0].len;
- map.measure(.backtrace, @max(chains[0].len, chains[1].len));
- const body = u.panel(box.w, box.h, "backtrace", .{ .focus = b.focus, .note = newestAtBottom(u, total, room) });
- clipBody(u, box);
- defer u.unclip();
- const opens = [2][]const Recording.Call{ rec.stack(u.f.scratch, now.stops[1]), rec.stack(u.f.scratch, now.stops[0]) };
- const top = body.y + m.pad;
- // Newest at the bottom, `#0` last: a frame's row is its place from
- // the oldest, less the oldest that do not fit (dropped from the top).
- const dropped = [2]usize{ chains[0].len -| room, chains[1].len -| room };
- for (chains, 0..) |chain, side| {
- const shows = if (side == 0) 1 - leave else arrive;
- for (chain, 0..) |frame, i| {
- const from_end = chain.len - 1 - i;
- const kept = from_end < shared;
- // A frame both have is drawn once, from the old chain to its place in the new.
- if (kept and side == 1) continue;
- var at_row = @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[side]));
- var depth = i;
- var which = side;
- if (kept) {
- const to = chains[1].len - 1 - from_end;
- at_row = std.math.lerp(at_row, @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[1])), slide);
- if (slide >= 0.5) {
- depth = to;
- which = 1;
- }
- } else if (shows <= 0) continue;
- if (at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
- const v = if (kept) u else u.faded(shows);
- const name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc}));
- rows.callRow(v, top + at_row * m.row, box.w, depth, name, callArguments(u, rec, opens[which], depth, frame.pc), frameWhere(u, rec, if (which == 1) now.marks[1] else now.marks[0], depth, frame.pc), depth == 0);
- }
- }
+ backtraceRows(u, now, b.cursor.rec, box, b.focus, "");
veiled(u, box, now.veil);
}
};
+/// A backtrace's panel and rows in `u`'s `box` (the panel, a lens's
+/// drawing, the calls lens's view: its tag's note after `prefix`).
+/// A frame is its words on the stack: the chain changes with memory. The
+/// frames both chains have (the same way back, counted from the oldest)
+/// slide to their new depth, as rows making room; those that end fade out
+/// first, those that begin fade in after. What a kept row says that
+/// changes (its depth, its pc's offset, its line) crossfades over the 12 f
+/// before the advance, as a stack span's name does; the newest's wash goes
+/// from one row to the other the same way. Nothing changes in a frame.
+pub fn backtraceRows(u: ui.Ui, now: cursors.Now, rec: *const Recording, box: Rect, focus: bool, prefix: []const u8) void {
+ var new_buf: [24]Frame = undefined;
+ var old_buf: [24]Frame = undefined;
+ const chains = [2][]Frame{ frames(rec, now.stops[1], &old_buf), frames(rec, now.stops[0], &new_buf) };
+ var shared: usize = 0;
+ while (shared < @min(chains[0].len, chains[1].len) and chains[0][chains[0].len - 1 - shared].pc == chains[1][chains[1].len - 1 - shared].pc) shared += 1;
+ // The newest frame's pc is the step's: it is the same frame whatever its offset.
+ if (shared < @min(chains[0].len, chains[1].len) and chains[0].len == chains[1].len and shared + 1 == chains[0].len) shared += 1;
+ const since = if (now.walking()) now.since(.memory, 0) else if (now.landed(.memory, 0)) std.math.inf(f32) else -std.math.inf(f32);
+ const leave = std.math.clamp(since / time.quick, 0, 1);
+ const slide = cursors.glide(std.math.clamp((since - time.quick / 2.0) / time.move, 0, 1));
+ const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1);
+ const renamed = now.renaming();
+ const room = rowsOf(box);
+ map.measure(.backtrace, @max(chains[0].len, chains[1].len));
+ const notes = [2][]const u8{ u.print("{s}{s}", .{ prefix, newestAtBottom(u, chains[0].len, room) }), u.print("{s}{s}", .{ prefix, newestAtBottom(u, chains[1].len, room) }) };
+ const renote = !std.mem.eql(u8, notes[0], notes[1]);
+ const body = u.panel(box.w, box.h, "backtrace", .{ .focus = focus, .note = if (renote) "" else notes[1] });
+ if (renote) {
+ u.faded(1 - slide).tagNote(box.w, notes[0]);
+ u.faded(slide).tagNote(box.w, notes[1]);
+ }
+ clipBody(u, box);
+ defer u.unclip();
+ const opens = [2][]const Recording.Call{ rec.stack(u.f.scratch, now.stops[1]), rec.stack(u.f.scratch, now.stops[0]) };
+ const top = body.y + m.pad;
+ // Newest at the bottom, `#0` last: a frame's row is its place from
+ // the oldest, less the oldest that do not fit (dropped from the top).
+ const dropped = [2]usize{ chains[0].len -| room, chains[1].len -| room };
+ const Row = struct { depth: usize, name: []const u8, args: []const u8, where: []const u8 };
+ for (chains, 0..) |chain, side| {
+ const shows = if (side == 0) 1 - leave else arrive;
+ for (chain, 0..) |frame, i| {
+ const from_end = chain.len - 1 - i;
+ const kept = from_end < shared;
+ // A frame both have is drawn once, from the old chain to its place in the new.
+ if (kept and side == 1) continue;
+ var at_row = @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[side]));
+ const here: Row = .{ .depth = i, .name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc})), .args = callArguments(u, rec, opens[side], i, frame.pc), .where = frameWhere(u, rec, now.marks[side], i, frame.pc) };
+ if (!kept) {
+ if (shows <= 0 or at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
+ rows.callRow(u.faded(shows), top + at_row * m.row, box.w, here.depth, here.name, here.args, here.where, here.depth == 0);
+ continue;
+ }
+ const to = chains[1].len - 1 - from_end;
+ const next = chains[1][to];
+ const there: Row = .{ .depth = to, .name = ui.symbol(u, rec.strings.get(next.pc) orelse u.print("{x}", .{next.pc})), .args = callArguments(u, rec, opens[1], to, next.pc), .where = frameWhere(u, rec, now.marks[1], to, next.pc) };
+ at_row = std.math.lerp(at_row, @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[1])), slide);
+ if (at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
+ const y = top + at_row * m.row;
+ // The wash where the row is the newest, going and coming with the words.
+ const washed = @as(f32, if (here.depth == 0) 1 - renamed else 0) + @as(f32, if (there.depth == 0) renamed else 0);
+ if (washed > 0) rows.callCurrent(u.faded(washed), y, box.w);
+ const same = here.depth == there.depth and std.mem.eql(u8, here.name, there.name) and std.mem.eql(u8, here.args, there.args) and std.mem.eql(u8, here.where, there.where);
+ if (same) {
+ rows.callLabels(u, y, box.w, there.depth, there.name, there.args, there.where, there.depth == 0);
+ } else {
+ rows.callLabels(u.faded(1 - renamed), y, box.w, here.depth, here.name, here.args, here.where, here.depth == 0);
+ rows.callLabels(u.faded(renamed), y, box.w, there.depth, there.name, there.args, there.where, there.depth == 0);
+ }
+ }
+ }
+}
+
/// A backtrace's tag note: `newest at the bottom`, and how many of the
/// oldest a panel of `room` rows leaves out above.
pub fn newestAtBottom(u: ui.Ui, total: usize, room: usize) []const u8 {
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index bbc3cf1..2811488 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -126,10 +126,11 @@ pub const Cursor = struct {
sprint_veil: anim.Value,
/// Steps taken.
count: anim.Value,
- /// The same values a little behind (`time.minimap_lag`): what the
- /// minimap draws from, secondary action that never starts on a primary
- /// onset's frame.
- lag: Lagged,
+ /// The same values a little behind (`time.minimap_lag`, then a frame
+ /// later each, `time.minimap_fade` of them): what the minimap draws
+ /// from, secondary action that never starts on a primary onset's frame
+ /// and fades over those frames.
+ lags: [time.minimap_fade]Lagged,
/// The levels the scene shows: set before the first step.
levels: Levels = .{},
/// The scene's whole way, for the head's progress line and counter (`journey`).
@@ -152,21 +153,21 @@ pub const Cursor = struct {
.veil = s.value(0),
.sprint_veil = s.value(0),
.count = s.value(0),
- .lag = undefined,
+ .lags = undefined,
.first = start,
.last = start,
};
// shortcut: an f32 holds whole moments up to 16 million; a longer recording needs two values a stop.
for (&c.stops) |*stop| stop.* = s.value(here);
for (&c.gaits) |*gait| gait.* = s.value(0);
- inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
+ for (&c.lags) |*lag| inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
const from = @field(c, name);
if (@TypeOf(from) == anim.Value) {
- @field(c.lag, name) = s.value(s.get(from));
- } else for (&@field(c.lag, name), from) |*to, one| {
+ @field(lag, name) = s.value(s.get(from));
+ } else for (&@field(lag, name), from) |*to, one| {
to.* = s.value(s.get(one));
}
- }
+ };
return c;
}
@@ -184,22 +185,44 @@ pub const Cursor = struct {
};
/// Plays `plays(values)` on the cursor's values from here, and on their
- /// lagging mirror `time.minimap_lag` later; the cursor ends where the first left it.
+ /// lagging mirrors `time.minimap_lag` later and a frame apart; the cursor ends where the first left it.
fn both(c: Cursor, s: *anim.Frame, plays: anytype) void {
const start = s.cursor;
- s.cursor = start + time.minimap_lag;
- plays.run(s, lagged(c));
+ for (0..c.lags.len) |k| {
+ s.cursor = start + time.minimap_lag + @as(f32, @floatFromInt(k)) / 60.0;
+ plays.run(s, lagged(c, k));
+ }
s.cursor = start;
plays.run(s, c);
}
- /// `c` with its lagging values in place of its own.
- fn lagged(c: Cursor) Cursor {
+ /// `c` with its `k`th lagging values in place of its own.
+ fn lagged(c: Cursor, k: usize) Cursor {
var out = c;
- inline for (@typeInfo(Lagged).@"struct".field_names) |name| @field(out, name) = @field(c.lag, name);
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| @field(out, name) = @field(c.lags[k], name);
return out;
}
+ /// `values` (a frame's every value, a copy) with the cursor's own as its
+ /// `k`th lagging mirror has them: what the minimap's `k`th drawing reads.
+ /// Returns whether they differ from the mirror before's (a drawing to make, not one to reuse).
+ pub fn lagInto(c: Cursor, values: []f32, k: usize) bool {
+ var differs = k == 0;
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
+ const own = @field(c, name);
+ const mirror = @field(c.lags[k], name);
+ const before = @field(c.lags[k -| 1], name);
+ if (@TypeOf(own) == anim.Value) {
+ values[@backingInt(own)] = values[@backingInt(mirror)];
+ differs = differs or values[@backingInt(mirror)] != values[@backingInt(before)];
+ } else for (own, mirror, before) |o, mv, b| {
+ values[@backingInt(o)] = values[@backingInt(mv)];
+ differs = differs or values[@backingInt(mv)] != values[@backingInt(b)];
+ }
+ }
+ return differs;
+ }
+
/// Where the timeline has taken the cursor so far: for scene code that
/// finds the next place from the last.
pub fn moment(c: Cursor, s: *const anim.Frame) u64 {
@@ -447,9 +470,8 @@ pub const Cursor = struct {
c.both(s, Jump{ .to = to });
}
- /// For a component, while it draws (on the minimap, `time.minimap_lag` behind).
- pub fn now(c_: Cursor, placed: anim.Placed) Now {
- const c = if (ui.strokes) lagged(c_) else c_;
+ /// For a component, while it draws (on the minimap the values are a lagging mirror's: `lagInto`).
+ pub fn now(c: Cursor, placed: anim.Placed) Now {
const rec = c.rec;
var n: Now = .{
.rec = rec,
@@ -577,12 +599,13 @@ pub const Now = struct {
/// How far (0 to 1, to be eased) a thing has got that moves as `level`
/// strikes: it sets off `lead` seconds before the strike and takes
/// `seconds`. At a run it sets off with its level and takes
- /// `time.run_ease`; at a sprint, and at rest, it is there.
+ /// `time.run_ease`; at a sprint it takes the step (4 f: never one
+ /// frame); at rest it is there.
pub fn moving(n: Now, level: Level, lead: f32, seconds: f32) f32 {
return switch (n.plan.gait) {
.walk => std.math.clamp((n.since(level, 0) + lead) / seconds, 0, 1),
.run => std.math.clamp(n.since(level, 0) / time.run_ease, 0, 1),
- .sprint => 1,
+ .sprint => if (n.resting()) 1 else std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1),
};
}
@@ -597,6 +620,17 @@ pub const Now = struct {
return if (n.fired == in) n.fire() else 0;
}
+ /// 0 to 1 over the 12 f before the advance (from the step's start where
+ /// that is sooner, over the step at a sprint): how far a label that
+ /// changes in place with the step (a frame's name, a tag's note) has
+ /// crossfaded to the new one. Never in a frame.
+ pub fn renaming(n: Now) f32 {
+ if (n.resting()) return 1;
+ const span = @min(time.quick, n.plan.advance);
+ if (span <= 0) return std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1);
+ return std.math.clamp((n.time - (n.plan.advance - span)) / span, 0, 1);
+ }
+
/// 0 to 1 (to be eased) through the mark's move to the next line: the
/// step's follow-through, and the next step's anticipation.
pub fn advancing(n: Now) f32 {
@@ -687,7 +721,8 @@ pub const Now = struct {
if (a < s.ember_steps) return .ember;
// Linear: a fade, as the mark leaves: secondary action does not
// start on the fire's frame, where the step's primary one does.
- return .{ .level = 1 - std.math.clamp((n.time - n.plan.advance) / s.out, 0, 1) };
+ // Within the step: a short one (a run's) is not cut off mid-fade by the next.
+ return .{ .level = 1 - std.math.clamp((n.time - n.plan.advance) / @max(@min(s.out, n.plan.total - n.plan.advance), 1.0 / 60.0), 0, 1) };
}
/// The mark of a thing last changed `age` steps ago (`older`: not
@@ -701,10 +736,15 @@ pub const Now = struct {
if (age != 0) return n.left(age);
const was = n.left(older);
switch (n.plan.gait) {
- // Faster than a strike can be seen: embers only.
- .sprint => return .ember,
- // A run strikes nothing: its values change in place.
- .run => return .none,
+ // Faster than a strike can be seen: embers only, coming in over the step.
+ .sprint => return .{ .level = if (n.resting()) 1 else std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1) },
+ // A run strikes nothing: its values change in place, and what
+ // marked them before goes with the run's ease, not in a frame.
+ .run => {
+ var gone = was;
+ gone.level *= 1 - (if (n.resting()) 1 else std.math.clamp(n.time / time.run_ease, 0, 1));
+ return gone;
+ },
.walk => {},
}
if (n.resting()) return .ember;
@@ -841,9 +881,10 @@ test "a write is armed, strikes, holds, cools with the advance, and leaves after
// Struck again over its ember: armed with the ember still under it.
h = instant(0.20, plan).heat(0, 1, -0.10);
try expect(h.level == 1 and h.arm == 1 and h.solid == 0);
- // Running: nothing struck. Sprinting: an ember, at once.
+ // Running: nothing struck, and the ember before goes over the run's ease. Sprinting: an ember, coming in over the step.
try expectEqual(ui.Heat.none, instant(0.2, Plan.running(0.3)).heat(0, null, 0.2));
- try expectEqual(ui.Heat.ember, instant(0.01, Plan.sprinting(0.05)).heat(0, null, 0.01));
+ try std.testing.expectApproxEqAbs(@as(f32, 0.5), instant(time.run_ease / 2.0, Plan.running(0.3)).heat(0, 1, 0).level, 1e-4);
+ try std.testing.expectApproxEqAbs(@as(f32, 0.2), instant(0.01, Plan.sprinting(0.05)).heat(0, null, 0.01).level, 1e-4);
}
test "what a step read is framed while its line is gold" {
diff --git a/anim/src/descent.zig b/anim/src/descent.zig
index 3394eaa..d435b59 100644
--- a/anim/src/descent.zig
+++ b/anim/src/descent.zig
@@ -107,11 +107,19 @@ pub const Descent = struct {
const room = theme.layout.rowsIn(box.h);
const before = layout(u, rec, now.stops[1], room, d.root);
const after = layout(u, rec, now.stops[0], room, d.root);
+ // On the map its box is as long as the rows it has wanted: not 69 for a function of 30.
+ if (ui.mapping) map.measure(.disasm, @max(before.items.len, after.items.len));
const tm = now.time;
const going = now.advancing();
const kind: enum { same, down, through, up } = if (now.resting() or now.stops[0] == now.stops[1]) .same else if (after.windows > before.windows) (if (before.in_stub) .through else .down) else if (after.windows < before.windows) .up else .same;
const shown = if (going >= 0.5) after else before;
- const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = shown.tag });
+ // A tag that changes with the advance crossfades over it.
+ const retag = !std.mem.eql(u8, before.tag, after.tag);
+ const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (retag) "" else shown.tag });
+ if (retag) {
+ u.faded(1 - going).tagNote(box.w, before.tag);
+ u.faded(going).tagNote(box.w, after.tag);
+ }
const top = body.y + m.pad;
u.clip(.{ .x = theme.stroke.rule, .y = m.tag, .w = box.w - 2 * theme.stroke.rule, .h = box.h - m.tag - theme.stroke.rule });
defer u.unclip();
@@ -328,7 +336,7 @@ pub const Descent = struct {
const yb = p.y + m.row / 2;
u.route(&.{ .{ 14, ya }, .{ 14, yb }, .{ c.address - 4, yb } }, t.primary, .{ .width = theme.stroke.rule, .head = .{ 7, 8 }, .radius = 4, .progress = cursors.standard(drawn) });
}
- map.window(.disasm, first(shown), last(shown));
+ map.window(.disasm, .{ first(after), last(after) }, .{ first(before), last(before) }, cursors.glide(going));
if (pc_y[1] orelse pc_y[0]) |y| ties.anchor(u, .pc, .{ .x = 0, .y = y, .w = theme.metric.plaque.pc, .h = m.row });
kernel(u, now, box, under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row, pc_y[0] orelse pc_y[1]);
context.veiled(u, box, now.veil);
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig
index e871cc6..cf16c6a 100644
--- a/anim/src/disasm.zig
+++ b/anim/src/disasm.zig
@@ -85,8 +85,18 @@ pub const Disasm = struct {
if (ui.mapping) map.measure(.disasm, listing(u, rec, now.marks[1], theme.map.disasm_rows, (theme.map.disasm_rows - 1) / 2).rows.len);
const pc = [2]u64{ rec.register(now.marks[0], "rip"), rec.register(now.marks[1], "rip") };
- const name = rec.strings.get(pc[if (going >= 0.5) 1 else 0]) orelse "";
- const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = name[0 .. std.mem.lastIndexOfScalar(u8, name, '+') orelse name.len] });
+ // The function's name: one that changes with the advance crossfades over it.
+ var names: [2][]const u8 = undefined;
+ for (pc, &names) |at_pc, *name| {
+ const sym = rec.strings.get(at_pc) orelse "";
+ name.* = sym[0 .. std.mem.lastIndexOfScalar(u8, sym, '+') orelse sym.len];
+ }
+ const renamed = !std.mem.eql(u8, names[0], names[1]);
+ const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (renamed) "" else names[1] });
+ if (renamed) {
+ u.faded(1 - going).tagNote(box.w, names[0]);
+ u.faded(going).tagNote(box.w, names[1]);
+ }
const top = body.y + m.pad;
u.clip(.{ .x = theme.stroke.rule, .y = m.tag, .w = box.w - 2 * theme.stroke.rule, .h = box.h - m.tag - theme.stroke.rule });
defer u.unclip();
@@ -172,7 +182,7 @@ pub const Disasm = struct {
break :blk rec.register(at - 1, "rip");
};
- if (shown.rows.len > 0) map.window(.disasm, shown.rows[0].addr, shown.rows[shown.rows.len - 1].addr);
+ if (to.rows.len > 0) map.window(.disasm, .{ to.rows[0].addr, to.rows[to.rows.len - 1].addr }, if (from.rows.len > 0) .{ from.rows[0].addr, from.rows[from.rows.len - 1].addr } else .{ to.rows[0].addr, to.rows[to.rows.len - 1].addr }, cursors.glide(going));
var last_line: ?u32 = null;
// A source of many lines (SQLite's) has wider numbers, as wide as
// its largest: what is right of them moves right by as much.
diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig
index 3abd052..47283e7 100644
--- a/anim/src/hexdump.zig
+++ b/anim/src/hexdump.zig
@@ -242,6 +242,27 @@ fn crossfade(now: cursors.Now) Passes {
return .{ .moments = .{ now.shown(.memory), undefined }, .shows = .{ 1, 0 }, .n = 1 };
}
+/// `crossfade`, for one row: at a walk too, a row whose bytes the step
+/// changed where the recording saw no write (memory nothing watches, read
+/// anew at the stop), or that became known, crossfades over 12 f from
+/// memory's slot. Nothing changes in a frame.
+fn rowPasses(now: cursors.Now, addr: u64) Passes {
+ const plain = crossfade(now);
+ if (plain.n == 2 or now.resting() or now.plan.gait != .walk or now.writeAge(addr, 16) == 0) return plain;
+ const q = std.math.clamp(now.since(.memory, 0) / theme.time.quick, 0, 1);
+ if (q <= 0 or q >= 1) return plain;
+ var was: [16]u8 = undefined;
+ var is: [16]u8 = undefined;
+ var known_was: [16]bool = undefined;
+ var known_is: [16]bool = undefined;
+ now.before().read(addr, &was, &known_was) catch return plain;
+ now.moment().read(addr, &is, &known_is) catch return plain;
+ for (0..16) |i| if (known_was[i] != known_is[i] or (known_is[i] and was[i] != is[i])) {
+ return .{ .moments = .{ now.before(), now.moment() }, .shows = .{ 1 - q, q }, .n = 2 };
+ };
+ return plain;
+}
+
/// A row of a panel: its first byte's address and its top.
pub const RowAt = struct { addr: u64, y: f32 };
@@ -418,9 +439,10 @@ pub fn fielded(v: View, now: cursors.Now, y: f32, of: Fields) void {
ry += m.row;
}
last = r;
- const passes = crossfade(now);
+ const passes = rowPasses(now, of.base + 16 * r);
for (passes.moments[0..passes.n], passes.shows[0..passes.n]) |mm, shows| fieldRow(u.faded(shows), now, ry, of.base + 16 * r, if (passes.n == 2) mm else moment, of, lead, shift);
at_rows.append(u.f.scratch, .{ .addr = of.base + 16 * r, .y = ry }) catch {};
+ @import("map.zig").row(.view, of.base + 16 * r, u, .{ .x = 0, .y = ry, .w = 860, .h = m.row });
ry += m.row;
}
if (shown[shown.len - 1] < total - 1) more(u, ry, total - 1 - shown[shown.len - 1]);
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig
index 65a9463..4ffe860 100644
--- a/anim/src/loupe.zig
+++ b/anim/src/loupe.zig
@@ -69,6 +69,19 @@ pub const Loupe = struct {
s.play(.{l.closing.to(1)}, .{ .seconds = time.close, .ease = anim.ease.linear });
}
+ /// What it opens on, by the pointer's name: for the map, where an open loupe is a panel of its own.
+ pub fn aim(l: *const Loupe, now: cursors.Now) ?struct { name: []const u8, target: u64 } {
+ const moment = now.moment();
+ return switch (l.from) {
+ .register => |name| blk: {
+ const regs = (moment.regs(l.cursor.rec.tid) catch null) orelse return null;
+ break :blk .{ .name = name, .target = regs.named(name) orelse return null };
+ },
+ .field => |field| .{ .name = "its field", .target = (Recording.word(moment, field.at, 8) catch null) orelse return null },
+ .row => |row| .{ .name = row.name, .target = row.fields.base },
+ };
+ }
+
/// Where it is now (in the working frame's units) and what it shows:
/// null while it is shut, or where its pointer is not on screen.
const Placed = struct { box: Rect, pointer: Rect, target: u64, first: u64, ink: u24 };
@@ -131,7 +144,7 @@ pub const Loupe = struct {
holding[@intFromBool(deep)] = null;
const opened = placed.value(l.opening) * time.open;
const closed = placed.value(l.closing);
- if (opened <= 0 or closed >= 1 or ui.mapping) return;
+ if (opened <= 0 or closed >= 1 or ui.mapping or @import("map.zig").looking(f)) return;
const u: ui.Ui = .{ .f = f, .at = placed };
const now = l.cursor.now(placed);
const p = l.place(u, now) orelse return;
diff --git a/anim/src/map.zig b/anim/src/map.zig
index 341d75f..255ea2d 100644
--- a/anim/src/map.zig
+++ b/anim/src/map.zig
@@ -36,6 +36,11 @@ pub const diving = struct {
pub const surface = 84;
};
+/// Whether every frame is the map (`Map.wholeMap`): `CANIM_MAP` in the environment.
+pub fn looking(f: *sk.Frame) bool {
+ return f.host.env("CANIM_MAP") != null;
+}
+
/// The dive's frames over which the falling map crossfades into the minimap's drawing.
pub const minimap_lands = [2]f32{ 90, 96 };
@@ -48,8 +53,10 @@ pub fn minimapShows(t: f32) f32 {
var window_px: [7]?[4]f32 = @splat(null);
/// The working frame's windows this frame: the first and last key of the
-/// rows each shows (a line number, an address).
-var windows: [7]?[2]u64 = @splat(null);
+/// rows each shows (a line number, an address), those it shows at the
+/// step's start, and how far (0 to 1, eased) it has gone from them.
+var windows: [7]?Window = @splat(null);
+const Window = struct { now: [2]u64, was: [2]u64, p: f32 };
/// The map's rows this frame, in canvas pixels: each one's key and box.
var rows: [7][160]struct { key: u64, box: [4]f32 } = undefined;
var counts: [7]usize = @splat(0);
@@ -64,9 +71,11 @@ pub fn measure(panel: Panel, n: usize) void {
if (ui.mapping) held[@intFromEnum(panel)] = @max(held[@intFromEnum(panel)], n);
}
-/// A working panel shows the rows of keys `first` to `last`.
-pub fn window(panel: Panel, first: u64, last: u64) void {
- if (!ui.mapping) windows[@intFromEnum(panel)] = .{ first, last };
+/// A working panel shows the rows of keys `now` (first and last), going
+/// there from `was`, `p` of the way (eased): its outline on the minimap
+/// glides with its scroll, and never jumps.
+pub fn window(panel: Panel, now: [2]u64, was: [2]u64, p: f32) void {
+ if (!ui.mapping) windows[@intFromEnum(panel)] = .{ .now = now, .was = was, .p = p };
}
/// A map panel's row of key `key` is at `r`, in `u`'s units.
@@ -87,7 +96,7 @@ pub fn row(panel: Panel, key: u64, u: ui.Ui, r: Rect) void {
/// lens's view, the registers, and in the rest the stack going on
/// (`continued`), in the third; the stack in the fourth, whole.
// shortcut: a column's rest after the disassembly is page: the 5-row dumps round what the registers point at, the open loupes and the key are not built.
-pub fn split(rec: *const Recording, lens: bool) Split {
+pub fn split(rec: *const Recording, lens: bool, way: [2]u64) Split {
const st = theme.map.stage;
const c = theme.map.columns;
const w = theme.map.column;
@@ -102,32 +111,203 @@ pub fn split(rec: *const Recording, lens: bool) Split {
}.of;
const band: Rect = .{ .x = c[0], .y = st.y, .w = w, .h = if (lens) theme.layout.split.subject.band.h else 0 };
const source_y = if (lens) band.y + band.h + gap else st.y;
- const bt_rows = want(.backtrace, 5);
+ // The backtrace as long as the call chain gets over the scene's way: packed once, never repacked under the eye.
+ const bt_rows = @max(want(.backtrace, 0), deepest(rec, way));
const source_rows: f32 = @floatFromInt(@min(rec.line_count, theme.layout.rowsIn(foot - source_y - gap - panelH(bt_rows))));
const source: Rect = .{ .x = c[0], .y = source_y, .w = w, .h = panelH(source_rows) };
const bt_y = source.y + source.h + gap;
- const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens) panelH(@min(want(.view, theme.map.memory_rows), theme.map.memory_rows)) else 0 };
- const registers: Rect = .{ .x = c[2], .y = if (lens) view.y + view.h + gap else st.y, .w = w, .h = panelH(17) };
+ // The view as long as what draws there has wanted: none where nothing does (a lens drawn alone).
+ const view_rows = @min(want(.view, 0), theme.map.memory_rows);
+ const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens and view_rows > 0) panelH(view_rows) else 0 };
+ const registers: Rect = .{ .x = c[2], .y = if (view.h > 0) view.y + view.h + gap else st.y, .w = w, .h = panelH(17) };
const more_y = registers.y + registers.h + gap;
const more_h = foot - more_y;
+ const disasm: Rect = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(@min(want(.disasm, theme.map.disasm_rows), theme.map.disasm_rows)) };
+ // The source longer than its column (69 lines round the current line, or the file whole if shorter)
+ // goes on at the top of the next column's free space, under its tag, `continued`.
+ const lines_left: f32 = @as(f32, @floatFromInt(@min(rec.line_count, theme.map.disasm_rows))) - source_rows;
+ const under_disasm = disasm.y + disasm.h + gap;
+ const more_rows = @min(lines_left, @as(f32, @floatFromInt(theme.layout.rowsIn(foot - under_disasm))));
+ const source_more: Rect = .{ .x = c[1], .y = under_disasm, .w = w, .h = if (more_rows >= 3) panelH(more_rows) else 0 };
+ const backtrace: Rect = .{ .x = c[0], .y = bt_y, .w = w, .h = @min(panelH(bt_rows), foot - bt_y) };
+ const rest = struct {
+ fn under(r: Rect, bottom: f32) Rect {
+ const y = r.y + r.h + theme.canvas.row_gap;
+ return .{ .x = r.x, .y = y, .w = r.w, .h = @max(bottom - y, 0) };
+ }
+ }.under;
return .{
.band = band,
.view = view,
.source = source,
- .disasm = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(@min(want(.disasm, theme.map.disasm_rows), theme.map.disasm_rows)) },
+ .disasm = disasm,
.registers = registers,
.stack = .{ .x = c[3], .y = st.y, .w = w, .h = st.h },
- .backtrace = .{ .x = c[0], .y = bt_y, .w = w, .h = @min(panelH(bt_rows), foot - bt_y) },
+ .backtrace = backtrace,
.dump_rows = theme.map.memory_rows,
.more = .{ .x = c[2], .y = more_y, .w = w, .h = if (more_h >= panelH(3)) theme.layout.panelH(@floor((more_h - 32) / 24)) else 0 },
+ .source_more = source_more,
+ .spare = .{ rest(backtrace, foot), if (source_more.h > 0) rest(source_more, foot) else rest(disasm, foot) },
};
}
+/// The most frames the call chain has from moment `way[0]` to `way[1]` (5 where it knows none).
+fn deepest(rec: *const Recording, way: [2]u64) f32 {
+ const context = @import("context.zig");
+ var most: usize = 0;
+ var seen: ?@TypeOf(rec.depths[0]) = null;
+ var i = way[0];
+ while (i <= @min(way[1], rec.end())) : (i += 1) {
+ if (seen != null and rec.depths[i] <= seen.?) continue;
+ seen = rec.depths[i];
+ var buf: [24]context.Frame = undefined;
+ most = @max(most, context.frames(rec, i, &buf).len);
+ }
+ return @floatFromInt(if (most > 0) most else 5);
+}
+
+/// What the map gives the rest of its first two columns, in the
+/// catalogue's order once the stack has had more (its own column, and the
+/// registers' column's rest, `stack, continued`): a short dump round each
+/// place the registers and the stack's words point at, outside the stack
+/// and the code (five rows, the target's row in the middle, its region's
+/// ink: registers first, in pwndbg's order, then the words up from rsp,
+/// none within another's rows); the loupes open, each a lifted panel of
+/// nine rows; and last the key. Only then page.
+pub const Spare = struct {
+ cursor: @import("cursor.zig").Cursor,
+ stage: *const Stage,
+ map: *const Map,
+
+ pub fn draw(sp: *const Spare, f: *sk.Frame, placed: anim.Placed) void {
+ if (!ui.mapping) return;
+ const hexdump = @import("hexdump.zig");
+ const context = @import("context.zig");
+ const rows_ = @import("rows.zig");
+ const m = theme.metric.context;
+ const panelH = theme.layout.panelH;
+ var free = sp.stage.now(placed).spare;
+ const now = sp.cursor.now(placed);
+ const rec = sp.cursor.rec;
+ const moment = now.moment();
+ const regs = (moment.regs(rec.tid) catch null) orelse return;
+ const things = @import("objects.zig").reach(f.scratch, rec, moment, null);
+ // The next box of height `h` in what is left: from the top of the first column with room.
+ const take = struct {
+ fn of(left: *[2]Rect, h: f32) ?Rect {
+ for (left) |*r| if (r.h >= h) {
+ const out: Rect = .{ .x = r.x, .y = r.y, .w = r.w, .h = h };
+ r.y += h + theme.canvas.row_gap;
+ r.h = @max(r.h - h - theme.canvas.row_gap, 0);
+ return out;
+ };
+ return null;
+ }
+ }.of;
+ const Target = struct { name: []const u8, at: u64 };
+ var targets: [24]Target = undefined;
+ var n: usize = 0;
+ const add = struct {
+ fn of(list: []Target, count: *usize, mo: Recording.Moment, name: []const u8, at: u64) void {
+ if (count.* == list.len) return;
+ switch (rows_.regionOf(mo, at)) {
+ .heap, .data, .rwx, .rodata => {},
+ .none, .stack, .code => return,
+ }
+ var byte: [8]u8 = undefined;
+ var known: [8]bool = undefined;
+ mo.read(at & ~@as(u64, 7), &byte, &known) catch return;
+ if (!known[0]) return;
+ // None within another's five rows.
+ for (list[0..count.*]) |t_| if (@abs(@as(i64, @bitCast((at & ~@as(u64, 15)) -% (t_.at & ~@as(u64, 15))))) < 5 * 16) return;
+ list[count.*] = .{ .name = name, .at = at };
+ count.* += 1;
+ }
+ }.of;
+ for (theme.metric.all_registers[0..16]) |name| {
+ if (std.mem.eql(u8, name, "rsp") or std.mem.eql(u8, name, "rbp")) continue;
+ add(&targets, &n, moment, name, regs.named(name) orelse continue);
+ }
+ var word: u64 = 0;
+ while (word < 64) : (word += 1) {
+ const addr = regs.rsp + 8 * word;
+ const points = (Recording.word(moment, addr, 8) catch null) orelse continue;
+ add(&targets, &n, moment, f.format("rsp+{x}", .{8 * word}), points);
+ }
+ for (targets[0..n]) |target| {
+ const box = take(&free, panelH(5)) orelse break;
+ const u = context.at(f, placed, box);
+ const region = rows_.regionOf(moment, target.at);
+ _ = u.panel(box.w, box.h, target.name, .{ .note = f.format("\u{2192} {x} \u{00b7} {s}", .{ target.at, regionName(region) }) });
+ hexdump.drawArcs(u, now, 0, m.tag + m.pad, (target.at & ~@as(u64, 15)) -| 32, 5, .{ .things = things, .region = rows_.ink(region) }, false, .{ m.tag, box.h - m.pad });
+ }
+ // The loupes open: lifted, nine rows round their target.
+ for (sp.map.loupes) |maybe| {
+ const l = maybe orelse continue;
+ const shows = std.math.clamp(placed.value(l.opening) * theme.time.loupe.open / theme.time.loupe.rise, 0, 1) * (1 - placed.value(l.closing));
+ if (shows <= 0) continue;
+ const aim = l.aim(now) orelse continue;
+ const box = take(&free, panelH(9)) orelse break;
+ const u = context.at(f, placed, box).faded(shows);
+ u.fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, theme.color.lift);
+ _ = u.panel(box.w, box.h, "loupe", .{ .note = f.format("{s} \u{2192} {x}", .{ aim.name, aim.target }) });
+ hexdump.drawArcs(u, now, 0, m.tag + m.pad, (aim.target & ~@as(u64, 15)) -| 64, 9, .{ .things = things, .region = rows_.ink(rows_.regionOf(moment, aim.target)) }, true, .{ m.tag, box.h - m.pad });
+ }
+ // The key: the recording and the moment, the marks, the inks.
+ if (take(&free, panelH(3))) |box| key(context.at(f, placed, box), box, rec, now);
+ }
+
+ fn regionName(region: @import("ztrace").telescope.Region) []const u8 {
+ return switch (region) {
+ .stack => "stack",
+ .heap => "heap",
+ .code => "code",
+ .data, .rwx => "data",
+ .rodata => "read-only",
+ .none => "",
+ };
+ }
+
+ /// The map's key, three rows: what ran and where in it the map is; the marks, each drawn as it is; the inks.
+ fn key(u: ui.Ui, box: Rect, rec: *const Recording, now: @import("cursor.zig").Now) void {
+ const m = theme.metric.context;
+ const t = theme.color.text;
+ const size = theme.size.mono.context;
+ const body = u.panel(box.w, box.h, "key", .{ .note = "the marks and inks of every picture", .legend = &.{} });
+ const rows_ = @import("rows.zig");
+ var y = body.y + m.pad;
+ u.text(.mono, size, m.side, rows_.baseline(y), u.print("{s} \u{00b7} moment {d} of {d}", .{ rec.file, now.marked() -| now.way[0], now.way[1] -| now.way[0] }), t.primary);
+ y += m.row;
+ var x: f32 = m.side;
+ u.current(.{ .x = x, .y = y, .w = 120, .h = m.row }, 40, 0);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "current", t.primary);
+ x += 160;
+ _ = u.written(.{ .x = x + 6, .y = y, .w = 24, .h = m.row }, .struck);
+ u.text(.mono_bold, size, x + 6, rows_.baseline(y), "2a", t.bright);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "written", t.primary);
+ x += 160;
+ u.corner(x + 2, y + 2, m.corner, 1);
+ u.text(.mono, size, x + 6, rows_.baseline(y), "2a", t.primary);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "changed", t.primary);
+ x += 160;
+ u.read(.{ .x = x + 6, .y = y, .w = 24, .h = m.row }, 1);
+ u.text(.mono, size, x + 6, rows_.baseline(y), "2a", t.primary);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "read", t.primary);
+ y += m.row;
+ x = m.side;
+ for (@import("context.zig").legend) |entry| {
+ u.text(.mono, size, x, rows_.baseline(y), entry.text, entry.ink);
+ if (entry.under) u.fill(.{ .x = x, .y = rows_.baseline(y) + 3, .w = u.width(.mono, size, entry.text), .h = theme.stroke.rule }, entry.ink);
+ x += u.width(.mono, size, entry.text) + 24;
+ }
+ }
+};
+
/// The map: its stage, and the components drawn on it, each a working
/// frame's component bound to that stage.
pub const Map = struct {
stage: *Stage,
- parts: [8]Part = undefined,
+ parts: [12]Part = undefined,
n: usize = 0,
/// The panel the narration is in: its window bright on the minimap.
focus: ?Panel = null,
@@ -140,6 +320,8 @@ pub const Map = struct {
obj: anim.Obj = undefined,
/// Where the program is: for the thread across the gutter, and the minimap's flashes.
cursor: ?@import("cursor.zig").Cursor = null,
+ /// The scene's loupes: open, each is a panel of its own on the map (`Spare`).
+ loupes: [2]?*const @import("loupe.zig").Loupe = .{ null, null },
const Part = struct { ctx: *const anyopaque, draw: *const fn (*const anyopaque, *sk.Frame, anim.Placed) void };
@@ -155,6 +337,13 @@ pub const Map = struct {
m.n += 1;
}
+ /// Puts a drawing on the map, in a band of its own over the source,
+ /// for a scene whose working frame has none (its map is split anew).
+ pub fn drawing(m: *Map, s: *anim.Frame, rec: *const Recording, component: anytype) void {
+ m.stage.first = split(rec, true, if (m.cursor) |c| .{ c.first, c.last } else .{ 0, 0 });
+ m.add(s, component);
+ }
+
/// Whether the working frame is in place (the minimap is the map).
pub fn settled(m: *const Map, at: anim.Placed) bool {
return at.value(m.t) >= diving.land;
@@ -229,6 +418,21 @@ pub const Map = struct {
}
}
+ /// Frames into the dive now; 0 (the map filling the frame, as a scene
+ /// that opens on it shows it) with `CANIM_MAP` in the environment.
+ fn diveAt(m: *const Map, f: *sk.Frame, placed: anim.Placed) f32 {
+ return if (looking(f)) 0 else placed.value(m.t);
+ }
+
+ /// With `CANIM_MAP` in the environment every frame is the map filling
+ /// it, as a scene that opens on it shows it (the clock draws it, `wholeMap`; the
+ /// working panels, the ties and the loupes stand aside): for looking at
+ /// any scene's map at 1:1 in a 4K export.
+ pub fn wholeMap(m: *const Map, f: *sk.Frame, placed: anim.Placed) void {
+ const fixed = @import("words.zig").fixed(f, placed, 0);
+ m.copy(f, m.falling(f, placed, 0), fixed, 0);
+ }
+
/// Below this scale (of the frame's) the falling map is drawn over the
/// panels, on its way into the corner, and not under them.
const small = 0.12;
@@ -328,19 +532,39 @@ pub const Map = struct {
raw.route(&.{ .{ a[2], (a[1] + a[3]) / 2 }, .{ lane, (a[1] + a[3]) / 2 }, .{ lane, (b[1] + b[3]) / 2 }, .{ b[0], (b[1] + b[3]) / 2 } }, gold, .{ .width = w, .head = null, .radius = 0 });
}
if (!mini or !now.walking()) return;
- // A struck word outside every window: the stack's, round its rsp.
+ // A mark no working window shows: a word struck or read, on the
+ // stack (its own column or continued) or in memory the map draws
+ // (the view's dump, the dumps round the pointers), flashes where the
+ // map has it, in the mark's colour.
const since = now.since(.memory, 0);
const p = since / (12.0 / 60.0);
if (p < 0 or p > 1) return;
- const win = windows[@intFromEnum(Panel.stack)] orelse return;
- for (rec.written(now.stops[1], now.stops[0])) |span| {
+ const marks = [2]struct { spans: []const Recording.Span, ink: u24 }{
+ .{ .spans = rec.written(now.stops[1], now.stops[0]), .ink = theme.color.struck },
+ .{ .spans = rec.read(now.stops[1], now.stops[0]), .ink = theme.mark(.read).solid },
+ };
+ for (marks) |mark| for (mark.spans) |span| {
+ // Where the map has it: the stack's word, or the 16 bytes of a dump's row.
const word = span.addr & ~@as(u64, 7);
- if (word >= win[0] and word <= win[1]) continue;
- const box = rows_of(.stack, word) orelse continue;
+ const sixteen = span.addr & ~@as(u64, 15);
+ const panel: Panel, const key: u64 = if (rows_of(.stack, word) != null) .{ .stack, word } else .{ .view, sixteen };
+ const box = rows_of(panel, key) orelse continue;
+ if (windows[@intFromEnum(panel)]) |win| if (key >= win.now[0] and key <= win.now[1]) continue;
const c = ui.Vec{ (box[0] + box[2]) / 2, (box[1] + box[3]) / 2 };
const r = std.math.lerp(@as(f32, 4), 7, p) * k / theme.minimap.scale;
- raw.faded(1 - p).disc(c, r, null, ui.rgb(theme.color.struck), @max(1, k / theme.minimap.scale));
- }
+ raw.faded(1 - p).disc(c, r, null, ui.rgb(mark.ink), @max(1, k / theme.minimap.scale));
+ };
+ }
+
+ /// The top and bottom of the map's rows of panel `i` with keys from `keys[0]` to `keys[1]`, in canvas pixels.
+ fn spanOf(i: usize, keys: [2]u64) ?[2]f32 {
+ var top: f32 = std.math.inf(f32);
+ var bottom: f32 = -std.math.inf(f32);
+ for (rows[i][0..counts[i]]) |rw| if (rw.key >= keys[0] and rw.key <= keys[1]) {
+ top = @min(top, rw.box[1]);
+ bottom = @max(bottom, rw.box[3]);
+ };
+ return if (top < bottom) .{ top, bottom } else null;
}
/// Where the map's row of key `key` in `panel` is this frame, in canvas pixels.
@@ -367,48 +591,110 @@ pub const Map = struct {
var r: [4]f32 = .{ a[0], a[1], b[0], b[1] };
var shown = panel == .registers or panel == .band;
if (windows[i]) |win| {
- var top: f32 = std.math.inf(f32);
- var bottom: f32 = -std.math.inf(f32);
- for (rows[i][0..counts[i]]) |rw| if (rw.key >= win[0] and rw.key <= win[1]) {
- top = @min(top, rw.box[1]);
- bottom = @max(bottom, rw.box[3]);
- };
- if (top < bottom) {
- r[1] = top;
- r[3] = bottom;
+ // Where the window was and where it is, and between them as far as its scroll has gone.
+ const is = spanOf(i, win.now);
+ const was = spanOf(i, win.was) orelse is;
+ if (is orelse was) |to| {
+ const from = was orelse to;
+ // On the minimap each end on whole pixels: crisp at rest, between them only while it glides.
+ const snap = struct {
+ fn of(v: f32, on: bool) f32 {
+ return if (on) @round(v) else v;
+ }
+ }.of;
+ r[1] = std.math.lerp(snap(from[0], mini), snap(to[0], mini), win.p);
+ r[3] = std.math.lerp(snap(from[1], mini), snap(to[1], mini), win.p);
shown = true;
}
}
+ // On the minimap on whole pixels (a window's ends already are, at rest).
+ if (mini) {
+ r[0] = @round(r[0]);
+ r[2] = @round(r[2]);
+ if (windows[i] == null) {
+ r[1] = @round(r[1]);
+ r[3] = @round(r[3]);
+ }
+ }
window_px[i] = if (shown) r else null;
if (shown) {
const focus = m.focus == panel;
// On the minimap a pixel of the frame: `k` is the canvas's pixels to a map unit.
const w = if (mini) @as(f32, if (focus) 1.5 else 1) * k / theme.minimap.scale else theme.map.outline * k;
const out = if (mini) w else theme.map.outline_out * k;
- raw.frame(.{ .x = r[0] - out, .y = r[1] - out, .w = r[2] - r[0] + 2 * out, .h = r[3] - r[1] + 2 * out }, ui.mix(if (mini) theme.color.text.primary else theme.color.text.dim, theme.color.text.bright, bright), if (bright > 0 and !mini) w * 1.5 else w);
+ const ring: Rect = .{ .x = r[0] - out, .y = r[1] - out, .w = r[2] - r[0] + 2 * out, .h = r[3] - r[1] + 2 * out };
+ const ink = ui.mix(if (mini) theme.color.text.primary else theme.color.text.dim, theme.color.text.bright, bright);
+ // On the minimap not snapped to pixels: a window that glides moves a pixel over many frames, not in one.
+ if (mini) {
+ const pen = raw.at.pen(.{ .fill = ink });
+ for ([4]sk.math.Rect{ .{ .x = ring.x, .y = ring.y, .w = ring.w, .h = w }, .{ .x = ring.x, .y = ring.y + ring.h - w, .w = ring.w, .h = w }, .{ .x = ring.x, .y = ring.y + w, .w = w, .h = ring.h - 2 * w }, .{ .x = ring.x + ring.w - w, .y = ring.y + w, .w = w, .h = ring.h - 2 * w } }) |edge| sk.draw.rect(f, edge, pen);
+ } else raw.frame(ring, ink, if (bright > 0) w * 1.5 else w);
}
}
}
}
};
+/// The minimap's drawings, a frame apart, and what they are averaged into:
+/// the host's images, made once for a size.
+/// shortcut: a process-wide cache of host images, for one player at a time; two at once want it in their Session.
+var fades: struct { w: u32 = 0, h: u32 = 0, images: [theme.time.minimap_fade + 1]sk.Image = undefined } = .{};
+
/// The minimap: `m` at a twentieth in the caption band's right end, still
/// while the camera moves; the page under it, framed a pixel in `rule`.
+/// Every change on it fades in over `time.minimap_fade` frames from
+/// `time.minimap_lag` after its onset: it is the average of that many
+/// drawings, each from the cursor's mirror a frame later (`Cursor.lagInto`),
+/// so a stroke that changes, a mark that comes and the gold that moves on
+/// all fade, and a window's glide is smoothed, never stepped.
pub fn minimap(m: *const Map, f: *sk.Frame, at: anim.Placed) void {
var shown = at;
- shown.pose.opacity *= minimapShows(at.value(m.t));
+ shown.pose.opacity *= minimapShows(m.diveAt(f, at));
if (shown.pose.opacity <= 0) return;
const fixed = @import("words.zig").fixed(f, shown, 0);
const box = theme.minimap.box;
- fixed.fill(box, theme.color.page);
+ const a = fixed.at.xf.apply(.{ box.x, box.y });
+ const b = fixed.at.xf.apply(.{ box.x + box.w, box.y + box.h });
+ const px: sk.Rect = .{ .x = @round(a[0]), .y = @round(a[1]), .w = @round(b[0]) - @round(a[0]), .h = @round(b[1]) - @round(a[1]) };
+ const w: u32 = @intFromFloat(@max(px.w, 1));
+ const h: u32 = @intFromFloat(@max(px.h, 1));
+ if (fades.w != w or fades.h != h) {
+ if (fades.w != 0) for (fades.images) |img| f.host.freeImage(img);
+ for (&fades.images) |*img| img.* = f.host.newImage(w, h);
+ fades.w = w;
+ fades.h = h;
+ }
+ // Each drawing in an image of its own, the page under it, in the image's pixels.
var placed = fixed.at;
- placed.xf = placed.xf.mul(.translate(box.x, box.y)).mul(.scale(theme.minimap.scale, theme.minimap.scale));
+ placed.pose.opacity = 1;
+ placed.xf = sk.math.Affine.translate(-px.x, -px.y).mul(fixed.at.xf).mul(.translate(box.x, box.y)).mul(.scale(theme.minimap.scale, theme.minimap.scale));
placed.scale = fixed.at.scale * theme.minimap.scale;
- const clip = fixed.at.xf.apply(.{ box.x, box.y });
- const end = fixed.at.xf.apply(.{ box.x + box.w, box.y + box.h });
- f.clip(sk.Rect{ .x = @round(clip[0]), .y = @round(clip[1]), .w = @round(end[0]) - @round(clip[0]), .h = @round(end[1]) - @round(clip[1]) });
- m.drawAt(f, placed, true);
- f.clip(null);
+ const values = f.scratch.dupe(f32, at.values) catch return;
+ placed.values = values;
+ const n = theme.time.minimap_fade;
+ var weights: [n]f32 = @splat(0);
+ var made: usize = 0;
+ for (0..n) |k| {
+ // A mirror the same as the one before draws the same: its drawing counts twice.
+ const differs = if (m.cursor) |c| c.lagInto(values, k) else k == 0;
+ if (differs) {
+ f.target(fades.images[made]);
+ f.clear(ui.rgb(theme.color.page));
+ m.drawAt(f, placed, true);
+ made += 1;
+ }
+ weights[made - 1] += 1;
+ }
+ // Averaged: each drawing over those before it at its share of the drawings so far.
+ const whole: sk.Rect = .{ .x = 0, .y = 0, .w = px.w, .h = px.h };
+ f.target(fades.images[n]);
+ var so_far: f32 = 0;
+ for (fades.images[0..made], weights[0..made]) |img, weight| {
+ so_far += weight;
+ f.image(img, whole, .{ .tint = sk.Color.white.alphaFloat(weight / so_far) });
+ }
+ f.target(.none);
+ f.image(fades.images[n], px, .{ .tint = sk.Color.white.alphaFloat(shown.pose.opacity) });
fixed.frame(.{ .x = box.x - 1, .y = box.y - 1, .w = box.w + 2, .h = box.h + 2 }, theme.color.rule, 1);
}
diff --git a/anim/src/nodes.zig b/anim/src/nodes.zig
index 81a9953..7c842d3 100644
--- a/anim/src/nodes.zig
+++ b/anim/src/nodes.zig
@@ -77,7 +77,7 @@ pub const Nodes = struct {
const shown = @min(count, (hi - first) / 16);
const v = hexdump.panel(f, placed, g.stage, u.print("the heap, {x} to {x}", .{ first, first + 16 * shown - 1 }), &legend);
if (v.rows > 0) hexdump.draw(v.u, now, 0, m.tag + m.pad, first, @min(shown, v.rows), .{ .things = things });
- if (v.rows > 0) @import("map.zig").window(.view, first, first + 16 * (@min(shown, v.rows) -| 1));
+ if (v.rows > 0) @import("map.zig").window(.view, .{ first, first + 16 * (@min(shown, v.rows) -| 1) }, .{ first, first + 16 * (@min(shown, v.rows) -| 1) }, 1);
v.veil(now);
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
}
@@ -221,7 +221,10 @@ pub const Nodes = struct {
const names = g.pins(u, now, o.addr);
const cx = r.x + r.w / 2;
ties.anchor(u, .{ .node_pin = o.addr }, .{ .x = cx - 1, .y = r.y + r.h, .w = 2, .h = label + 10 });
- if (names.names.len > 0 and names.shows > 0) u.faded(names.shows).pinUnderInked(cx, r.y + r.h, names.names, names.inks, heap, label);
+ if (names.names.len > 0 and names.shows > 0) {
+ u.faded(names.shows).pinUnderInked(cx, r.y + r.h, &.{}, &.{}, heap, label);
+ u.faded(names.shows * names.text).pinNames(cx, r.y + r.h, names.names, names.inks, label);
+ }
}
/// Where variable `name`'s tag is: it travels from node to node in the
@@ -279,7 +282,10 @@ pub const Nodes = struct {
}
}
- const Pins = struct { names: []const []const u8, inks: []const u24, shows: f32 };
+ /// `text`: how much its names show: a register joining or leaving
+ /// crosses the middle of its change with them faded out, so the names
+ /// it leaves and those it gets never swap in a frame.
+ const Pins = struct { names: []const []const u8, inks: []const u24, shows: f32, text: f32 = 1 };
/// The registers that hold `addr` (before this step, and after it once
/// their link has landed), then the scene's variables that do.
@@ -288,6 +294,7 @@ pub const Nodes = struct {
var out: std.ArrayList([]const u8) = .empty;
var inks: std.ArrayList(u24) = .empty;
var shows: f32 = 0;
+ var text: f32 = 1;
const is = (now.moment().regs(rec.tid) catch null) orelse zt.Regs{};
const was = (now.before().regs(rec.tid) catch null) orelse is;
// The scene's variables first: what the narration names, in the ink
@@ -309,6 +316,7 @@ pub const Nodes = struct {
if (!before and !after) continue;
const s = ties.pinShows(now, i, .node);
const this = if (before and after) 1 else if (after) s.new else s.old;
+ if (before != after) text = @min(text, @abs(2 * this - 1));
if (this < 0.5) continue;
out.append(u.f.scratch, name) catch break;
inks.append(u.f.scratch, t.primary) catch break;
@@ -317,7 +325,7 @@ pub const Nodes = struct {
// Names keep their side: the first to come is on the left, the next
// on the right, and a name that lands where another is stays on the
// right it travelled on; one left alone where it was on the right stays there.
- const came = u.f.scratch.alloc(u64, out.items.len) catch return .{ .names = out.items, .inks = inks.items, .shows = shows };
+ const came = u.f.scratch.alloc(u64, out.items.len) catch return .{ .names = out.items, .inks = inks.items, .shows = shows, .text = text };
for (out.items, came) |name, *at| at.* = g.arrival(u, now, name, addr);
for (1..@max(out.items.len, 1)) |i| {
var k = i;
@@ -345,7 +353,7 @@ pub const Nodes = struct {
inks.insert(u.f.scratch, 0, t.primary) catch {};
}
}
- return .{ .names = out.items, .inks = inks.items, .shows = shows };
+ return .{ .names = out.items, .inks = inks.items, .shows = shows, .text = text };
}
/// When `name` came to point at `addr`: the moment its value last
diff --git a/anim/src/root.zig b/anim/src/root.zig
index e289641..7e4206a 100644
--- a/anim/src/root.zig
+++ b/anim/src/root.zig
@@ -35,6 +35,8 @@ const contexts = @import("context.zig");
pub const Registers = contexts.Registers;
pub const Stack = contexts.Stack;
pub const Backtrace = contexts.Backtrace;
+/// A panel's `Ui` at its box on the stage now (in a dive, on its way out of its window on the map).
+pub const panelAt = contexts.at;
/// The registers' tag: what an address's ink says.
pub const contextLegend = contexts.legend;
pub const disasm = @import("disasm.zig");
@@ -275,15 +277,17 @@ pub fn context(s: *anim.Frame, cursor_: Cursor, options: Context.Options) Contex
var at = cursor_;
at.levels.crossings = options.syscalls;
// The map first: while it fills the frame or falls to the minimap it is under the panels diving out of it.
- const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0)), .frame = stage, .t = s.value(map.diving.land + map.diving.still), .cursor = at });
+ const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0, .{ at.first, at.last })), .frame = stage, .t = s.value(map.diving.land + map.diving.still), .cursor = at });
whole.obj = s.custom(whole, .{ .x = -640, .y = -360, .scale = ui.scale });
whole.add(s, Source{ .cursor = at, .stage = whole.stage, .descent = options.descent });
+ whole.add(s, Source{ .cursor = at, .stage = whole.stage, .descent = options.descent, .part = .source_more });
if (options.descent) whole.add(s, Descent{ .cursor = at, .stage = whole.stage }) else whole.add(s, Disasm{ .cursor = at, .stage = whole.stage });
whole.add(s, Registers{ .cursor = at, .stage = whole.stage, .syscalls = options.syscalls, .quiet = options.quiet });
whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above });
// The stack goes on in the rest of the memory's column, from where its own column ends.
whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above - @as(i32, @intCast(theme.layout.rowsIn(whole.stage.first.stack.h))), .part = .more });
whole.add(s, Backtrace{ .cursor = at, .stage = whole.stage });
+ whole.add(s, map.Spare{ .cursor = at, .stage = whole.stage, .map = whole });
return .{
.stage = stage,
.map = whole,
diff --git a/anim/src/rows.zig b/anim/src/rows.zig
index 69aa62b..a125b05 100644
--- a/anim/src/rows.zig
+++ b/anim/src/rows.zig
@@ -205,25 +205,46 @@ pub const flags = [_]Flag{ .{ .name = "CF", .bit = 0 }, .{ .name = "PF", .bit =
/// flag, and how much of the corner shows); read, framed (`read`: a bit per
/// flag, while a conditional reads them: an echo of the row that set them,
/// `read_shows` how much). The value of eflags is not drawn: the names are the value.
-pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags: u64, changed: u64, held: f32, fire: f32, read: u64, read_shows: f32) void {
+pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags: u64, changed: u64, held: f32, fire: f32, read: u64, read_shows: f32, was: ?RipWas) void {
const gold = theme.mark(.current);
u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, theme.metric.plaque.rip, fire);
u.text(.mono_bold, size, m.side, baseline(y), "rip", gold.on_solid);
const fl = theme.metric.flags;
var x = w - m.side - @as(f32, flags.len) * fl.pitch + 10;
- _ = chain(u, m.chain_x, y, moment, pc, x - 16, .{});
+ // Where execution is changes with the advance: the old value goes as the new one comes, over it.
+ const before = was orelse RipWas{ .moment = moment, .pc = pc, .eflags = eflags };
+ if (before.pc != pc and before.going < 1) {
+ _ = chain(u.faded(1 - before.going), m.chain_x, y, before.moment, before.pc, x - 16, .{});
+ _ = chain(u.faded(before.going), m.chain_x, y, moment, pc, x - 16, .{});
+ } else _ = chain(u, m.chain_x, y, moment, pc, x - 16, .{});
for (flags) |flag| {
const set = eflags >> flag.bit & 1 != 0;
- if (set) {
- u.chip(.{ .x = x, .y = y + 2, .w = fl.chip[0], .h = fl.chip[1] });
- u.text(.mono_bold, size, x + 4, baseline(y), flag.name, t.bright);
- } else u.text(.mono, size, x + 4, baseline(y), u.print("{c}{c}", .{ std.ascii.toLower(flag.name[0]), std.ascii.toLower(flag.name[1]) }), ui.mix(t.dim, gold.ember, 0.2));
+ // A flag the step sets or clears crossfades as it lands (`flip`).
+ if (set != (before.eflags >> flag.bit & 1 != 0) and before.flip < 1) {
+ ripFlag(u.faded(1 - before.flip), x, y, flag, !set);
+ ripFlag(u.faded(before.flip), x, y, flag, set);
+ } else ripFlag(u, x, y, flag, set);
if (changed >> flag.bit & 1 != 0) u.corner(x, y + 2, m.corner, held);
if (read >> flag.bit & 1 != 0 and read_shows > 0) u.read(.{ .x = x, .y = y + 2, .w = fl.chip[0], .h = fl.chip[1] }, read_shows);
x += fl.pitch;
}
}
+/// rip's row as it was before the step: its value, going to the new one
+/// `going` of the way (the advance), and the flags, `flip` of the way.
+pub const RipWas = struct { moment: Recording.Moment, pc: u64, eflags: u64, going: f32 = 1, flip: f32 = 1 };
+
+fn ripFlag(u: ui.Ui, x: f32, y: f32, flag: Flag, set: bool) void {
+ const fl = theme.metric.flags;
+ if (set) {
+ u.chip(.{ .x = x, .y = y + 2, .w = fl.chip[0], .h = fl.chip[1] });
+ u.text(.mono_bold, size, x + 4, baseline(y), flag.name, t.bright);
+ } else u.text(.mono, size, x + 4, baseline(y), u.print("{c}{c}", .{ std.ascii.toLower(flag.name[0]), std.ascii.toLower(flag.name[1]) }), ui.mix(t.dim, theme.mark(.current).ember, 0.2));
+}
+
+/// A slot's role as it was before the step, and how far (0 to 1) the role it has now has come in over it.
+pub const Role = struct { name: []const u8, local: bool = false, going: f32 = 1, from_rsp: ?i64 = null };
+
/// `slot`: a word of the stack: a lane to 112 for `row` pins (`pins`, the
/// registers that hold its address); its offset from rsp (`from_rsp`
/// bytes), hex, faint, ranged right to 172 (`+18`, `-8` above rsp); its
@@ -232,19 +253,28 @@ pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags:
/// recording knows it: `saved rbp` dim, a `local`'s name primary), ranged right where the room ends
/// (136 from the right edge `w`: the `call` spans'), the chain ending a
/// character before it.
-pub fn slot(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, addr: u64, from_rsp: i64, pins: []const []const u8, pin_shows: f32, marks: Marks, role: []const u8, local: bool) Hops {
+pub fn slot(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, addr: u64, from_rsp: i64, pins: []const []const u8, pin_shows: f32, marks: Marks, role: []const u8, local: bool, was: ?Role) Hops {
const s = theme.metric.slot;
if (pins.len > 0 and pin_shows > 0) u.faded(pin_shows).pinRow(s.lane, y, pins, theme.color.region.stack);
- offset(u, y, from_rsp);
+ // An offset that changes with rsp (the window held, or moved by more than the slide) crossfades as a role does.
+ if (was) |o| if (o.from_rsp) |old| if (old != from_rsp and o.going < 1) {
+ offset(u.faded(1 - o.going), y, old);
+ offset(u.faded(o.going), y, from_rsp);
+ } else offset(u, y, from_rsp) else offset(u, y, from_rsp) else offset(u, y, from_rsp);
var lead = marks;
lead.first = .none;
const base = baseline(y);
const end = u.address(s.address, base, addr, .{ .ink = ui.rgb(theme.color.region.stack), .lead = marks.lead });
var room = w - s.room;
- if (role.len > 0) {
- const rx = room - u.width(.mono, size, role);
- u.text(.mono, size, rx, base, role, if (local) t.primary else t.dim);
- room = rx - adv;
+ // A role that changes in place (the step makes the word another's) crossfades, `was.going` of the way.
+ const before = was orelse Role{ .name = role, .local = local };
+ const changes = !std.mem.eql(u8, before.name, role) or before.local != local;
+ const right = room;
+ for ([2]Role{ before, .{ .name = role, .local = local } }, [2]f32{ if (changes) 1 - before.going else 0, if (changes) before.going else 1 }) |r, shows| {
+ if (r.name.len == 0 or shows <= 0) continue;
+ const rx = right - u.width(.mono, size, r.name);
+ u.faded(shows).text(.mono, size, rx, base, r.name, if (r.local) t.primary else t.dim);
+ room = @min(room, rx - adv);
}
const held = (Recording.word(moment, addr, 8) catch null) orelse {
_ = u.arrow(end, y + row_h / 2, .points);
@@ -299,8 +329,18 @@ pub fn spanNameX(u: ui.Ui, w: f32, name: []const u8) f32 {
/// primary), file and line ranged right, dim. A name cut only where the
/// arguments begin, saying so.
pub fn callRow(u: ui.Ui, y: f32, w: f32, n: usize, name: []const u8, args: []const u8, where: []const u8, newest: bool) void {
+ if (newest) callCurrent(u, y, w);
+ callLabels(u, y, w, n, name, args, where, newest);
+}
+
+/// The newest call's wash and plaque, apart from its words: for a row that becomes or stops being the newest.
+pub fn callCurrent(u: ui.Ui, y: f32, w: f32) void {
+ u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, 40, 0);
+}
+
+/// A `call` row's words, apart from its wash: for one whose words crossfade.
+pub fn callLabels(u: ui.Ui, y: f32, w: f32, n: usize, name: []const u8, args: []const u8, where: []const u8, newest: bool) void {
const gold = theme.mark(.current);
- if (newest) u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, 40, 0);
u.text(if (newest) .mono_bold else .mono, size, m.side, baseline(y), u.print("#{d}", .{n}), if (newest) gold.on_solid else t.faint);
const where_x = w - m.side - u.width(.mono, size, where);
const args_x: f32 = 384;
@@ -515,10 +555,11 @@ pub const Arcs = struct {
/// Nested spans take separate lanes, the longest outermost; spans that
/// do not overlap share one; past `lanes` the step's come first, then
- /// the shorter, and the rest are only read.
+ /// the shorter, and the rest are only read. A lane change glides: while
+ /// an arc draws or fades (12 f), the others go from the lanes they have
+ /// without it to those they have with it, as far as it has drawn or shows.
pub fn draw(a: *Arcs, u: ui.Ui, lanes: usize) void {
const k = theme.metric.arc;
- const Span = struct { lo: f32, hi: f32, y0: f32, y1: f32, i: usize };
var spans: [32]Span = undefined;
for (a.items[0..a.n], spans[0..a.n], 0..) |arc, *sp, i| {
const up = arc.to < arc.from;
@@ -536,11 +577,35 @@ pub const Arcs = struct {
return x.hi - x.lo > y.hi - y.lo;
}
}.longer);
+ // Arriving or leaving: how far (the least of them), and the lanes without them.
+ var settled: f32 = 1;
+ for (a.items[0..a.n]) |arc| settled = @min(settled, @min(arc.drawn, arc.shows));
+ const with = a.assign(spans[0..a.n], lanes, false);
+ const without = if (settled < 1) a.assign(spans[0..a.n], lanes, true) else with;
+ for (spans[0..a.n]) |sp| {
+ const arc = a.items[sp.i];
+ const lane = with[sp.i] orelse continue;
+ const was = without[sp.i] orelse lane;
+ const x = std.math.lerp(k.lanes[was], k.lanes[lane], cursorGlide(settled));
+ const shade = ui.mix(arc.ink, theme.color.page, k.standing * (1 - std.math.clamp(arc.full, 0, 1)));
+ const v = u.faded(arc.shows);
+ if (arc.stub) {
+ v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed });
+ } else v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 }, .{ k.in, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed });
+ }
+ }
+
+ const Span = struct { lo: f32, hi: f32, y0: f32, y1: f32, i: usize };
+
+ /// Each span's lane (`spans` longest first), the step's first; `settled`:
+ /// only of the arcs neither drawing nor fading (those keep their lane in full).
+ fn assign(a: *const Arcs, spans: []const Span, lanes: usize, settled: bool) [32]?usize {
var taken: [3][32][2]f32 = undefined;
var counts = [3]usize{ 0, 0, 0 };
var lane_of: [32]?usize = @splat(null);
- for ([_]bool{ true, false }) |hot| for (spans[0..a.n]) |sp| {
- if (a.items[sp.i].hot != hot) continue;
+ for ([_]bool{ true, false }) |hot| for (spans) |sp| {
+ const arc = a.items[sp.i];
+ if (arc.hot != hot or (settled and (arc.drawn < 1 or arc.shows < 1))) continue;
lane_of[sp.i] = for (0..@min(lanes, 3)) |l| {
const clear = for (taken[l][0..counts[l]]) |t2| {
if (!(sp.hi < t2[0] or sp.lo > t2[1])) break false;
@@ -552,16 +617,11 @@ pub const Arcs = struct {
}
} else null;
};
- for (spans[0..a.n]) |sp| {
- const arc = a.items[sp.i];
- const lane = lane_of[sp.i] orelse continue;
- const x = k.lanes[lane];
- const shade = ui.mix(arc.ink, theme.color.page, k.standing * (1 - std.math.clamp(arc.full, 0, 1)));
- const v = u.faded(arc.shows);
- if (arc.stub) {
- v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed });
- } else v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 }, .{ k.in, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed });
- }
+ return lane_of;
+ }
+
+ fn cursorGlide(p: f32) f32 {
+ return theme.ease(.glide, std.math.clamp(p, 0, 1));
}
};
diff --git a/anim/src/source.zig b/anim/src/source.zig
index 3843825..0705f5b 100644
--- a/anim/src/source.zig
+++ b/anim/src/source.zig
@@ -32,21 +32,29 @@ pub const Source = struct {
/// In a `descent`: while the pc is in code without source, the line it
/// called from waits, ringed, and the tag says where the pc is.
descent: bool = false,
+ /// Which box of its stage it is in: on the map the source may go on in `source_more`.
+ part: @import("stage.zig").Part = .source,
pub fn draw(p: *const Source, f: *sk.Frame, placed: anim.Placed) void {
- const box = p.stage.box(placed, .source);
+ const box = p.stage.box(placed, p.part);
+ if (box.h < m.tag + m.row) return;
const u = context.at(f, placed, box);
const rec = p.cursor.rec;
const now = p.cursor.now(placed);
const text = prepared(rec.source, rec.file) orelse return;
+ // Its window, and on the map the lines of both its boxes (`continued`): this one from `skip` lines in.
+ const head = theme.layout.rowsIn(p.stage.box(placed, .source).h);
+ const tail = theme.layout.rowsIn(p.stage.box(placed, .source_more).h);
const fit: u32 = @intCast(theme.layout.rowsIn(box.h));
+ const span_fit: u32 = @intCast(head + tail);
+ const skip: f32 = if (p.part == .source_more) @floatFromInt(head) else 0;
// The mark: leaving the line of one moment for that of the next.
const was = rec.own[now.marks[0]];
const here = rec.own[now.marks[1]];
// The window: where the line it is on has it, and (as the mark
// moves on) gliding to where the next one does. It never cuts.
const going = now.advancing();
- const windows = [2]f32{ @floatFromInt(rec.viewFirst(fit, was)), @floatFromInt(rec.viewFirst(fit, here)) };
+ const windows = [2]f32{ @as(f32, @floatFromInt(rec.viewFirst(span_fit, was))) + skip, @as(f32, @floatFromInt(rec.viewFirst(span_fit, here))) + skip };
// Farther than its own height (another function far off): what
// leaves has left before what replaces it arrives; a scroll of more
// lines than the window shows would be a blur, and say nothing.
@@ -64,9 +72,9 @@ pub const Source = struct {
var notes: [2][]const u8 = undefined;
for (now.marks, &notes) |mk, *note| note.* = if (p.descent and !rec.sourced(mk) and rec.own[mk] != 0) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(firstOwn(rec, mk), "rip")), rec.own[mk], whereIs(u, rec, mk) }) else lines_note;
const swap = !std.mem.eql(u8, notes[0], notes[1]) and (notes[0].ptr != lines_note.ptr or notes[1].ptr != lines_note.ptr) and now.walking();
- const body = u.panel(box.w, box.h, rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note });
+ const body = u.panel(box.w, box.h, if (p.part == .source_more) u.print("{s}, continued", .{rec.file}) else rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note });
if (swap) {
- const c = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ const c = now.renaming();
u.faded(1 - c).tagNote(box.w, notes[0]);
u.faded(c).tagNote(box.w, notes[1]);
}
@@ -109,28 +117,40 @@ pub const Source = struct {
} else if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line + widen, now.fires(.source));
if (shows >= 1 and mark_y >= body.y and mark_y + m.row <= box.h) ties.anchor(u, .source, .{ .x = 0, .y = mark_y, .w = box.w, .h = m.row });
- // The trail: the last three other lines it was on. It shifts without animation.
- const on_line = rec.own[now.marked()];
- var trail: [3]u32 = @splat(0);
- var found: usize = 0;
- var back = now.marked();
- while (back > 0 and found < trail.len) {
- back -= 1;
- const l = rec.own[back];
- if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found], l) != null) continue;
- trail[found] = l;
- found += 1;
+ // The trail: the last three other lines it was on, as the mark left
+ // them and as it finds them: a bar that moves crossfades with the advance.
+ var trails: [2][3]u32 = @splat(@splat(0));
+ var founds = [2]usize{ 0, 0 };
+ for (now.marks, &trails, &founds) |mk, *trail, *found| {
+ const on_line = rec.own[mk];
+ var back = mk;
+ while (back > 0 and found.* < trail.len) {
+ back -= 1;
+ const l = rec.own[back];
+ if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found.*], l) != null) continue;
+ trail[found.*] = l;
+ found.* += 1;
+ }
}
- map.window(.source, shown_first, @min(shown_first + fit - 1, rec.line_count));
+ const lines_of = struct {
+ fn of(at: f32, n: u32, lines: u32) [2]u64 {
+ const a: u32 = @intFromFloat(at);
+ return .{ a, @min(a + n - 1, lines) };
+ }
+ }.of;
+ map.window(.source, lines_of(windows[1], fit, rec.line_count), lines_of(windows[0], fit, rec.line_count), cursors.glide(going));
var line = @max(from, 1);
while (line <= last) : (line += 1) {
const y = top + (@as(f32, @floatFromInt(line)) - first) * m.row;
map.row(.source, line, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
const span = text.lines[line - 1];
- const k = std.mem.indexOfScalar(u32, trail[0..found], line);
+ const ks = [2]?usize{ std.mem.indexOfScalar(u32, trails[0][0..founds[0]], line), std.mem.indexOfScalar(u32, trails[1][0..founds[1]], line) };
+ const k = if (going >= 0.5) ks[1] else ks[0];
const on = shows >= 0.5 and line == mark_line;
- rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (k) |n| .{ .trail = n } else .plain);
+ const fading = !std.meta.eql(ks[0], ks[1]) and going > 0 and going < 1;
+ rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (fading) .plain else if (k) |n| .{ .trail = n } else .plain);
+ if (fading and !(on and !waits)) for (ks, [2]f32{ 1 - going, going }) |kk, amount| if (kk) |n| lit.faded(amount).trail(theme.stroke.rule, y, n);
}
// The source is read at a run; at a sprint it is veiled too.
context.veiled(u, box, now.sprint_veil);
diff --git a/anim/src/stage.zig b/anim/src/stage.zig
index a24ec28..35988aa 100644
--- a/anim/src/stage.zig
+++ b/anim/src/stage.zig
@@ -10,7 +10,7 @@ const theme = ui.theme;
const Split = theme.layout.Split;
const Rect = theme.Rect;
-pub const Part = enum { band, view, source, disasm, registers, stack, backtrace, more };
+pub const Part = enum { band, view, source, disasm, registers, stack, backtrace, more, source_more };
pub const Stage = struct {
first: Split,
diff --git a/anim/src/theme.zig b/anim/src/theme.zig
index 78c1d7d..cb52287 100644
--- a/anim/src/theme.zig
+++ b/anim/src/theme.zig
@@ -111,6 +111,12 @@ pub const layout = struct {
dump_rows: u32,
/// On the map: the rest of a column, where the stack goes on (`continued`).
more: Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
+ /// On the map: the source going on, `continued`, where its column cannot hold it.
+ source_more: Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
+ /// On the map: the rest of the first two columns (under the backtrace,
+ /// under the disassembly), given to the dumps round what the registers
+ /// and the stack point at, the loupes open and the key (`map.Spare`).
+ spare: [2]Rect = @splat(.{ .x = 0, .y = 0, .w = 0, .h = 0 }),
};
pub const split = struct {
/// The machine alone: fourteen lines over seventeen instructions;
@@ -971,6 +977,9 @@ pub const time = struct {
/// The minimap follows the frame this far behind: secondary action, it
/// never starts on a primary onset's frame.
pub const minimap_lag = 6.0 / 60.0;
+ /// And every change on it fades in over this many frames, a frame apart
+ /// from the lag: it is drawn this many times, each a frame later, averaged.
+ pub const minimap_fade = 6;
/// A hurried step with this long or more is still a whole sentence,
/// said faster; with less, it is a run.
pub const walk_least = 0.70;
diff --git a/anim/src/ties.zig b/anim/src/ties.zig
index d3a9ec7..e25c34b 100644
--- a/anim/src/ties.zig
+++ b/anim/src/ties.zig
@@ -139,7 +139,11 @@ pub fn pinShows(now: cursors.Now, i: usize, target: enum { slot, node }) struct
if (now.registerAge(i) != 0) return .{ .old = 1, .new = 1 };
if (now.resting()) return .{ .old = 0, .new = 1 };
const since = linkSince(now, i);
- if (!now.walking()) return if (since >= 0) .{ .old = 0, .new = 1 } else .{ .old = 1, .new = 0 };
+ // At a run the pin changes with the run's ease (8 f), never in a frame.
+ if (!now.walking()) {
+ const p = std.math.clamp(since / time.run_ease, 0, 1);
+ return .{ .old = 1 - p, .new = p };
+ }
const l = time.link;
const arrives = l.after + linkTime(if (target == .slot) .slot else .node);
return .{
@@ -180,8 +184,9 @@ pub const Ties = struct {
defer stack_window = null;
defer thread_waits = false;
const now = g.cursor.now(at);
- // Diving or surfacing, the panels are on their way: no ties.
+ // Diving or surfacing, the panels are on their way: no ties; nor while the map alone is looked at.
for (@import("context.zig").zoomed) |z| if (z != null) return;
+ if (@import("map.zig").looking(f)) return;
// In canvas pixels, `k` of them a unit: places come from panels anywhere.
var raw: ui.Ui = .{ .f = f, .at = at };
raw.at.xf = .identity;
diff --git a/anim/src/words.zig b/anim/src/words.zig
index 280abbc..4d221f4 100644
--- a/anim/src/words.zig
+++ b/anim/src/words.zig
@@ -69,6 +69,7 @@ pub const Clock = struct {
u.faded(now.hurried).text(.mono, size, count_x - u.width(.mono, size, steps) - 3 * ui.advance(size), base, steps, t.dim);
}
if (k.map) |m| {
+ if (@import("map.zig").looking(f)) return m.wholeMap(f, at);
m.fallingOver(f, at);
@import("map.zig").minimap(m, f, at);
}
diff --git a/anim/test/gallery/atoms.png b/anim/test/gallery/atoms.png
index e18052b..3bfd6ec 100644
--- a/anim/test/gallery/atoms.png
+++ b/anim/test/gallery/atoms.png
Binary files differ
diff --git a/anim/test/gallery/loupe.png b/anim/test/gallery/loupe.png
index 8b63c1d..7661f53 100644
--- a/anim/test/gallery/loupe.png
+++ b/anim/test/gallery/loupe.png
Binary files differ
diff --git a/anim/test/gallery/none.png b/anim/test/gallery/none.png
index b850f99..8abce55 100644
--- a/anim/test/gallery/none.png
+++ b/anim/test/gallery/none.png
Binary files differ
diff --git a/anim/test/gallery/rest.png b/anim/test/gallery/rest.png
index f2869e4..61829aa 100644
--- a/anim/test/gallery/rest.png
+++ b/anim/test/gallery/rest.png
Binary files differ
diff --git a/anim/test/gallery/rows.png b/anim/test/gallery/rows.png
index de8580b..2d11a94 100644
--- a/anim/test/gallery/rows.png
+++ b/anim/test/gallery/rows.png
Binary files differ
diff --git a/anim/test/gallery/step.png b/anim/test/gallery/step.png
index 8f80f5f..232b235 100644
--- a/anim/test/gallery/step.png
+++ b/anim/test/gallery/step.png
Binary files differ
diff --git a/anim/test/gallery/subject.png b/anim/test/gallery/subject.png
index b779060..1175df7 100644
--- a/anim/test/gallery/subject.png
+++ b/anim/test/gallery/subject.png
Binary files differ
diff --git a/anim/tools/chart.py b/anim/tools/chart.py
index 720e356..320ba90 100644
--- a/anim/tools/chart.py
+++ b/anim/tools/chart.py
@@ -57,6 +57,10 @@ motion.REGIONS.update({
"zoom": {**none, **words},
"gallery": {**beside, **words},
})
+# `cut`: the gallery is the catalogue's pages, cut from one to the next (scenes/gallery.zig: 1, 2, 3.6, 6, 8 and
+# 10.8 s), not a scene: a page's first frame changes everything at once by design.
+PAGES = {60, 120, 216, 360, 480, 648}
+motion.EXEMPT["cut"] = lambda name, t, moved: lint.scene == "gallery" and any(abs(t - p) <= 1 for p in PAGES)
_regions_for = motion.regions_for
scene = lambda video: os.path.basename(video).split("-")[0].split(".")[0]
motion.regions_for = lambda video, name: _regions_for(video, name or scene(video))
@@ -84,8 +88,17 @@ def shown(text):
text = re.sub(r"\\(.)", r"\1", text.replace("\\n", ""))
return len(text.replace("`", ""))
+# A scene that opens on the map dives (scenes/list.zig: at 2.5 s, 150 f): the falling map passes under the
+# caption, which does not change. Its frames are no caption's arrival or leaving.
+DIVES = {"list": (150, 300)}
+
_lint = motion.lint
def lint(names, counts, soft, sizes, fps, ev):
+ if lint.scene in DIVES and "caption" in names:
+ a, b = DIVES[lint.scene]
+ counts, soft = counts.copy(), soft.copy()
+ counts[a:b, names.index("caption")] = 0
+ soft[a:b, names.index("caption")] = 0
out = [line for line in _lint(names, counts, soft, sizes, fps, ev) if line != " none"]
said = captions(lint.scene) if lint.scene else None
cap = names.index("caption") if "caption" in names else None
diff --git a/design/motion/motion.py b/design/motion/motion.py
index d192295..66571be 100644
--- a/design/motion/motion.py
+++ b/design/motion/motion.py
@@ -189,6 +189,22 @@ def report(video, names, counts, soft, sizes, fps):
WORDS = ("head", "caption", "clock", "minimap") # regions that are not panels
+# One-frame changes that are right, by name: each a test of (region, frame, pixels moved there) that says
+# whether the POP at that frame is one of its kind. They are counted apart, never silently dropped.
+# `keyframe`: the encoder's, not the scene's: a few pixels of a still region re-quantized at an I frame.
+KEYFRAMES = set() # the video's I frames (cmd_chart reads them)
+EXEMPT = {"keyframe": lambda name, t, moved: t in KEYFRAMES and moved < 200}
+
+
+def keyframes(video):
+ out = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-skip_frame", "nokey", "-show_entries",
+ "frame=pts", "-of", "csv=p=0", video], capture_output=True, text=True, check=True)
+ fps, _ = probe(video)
+ tb = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=time_base",
+ "-of", "csv=p=0", video], capture_output=True, text=True, check=True).stdout.strip().split("/")
+ per = fps * int(tb[0]) / int(tb[1])
+ return {int(round(int(line) * per)) for line in out.stdout.split() if line.strip().lstrip("-").isdigit()}
+
def lint(names, counts, soft, sizes, fps, ev):
"""What a viewer would trip on, found by rule. Each line: what, how often, the first few times."""
@@ -200,17 +216,29 @@ def lint(names, counts, soft, sizes, fps, ev):
# POP: a region still for STILL frames changes in one frame and is still again, at any size: a label
# swapped, a box gone, a count appearing. Nothing eased it. (And, as before, a large change in two.)
- pops = {e["from"] for e in ev if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002}
+ pops, exempt = set(), {}
+ for e in ev:
+ if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002:
+ kind = next((n_ for n_, test in EXEMPT.items() if test("all", e["from"], e["peak"])), None)
+ exempt.setdefault(kind, set()).add(e["from"]) if kind else pops.add(e["from"])
for k in range(1, len(names)):
if names[k] == "clock": # its count changes in a frame by design: it is time, not a thing
continue
col = on[:, k]
for t in range(STILL, len(col) - 1):
if col[t] and not col[t + 1] and not col[t - STILL:t].any() and counts[t, k] >= MIN_PX:
- pops.add(t)
+ kind = next((n_ for n_, test in EXEMPT.items() if test(names[k], t, counts[t, k])), None)
+ if kind:
+ exempt.setdefault(kind, set()).add(t)
+ else:
+ pops.add(t)
pops = sorted(pops)
if pops:
out.append(f" POP {len(pops):3d} a change in one frame after stillness: {some([t / fps for t in pops])}")
+ for kind, ts in sorted(exempt.items()):
+ ts = sorted(ts - set(pops))
+ if ts:
+ out.append(f" POP exempt {len(ts):3d} {kind}: {some([t / fps for t in ts])}")
# CROWD: three or more panels begin to move within two frames of each other.
crowd = []
@@ -249,7 +277,8 @@ def lint(names, counts, soft, sizes, fps, ev):
longs.append(b / fps)
elif 6 < up < 90: # 6: a caption leaving and the next arriving
shorts.append(b / fps)
- later = np.nonzero(on[b + 1:, panels].any(axis=1))[0]
+ later = [i for i in np.nonzero(on[b + 1:, panels].any(axis=1))[0]
+ if not ({b + 1 + i, b + i} & KEYFRAMES and counts[b + 1 + i, panels].max() < 200)] # the encoder's (an I frame and the one after it), not the picture's
if len(later) and later[0] < 60 and up >= 90:
late.append(b / fps)
for what, times in (("up over 720 f (12 s)", longs), ("up under 90 f", shorts),
@@ -315,6 +344,8 @@ def chart(video, names, counts, soft, sizes, fps, ev, path, per_row=10.0):
def cmd_chart(a):
fps, _ = probe(a.video)
+ KEYFRAMES.clear()
+ KEYFRAMES.update(keyframes(a.video))
regions = regions_for(a.video, a.regions)
names, counts, soft, sizes = measure(a.video, regions)
ev, text = report(a.video, names, counts, soft, sizes, fps)
diff --git a/src/trace/Debugger.zig b/src/trace/Debugger.zig
index 886b0fc..971b50b 100644
--- a/src/trace/Debugger.zig
+++ b/src/trace/Debugger.zig
@@ -253,7 +253,7 @@ pub fn step(d: *Debugger) !Stop {
var stop = try d.stepOne();
if (stop == .step and d.proc.tid == tid) {
if (d.lineAt(d.regs.rip)) |here| {
- if (from == null or from.?.key != here.key or from.?.line != here.line) return d.report(.step);
+ if (from == null or from.?.key != here.key or from.?.line != here.line or d.breakpointAt(d.regs.rip) != null) return d.report(.step);
continue;
}
// In code without lines. A call there from code with lines