diff options
32 files changed, 762 insertions, 336 deletions
diff --git a/anim/README.md b/anim/README.md index f4a5a2b..cffb7aa 100644 --- a/anim/README.md +++ b/anim/README.md @@ -11,7 +11,7 @@ a block of the catalogue is a function or a component of the same name here. zig build record # the recordings, into zig-out/recordings zig build run -Dscene=fib # a scene in a window, hot reload (zig build lib --watch) zig build export -Dscene=fib -- DIR --fps 60 --size 1920x1080 # frames as PNGs (or - for raw RGBA) -zig build videos -Doptimize=ReleaseFast # every scene: out/NAME-1080.mp4 and out/NAME-2160.mp4 (x264, 60 fps) +zig build videos -Doptimize=ReleaseFast # every scene: out/NAME-1080.mp4 and out/NAME-2160.mp4 (x264, 60 fps, aq-mode=0) zig build test # unit tests, each scene run headless, and the gallery against its pictures zig build gallery # the gallery's pictures drawn anew into test/gallery zig build bench # what a recording costs a frame @@ -72,7 +72,11 @@ before (after the last of its registers, which strike 6 f apart), in the order C the step did not touch, or touched nothing drawn, gives up its slot; a drawing made of bytes strikes when the projection from them arrives, 24 f after them, and its write 12 f later still; a call's node when the -projection from its return address does, 36 f after); the writes of one step strike 6 f apart; a hold to read; the +projection from its return address does, 36 f after); the writes of one step strike 6 f apart (those that take a +place: not a stack frame the step has already left, a callee's words under rsp), each keeping its old value through +its arm until its own strike lands (s+3: `Now.struckAgo`, `shownAt`; what the kernel fills, once the last byte of the +word lands); a register's chain reads memory as the panels show it: from the bytes' strike its later hops fade +out (3 f), and 4 f after they land they are followed again (`extend`, `Now.following`); a hold to read; the mark advances last; a rest. `walk` plays steps in full, `hurry` ramps the pace down and up again (each step 0.6 of the one before) to a run (0.30 s a step: nothing struck, no held corner, no arc, a dump's values crossfading @@ -91,15 +95,15 @@ on a primary onset's frame and nothing on it changes in one. | Scene | Shows | Split, lens | Recording | | --- | --- | --- | --- | -| `title` | the series and the legend of marks | a card | | +| `title` | the series (six programs, named) and the legend of the marks the scenes use | a card | | | `fib` | recursion: each call a frame and a node | `subject`, `calls` | `steps` | | `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; 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` | +| `zoom` | one line of C as its instructions, the call's bytes | `none`, the camera at x1.16 on the instructions and the stack in one view, cause and effect (the stack's window set before the move and held); 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`; as the caption names them, rdi's `BtCursor` opened in a loupe, then rsi linked to its row in the view (`Context.tiesWith`); the page's fields named a group at a time, 2 s apart; the backtrace lens drawn on its map | `sqlite` | +| `gallery` | every block in its states, a page or a state each 3 s | all three | `gallery` | ## The blocks @@ -109,19 +113,19 @@ every state the code has in the `gallery` scene. | Layer | Block | Where | Notes | | --- | --- | --- | --- | | 0 tokens | grid, colour, type, the splits | `src/theme.zig` | per "Token changes" (`metric.calls`, `time.pin`, `time.continue_wave`, `time.relayout_fade` there; the insn's character counts gone); JetBrains Mono NL (`.code*` faces) for all mono, Medium under 30 | -| 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 | +| 1 atom | `address` (`lead`, `name`, `rwx`), `value` (and `Ui.typed`: `fd`, `bool`, `char`), `arrow` (`points`, `holds`, `more`), `mark`s, `plaque` (`chip`), `pin` (`row`, `under`; and at a view's row's end, `Ui.pinEnd`), `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); until its strike lands (s+3) a run keeps its old bytes and their reading, through the arm, read by its old field where the step retypes it (`hexdump.keepOld`, `Fields.was`) | +| 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`; a register's reads memory as the panels show it, the step's bytes from their strike (s+3): its later hops fade out from the strike and are followed again 4 f after the bytes land (`Now.following`, `Marks.hops`). `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 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` | 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` | +| 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 (12 f each; at a run half its step each), and what it brings, and what changed before it, is plain; while rows slide they keep their roles (those of both windows are read), and a word becoming a saved rbp, or no longer one, has its arc go or come with its role; 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, 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 | +| | 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; the rows make room for it, a full log scrolling a row, 24 f, `glide`, the count above crossfading; out of room a row gives up its faint names first, then its arguments from the right, and keeps what it returned; a path by its string, the kernel's capture where the stop did not read it) 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; a left child's result on its left shoulder, off its parent; a view's row a register points into carries the register's `pin` at the row's end (`hexdump` `rowPin`), the reading ending before it; at a sprint the array's pins hold and move where a phrase ends | +| 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; to a view's row (`dump_pin`) by the left lane, into the row's edge; on a beat the narration names (`Context.tiesWith`, `ties.Beat`): the register framed as read, then its link, held, drawn back with the frame; 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 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` | @@ -179,115 +183,112 @@ that is right is counted apart by name (`POP exempt`), never dropped: 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 +the next (chart.py names their times). The videos are x264 without +adaptive quantization (`aq-mode=0`, 18% larger): with it a still glyph's +edge was re-quantized as the rest of the frame moved, a one-pixel column +flickering in fib's caption band at 7.45 s that the instrument took for an +extra caption (the rendered frames there are identical; with `aq-mode=0` +fib's first 600 frames have no such column). 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. +under the caption, which does not change. | | fib | list | sort | syscalls | zoom | sqlite | heap | gallery | | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| 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 | +| POP, before / after | 14 / 11 | 14 / 13 | 8 / 6 | 26 / 25 | 7 / 11 | 7 / 8 | 21 / 17 | 5 / 8 | +| of them the minimap's, before / after | 5 / 5 | 7 / 6 | 2 / 1 | 16 / 17 | 4 / 6 | 3 / 3 | 9 / 8 | 3 / 4 | +| POP exempt, before / after | | keyframe 3 / | | keyframe 2 / | | keyframe 2 / | | cut 3 / cut 3 | +| CROWD, before / after | 4 / 4 | 8 / 9 | 6 / 7 | 3 / 3 | 3 / 1 | 0 / 1 | 15 / 16 | 4 / 4 | +| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | +| CAPTION up over 720 f, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | +| CAPTION under its reading time, before / after | not paired / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | +| CAPTION picture moving within 60 f, before / after | 1 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | +| AIR, before / after | 0 / 0 | 2 / 0 | 0 / 1 | 2 / 0 | 1 / 1 | 5 / 2 | 0 / 0 | 0 / 1 | +| seconds, before / after | 42.0 / 42.0 | 84.5 / 81.7 | 42.2 / 42.2 | 89.2 / 83.8 | 33.6 / 33.5 | 64.6 / 62.9 | 78.1 / 78.6 | 11.0 / 21.0 | -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: +"Before" is the last pass's "after", measured with x264's adaptive +quantization, whose keyframes re-quantized still regions (the `keyframe` +exemptions, and a still picture broken in two: sort's last 4.6 s, an AIR +now). zoom's POPs grew because its camera now shows the disassembly and +the stack's chains with the stack (annotations taking their value in +place, 18.10 and 19.60 s; offsets crossfading, 12.80 and 16.40 s); +the gallery's because each state is held 3 s and its view re-windows at a +state's first frame (9.00, 12.62, 15.40 s), as before. -- 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. +What this pass fixed at the block (every scene that draws the block gets +it), an effect shown before its cause first, found on the last pass's +exports: + +- A write's bytes took their new value at memory's landing, before their + own arm (any write 6 f or more after the first of its step: sort's first + swap, the heap's first free, its chunk's words and the tcache's header). + Each run now keeps its old bytes, and their reading (by its old field + where the step retypes it), through its arm until its own strike lands + (`hexdump.keepOld`, `Now.shownAt`, a stack word too); a write on a frame + the step has already left (a callee's words under rsp) takes no place + among the strikes, so sort's two elements strike 6 f apart, not on one frame. +- A register's chain read memory as of the stop after the step from the + CPU's strike: rsi's `Hello, k` 2 s before `read` wrote it. It reads it as + the panels show it; its later hops fade out from the bytes' strike and + are followed again 4 f after the word's last byte lands (`Now.following`), + never gone in a frame. +- What a crossing's first part struck had its cool cut as the crossing + began (read, write): the crossing's plan carries the cool on + (`Plan.cooling`); an fd's `"note"` fades in with its framing. +- The list's dive played twice: the minimap's drawings overwrote where the + falling map's windows are, which the panels set off from (`map.minimap` + keeps `window_px`); the thread, which came in a frame at the landing, + fades in after it (`context.thread_shows`). +- A stack window going far at a run faded out in a frame (the 12 f before + memory's strike lie before a run step's start): it fades out and in round + a turn that fits the step (syscalls 56 s). +- Rows sliding out of the stack's window lost their roles (fib 6.50, + `saved rbp`, `saved rbx`), and an arc was drawn from the row above the + window that is there only for a slide: the roles of both windows are + read; arcs join rows on show; a word becoming a saved rbp has its arc go + with its role. +- The system calls' log scrolled a row in a frame as a crossing began + (sqlite 38.67): it scrolls with the row's arrival, its count crossfading. +- sort's source jumped 3 lines at a sprint's phrase end: the mark travels + over the sprint's step. +- Under the camera a free word rsp reached became a slot in a frame (zoom + 19.6 s): it crossfades as memory strikes. +- `changedBytes` read its own result as it wrote it (a Zig result-location + hazard): a strike could cover bytes that kept their value (a Debug build + panicked on it). 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): +What fires still, by kind (located on this pass's 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. +- The minimap (about half of every scene's): a repack of the map (a panel + that wants more rows, a frame behind) lands in one frame for all six + drawings; and a working window's outline, drawn from the frame's own + scroll and not averaged, moving a pixel with a pause where its glide's + sub-pixel steps round alike (syscalls' run through `open`). +- The stack: a few pixels in the arcs' lanes and the pins (fib 8.20, + 19.50, 24.90, 39.13; syscalls 29.13, 57.72, 70.17; sqlite 20.43, 31.75). +- Registers: a held corner, a few pixels at a value's top left (fib 21.10, + sort 14.88, syscalls 44.32, sqlite 38.67). +- The source and the disassembly: syscalls 17.92 and 55.62, the line + going `waiting` and back with the descent's rows; zoom 18.10 and 19.60, + an annotation taking its value in place under the camera. +- The view: syscalls 64.77, the read's first byte landing over the + buffer's dots; the gallery's view re-windowing at a state's first frame. +- The drawing: fib 33.63 the calls tree's badge corner; sort's index pins + sliding where a sprint's phrase ends; the heap's runs (its 16 CROWDs + too: the calls and returns it does not narrate). +- AIR: sort's and zoom's last picture (the last caption read, then held); + sqlite 32.95, after the continue to `unixWrite`, and 46.02, where the + chart misses the read frame on one byte (`0d`) at 47.5 s: the picture is + still 1.5 s and then 2 s; the gallery's atoms page, 3 s by design. - 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; 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`; 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). + the disassembly scrolling with it), the veil over three panels at a + run's first step. ## What is not done @@ -390,8 +391,29 @@ What fires still, by kind (looked at on the exports): stack, `23 rows`, 5.0 s; in a continue a link sets off with memory's strike, when the window is at its new place). One to a slot above the window would put its count over the panel's tag. -- The calls tree's leaf spacing holds for fib(5); past about ten leaves - nodes and badges collide (the catalogue's known case). +- A call's result badge is on its outer shoulder (a left child's left, off + its parent's disc; it lay on the parent, fib 24 s on): in fib(5) none + lies on a node, but two neighbours' badges between their nodes are 4 + units apart (`1][1`). Past about ten leaves nodes and badges collide + (the catalogue's known case). +- A view's row a register points into carries its pin at the row's end, + its head toward the row (`Ui.pinEnd`): the catalogue's `row` pin has no + lane in a dump, whose bracket and address take its first 34 units. The + reading gives way to it (the read buffer's text reads `"Hello, …` while + rsi's pin is on its row; the top's `top` note goes while a register + points into its row), and a link to the row ends at its left edge, not + at the pin. +- The zoom scene's camera goes to x1.16, not the x1.5 decided: the stage + (1792 wide) holds the instructions' mnemonics to the stack's roles at + x1.16; at x1.5 the stack's chains (`fib+42`) and roles (`saved rbp`, `n`) + the captions name fall off its right edge, or the mnemonics off its left; + the stack's call spans are off its right edge at x1.16. +- A working window's outline on the minimap is drawn from the frame's own + scroll, not averaged with the six drawings: a one-pixel scroll there + moves over a few frames with a pause where the glide's sub-pixel steps + round alike (most of syscalls' minimap POPs, in the run through `open`). +- Bytes the recorder merged into one written span (a free's link and key, + stored by two instructions next to each other) strike as one. - The `pages` lens is not in the band (`Timeline` is the old far view). - The map's and minimap's drawing flags (`ui.mapping`, `ui.strokes`, `ui.chrome`), a dive's per-panel transforms (`context.zoomed`), the diff --git a/anim/build.zig b/anim/build.zig index 5601e39..54ff589 100644 --- a/anim/build.zig +++ b/anim/build.zig @@ -304,13 +304,15 @@ pub fn build(b: *std.Build) void { test_step.dependOn(&scene.app.addScript(exe, b.path(b.fmt("test/{s}.script", .{name})), .{}).step); for ([_][]const u8{ "1920x1080", "3840x2160" }) |size| { - // The design's master: x264 from the raw frames, tagged bt709. + // The design's master: x264 from the raw frames, tagged bt709. No + // adaptive quantization: on a still page it re-quantized a glyph's + // edge as the rest of the frame moved, a column flickering (fib 7.45 s). const video = b.addSystemCommand(&.{ "sh", "-c", \\set -e \\mkdir -p out \\"$0" --state "$1" --export - --size "$2" --fps 60 | \\ ffmpeg -loglevel error -y -f rawvideo -pix_fmt rgba -s "$2" -r 60 -i - \ - \\ -c:v libx264 -crf 14 -preset slow -g 600 -pix_fmt yuv420p \ + \\ -c:v libx264 -crf 14 -preset slow -g 600 -x264-params aq-mode=0 -pix_fmt yuv420p \ \\ -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range tv "$3" }); video.addArtifactArg(exe); diff --git a/anim/scenes/gallery.zig b/anim/scenes/gallery.zig index bd363d5..693553e 100644 --- a/anim/scenes/gallery.zig +++ b/anim/scenes/gallery.zig @@ -33,7 +33,8 @@ const Pages = struct { pub fn draw(p: *const Pages, f: *sk.Frame, at: anim.Placed) void { const u: ui.Ui = .{ .f = f, .at = at }; - if (at.t < 1) atoms(u, p) else if (at.t < 2) rowsPage(u, p); + // Each page 3 s: long enough to be looked at. + if (at.t < 3) atoms(u, p) else if (at.t < 6) rowsPage(u, p); } }; @@ -183,12 +184,15 @@ fn atoms(u: ui.Ui, p: *const Pages) void { y = 698; title(u, 64, y, "pin"); - note(u, 140, y, "row; under; a count after three names"); + note(u, 140, y, "row, end; under; a count after three names"); y += 12; u.pinRow(64, y, &.{ "rsp", "rbp" }, region.stack); + // At a view's row's end (a dump has no lane before its addresses). + _ = u.pinEnd(440, y, &.{"rsi"}, region.stack); u.pinRow(64, y + row, &.{ "rax", "rdi", "rsi", "r8" }, region.heap); - u.fill(.{ .x = 400, .y = y - 20, .w = 116, .h = 20 }, theme.color.raised); - u.pinUnder(458, y, &.{ "rax", "rdi" }, region.heap, theme.size.mono.context); + // Clear of the note over it. + u.fill(.{ .x = 520, .y = y - 20, .w = 116, .h = 20 }, theme.color.raised); + u.pinUnder(578, y, &.{ "rax", "rdi" }, region.heap, theme.size.mono.context); y = 698; title(u, 700, y, "bracket"); @@ -322,20 +326,20 @@ fn frame(s: *anim.Frame) void { const joins = ctx.ties(s); const says = canim.caption(s, "The gallery: the frame, at rest. Every panel, the thread,\nthe lens beside it: the list and the bytes it is drawn from."); const panels = .{ ctx.clock, ctx.registers, ctx.stack, ctx.backtrace, ctx.source, ctx.disasm, list, joins, says }; - s.wait(2); + s.wait(6); var all: [panels.len]anim.Animation = undefined; inline for (panels, 0..) |o, i| all[i] = o.fadeIn(); s.play(all, .{ .seconds = 0 }); - // A step at 3 s, its strikes and ties at about 3.6. - s.wait(3 - s.cursor); + // A step at 9 s, its strikes and ties at about 9.6; each state 3 s. + s.wait(9 - s.cursor); at.walk(s, .line, rec.next(.line, rest)); - s.wait(5 - s.cursor); + s.wait(12 - s.cursor); ctx.stage.relayout(s, canim.layout.split.subject); - s.wait(7 - s.cursor); + s.wait(15 - s.cursor); ctx.stage.relayout(s, canim.layout.split.none); - s.wait(9 - s.cursor); + s.wait(18 - s.cursor); near.open(s); - s.wait(9.8 - s.cursor); + s.wait(18.8 - s.cursor); deeper.open(s); - s.wait(11 - s.cursor); + s.wait(21 - s.cursor); } diff --git a/anim/scenes/heap.zig b/anim/scenes/heap.zig index 544ae91..1f82766 100644 --- a/anim/scenes/heap.zig +++ b/anim/scenes/heap.zig @@ -220,7 +220,10 @@ const Lists = struct { 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 r: canim.Rect = .{ .x = xy[0], .y = xy[1], .w = w, .h = h }; - _ = nv.address(r.x + 16, r.y - 8, node, .{ .ink = ui.rgb(theme.color.region.heap) }); + // On its way between the rows its address goes and comes back (the first and last quarter): it never passes over a pin's names. + const travels = s0.row != s1.row or s0.k != s1.k; + const label = if (travels) std.math.clamp(@max(1 - 4 * p, 4 * p - 3), 0, 1) else 1; + _ = nv.faded(label).address(r.x + 16, r.y - 8, node, .{ .ink = ui.rgb(theme.color.region.heap) }); // 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); @@ -346,7 +349,7 @@ const Chunks = struct { // The heap new in this step (the first malloc's): its rows come in, unmarked, over 12 f with memory's slot. const new = !now.resting() and heapAt(f.scratch, c.cursor.rec, now.stops[1]) == null; const comes: f32 = if (new) std.math.clamp(now.since(.memory, 0) / (12.0 / 60.0), 0, 1) else 1; - canim.hexdump.fielded(.{ .u = v.u.faded(comes), .rows = v.rows, .box = v.box }, now, cm.tag + cm.pad, .{ .base = view_base, .len = view_len, .fields = fieldsAt(f.scratch, c.cursor.rec, now.stop(.memory)), .watched = if (new) 0 else std.math.maxInt(usize) }); + canim.hexdump.fielded(.{ .u = v.u.faded(comes), .rows = v.rows, .box = v.box }, now, cm.tag + cm.pad, .{ .base = view_base, .len = view_len, .fields = fieldsAt(f.scratch, c.cursor.rec, now.stop(.memory)), .was = fieldsAt(f.scratch, c.cursor.rec, now.stops[1]), .watched = if (new) 0 else std.math.maxInt(usize), .pins = true }); v.veil(now); } }; diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig index 39d413b..71cdf53 100644 --- a/anim/scenes/list.zig +++ b/anim/scenes/list.zig @@ -57,15 +57,16 @@ fn frame(s: *anim.Frame) void { 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."); + // The loop's caption leads the loop: as long as its step (the rest of the trip has captions of its own). + says.line(s, "`next` remembers the way on,\nbefore `cur->next` is turned round."); at.walk(s, .line, loaded); // A beat of its own: the pointer just loaded is opened, and the one in it. - says.line(s, "`rax` holds `cur->next`: under it opens the heap round that node,\nand from its `next`, one deeper, the node after it."); + says.line(s, "`rax` holds `cur->next`: the heap round that node opens\nunder it, and from its `next`, the node after."); near.open(s); s.wait(t.beat); deeper.open(s); - s.wait(2 * t.beat + t.loupe.open); + // Held while the caption is read: 2 s at most without a change. + s.wait(2.0); deeper.close(s); s.wait(t.stagger * 3); near.close(s); diff --git a/anim/scenes/sqlite.zig b/anim/scenes/sqlite.zig index db0e6d9..e19a7be 100644 --- a/anim/scenes/sqlite.zig +++ b/anim/scenes/sqlite.zig @@ -56,20 +56,22 @@ fn leaf(arena: std.mem.Allocator, page: []const u8) []const Field { std.debug.assert(page[0] == 0x0d); const cells = std.mem.readInt(u16, page[3..5], .big); var out: std.ArrayList(Field) = .empty; + // Read as the caption names them: the page's type, then the rest of its + // header (3 cells), then the cell pointers, then each cell. out.appendSlice(arena, &.{ .{ .at = 0, .len = 1, .mark = 0 }, - .{ .at = 1, .len = 2, .reads = .bytes, .big = true, .mark = 0 }, - .{ .at = 3, .len = 2, .big = true, .mark = 0 }, - .{ .at = 5, .len = 2, .reads = .bytes, .big = true, .mark = 0 }, - .{ .at = 7, .len = 1, .reads = .bytes, .mark = 0 }, + .{ .at = 1, .len = 2, .reads = .bytes, .big = true, .mark = 1 }, + .{ .at = 3, .len = 2, .big = true, .mark = 1 }, + .{ .at = 5, .len = 2, .reads = .bytes, .big = true, .mark = 1 }, + .{ .at = 7, .len = 1, .reads = .bytes, .mark = 1 }, }) catch @panic("OOM"); - for (0..cells) |k| out.append(arena, .{ .at = 8 + 2 * k, .len = 2, .big = true, .mark = 1 }) catch @panic("OOM"); + for (0..cells) |k| out.append(arena, .{ .at = 8 + 2 * k, .len = 2, .big = true, .mark = 2 }) catch @panic("OOM"); for (0..cells) |k| { const at: usize = std.mem.readInt(u16, page[8 + 2 * k ..][0..2], .big); const size = page[at]; const header = page[at + 2]; std.debug.assert(size < 0x80 and page[at + 1] < 0x80 and header == 2); - const mark: u8 = @intCast(2 + k); + const mark: u8 = @intCast(3 + k); out.appendSlice(arena, &.{ .{ .at = at, .len = 1, .reads = .bytes, .mark = mark }, .{ .at = at + 1, .len = 1, .mark = mark }, @@ -135,7 +137,7 @@ fn frame(s: *anim.Frame) void { std.debug.assert(bytes.len == 4096 and bytes[0] == 0x0d and bytes[4] == 3); std.debug.assert(std.mem.eql(u8, bytes[8..14], &.{ 0x0f, 0xf7, 0x0f, 0xef, 0x0f, 0xe6 })); std.debug.assert(rec.register(handed, "rsi") == write.args[1]); - const page_marks = s.new([_]anim.Value{ s.value(0), s.value(0), s.value(0), s.value(0), s.value(0) }); + const page_marks = s.new([_]anim.Value{ s.value(0), s.value(0), s.value(0), s.value(0), s.value(0), s.value(0) }); const page = canim.add(s, canim.hexdump.Dump{ .cursor = at, .stage = ctx.stage, @@ -144,7 +146,9 @@ fn frame(s: *anim.Frame) void { .marks = page_marks, .since = handed, }); - const joins = ctx.ties(s); + // rdi, the table's cursor, opened as the caption names it; rsi, the row, linked to the view's row it points at. + const btcursor = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .register = "rdi" } }); + const joins, const row_link = ctx.tiesWith(s, "rsi", 1.0); var says: canim.Narrator = .{}; const fade = struct { @@ -178,9 +182,17 @@ fn frame(s: *anim.Frame) void { fade.in(s, row); says.line(s, "`sqlite3VdbeExec`, the bytecode's loop, calls the B-tree: `rdi` is\nthe table's cursor, `rsi` the row: rowid 1, a record of 7 bytes."); - // Each field as the caption reaches it: the rowid, then the record's length. + // As the caption names them: rdi's cursor opened under it (a beat of + // its own), then rsi linked to the row; then each field: the rowid, the record's length. + const named = s.cursor; + btcursor.open(s); + row_link.play(s); + s.cursor = named + t.loupe.open + row_link.total(); + btcursor.close(s); + // Spread over the caption's reading: never more than 2 s still. + s.wait(1.4); mark.in(s, row_marks[0]); - s.wait(2 * t.beat); + s.wait(2.0); mark.in(s, row_marks[1]); says.line(s, "Two more continues, the same call: rowid 2, then 3, records\nof 6 and 7 bytes. The rows are in memory, not yet on disk."); @@ -203,16 +215,18 @@ fn frame(s: *anim.Frame) void { const crossing = canim.syscalls.Plan.of(write); at.step(s, back, crossing.step(), crossing.total); - says.line(s, "Page 2 as the kernel took it: `0d`, a table's leaf; 3 cells;\ntheir offsets, `0ff7 0fef 0fe6`, each a row at the page's end."); - mark.in(s, page_marks[0]); - s.wait(3 * t.beat); - mark.in(s, page_marks[1]); - says.line(s, "Each cell: its length, its rowid, the record's header, the text.\n'alpha' went in first and sits last: cells fill from the end."); - mark.out(s, page_marks[0..2]); + // Each field as the caption reaches it, 2 s apart: the picture is never still longer. + says.line(s, "Page 2 as the kernel took it: `0d`, a table's leaf; 3 cells,\nat `0ff7 0fef 0fe6`: each a row at the page's end."); + for (page_marks[0..3], 0..) |v, k| { + s.wait(if (k == 0) 0.4 else 2.0); + mark.in(s, v); + } + says.line(s, "Each cell: its length, rowid, header and text. 'alpha'\nwent in first and sits last: cells fill from the end."); + mark.out(s, page_marks[0..3]); // The rows from the page's end: the first one in, then the next two. - for (page_marks[2..]) |v| { + for (page_marks[3..], 0..) |v, k| { + s.wait(if (k == 0) 0.4 else 2.0); mark.in(s, v); - s.wait(2 * t.beat); } says.close(s); } diff --git a/anim/scenes/syscalls.zig b/anim/scenes/syscalls.zig index 0d39089..e9f0ae5 100644 --- a/anim/scenes/syscalls.zig +++ b/anim/scenes/syscalls.zig @@ -54,12 +54,15 @@ fn frame(s: *anim.Frame) void { says.line(s, "A program cannot open a file itself.\nIt asks the kernel, and waits."); cur.walk(s, .line, rec.lineMoment(6, main.enter)); + // Each caption leads its beat, and is read while it plays: the call's + // caption the line that makes it, the descend's the descend, so that no + // still picture waits out a reading time. + says.line(s, "`main` calls `open` by its stub in the PLT, with \"note\"\nin rdi and O_RDONLY in rsi."); cur.walk(s, .moment, stub - 1); - says.line(s, "`main` calls `open` by its stub in the PLT. The arguments\nare in rdi and rsi: \"note\" and O_RDONLY."); + says.line(s, "The call goes down: main's call waits, ringed;\nthe stub's three rows open under it."); canim.descent.step(cur, s, .moment); s.wait(t.phrase_rest); - says.line(s, "The call went down: main's window keeps its call, ringed,\nand the stub's three rows open under it."); - says.line(s, "The stub's jmp reads open@got, the GOT's slot,\nand goes on to libc's `open`."); + says.line(s, "The stub's jmp reads open@got\nand goes on to libc's `open`."); canim.descent.step(cur, s, .moment); s.wait(t.phrase_rest); // The wrapper at a run, veiled; its last three instructions walked, named as they run. diff --git a/anim/scenes/title.zig b/anim/scenes/title.zig index d5af819..e412bd7 100644 --- a/anim/scenes/title.zig +++ b/anim/scenes/title.zig @@ -10,14 +10,14 @@ fn frame(s: *anim.Frame) void { const size = canim.theme.size.sans; const text = canim.theme.color.text; const series = canim.label(s, .{ .text = "How programs really run", .box = .{ .x = 64, .y = 138, .w = 900, .h = 48 }, .size = size.kicker, .color = text.dim }); - const title = canim.label(s, .{ .text = "Four small programs,\none step at a time", .box = .{ .x = 64, .y = 220, .w = 1792, .h = size.title_leading }, .face = .sans_bold, .size = size.title, .color = text.bright }); - const under = canim.label(s, .{ .text = "recorded as they ran: every line, register and byte", .box = .{ .x = 64, .y = 500, .w = 1792, .h = 60 }, .face = .sans, .size = size.subtitle, .color = text.dim }); + const title = canim.label(s, .{ .text = "Six programs,\none step at a time", .box = .{ .x = 64, .y = 220, .w = 1792, .h = size.title_leading }, .face = .sans_bold, .size = size.title, .color = text.bright }); + const under = canim.label(s, .{ .text = "fib, a list, a sort, hello, malloc and SQLite: every line, register and byte", .box = .{ .x = 64, .y = 500, .w = 1792, .h = 60 }, .face = .sans, .size = size.subtitle, .color = text.dim }); const marks = canim.legend(s, .{ .box = canim.theme.cols(0, 12, 512, 256) }); const t = canim.theme.time; s.play(.{ series.fadeIn(), title.fadeIn() }, .{ .seconds = t.layout, .ease = canim.ease.enter }); s.play(.{under.fadeIn()}, .{ .seconds = t.move }); s.wait(t.beat); s.play(.{marks.fadeIn()}, .{ .seconds = t.travel }); - // Ten marks to learn: long enough to read them all. - s.wait(8); + // Twelve marks to learn: long enough to read them all. + s.wait(10); } diff --git a/anim/scenes/zoom.zig b/anim/scenes/zoom.zig index 1f23c05..426d3a3 100644 --- a/anim/scenes/zoom.zig +++ b/anim/scenes/zoom.zig @@ -7,8 +7,9 @@ //! row fires in the disassembly, the registers it changed strike, then //! the stack, and the mark walks down the listing. The camera goes //! nearer once, announced (its target framed, the rest cleared first), -//! for the call: the eight bytes of the way back, and the frame built -//! under them; then back, and the line is where it was, one call deeper. +//! for the call: the instructions and the stack's words in one view, the +//! eight bytes of the way back and the frame built under them; then back, +//! and the line is where it was, one call deeper. const anim = @import("anim"); const canim = @import("canim"); const recordings = @import("recordings"); @@ -39,17 +40,22 @@ fn frame(s: *anim.Frame) void { at.walk(s, .moment, call.enter - 1); 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. + // The stack holds still under the camera, set before it moves: six free + // words above rsp for the new frame (rsp-30 to rsp+8). ctx.stage.holdStack(s, at.moment(s), 6); + // Nearer, cause and effect in one view: the instructions as they run + // (mnemonics, operands, what each leaves) and the stack's words they + // write with their chains and roles (`fib+42`, `saved rbp`, `n`): from + // the mnemonics to the roles' end is all the stage holds at x1.16 (at + // x1.5 the stack's names and roles are off it); the rest cleared. + cam.go(s, .{ .x = 190, .y = 342, .w = 1525, .h = 480 }, 1.16, .{ ctx.source, ctx.registers, ctx.backtrace }); 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); - cam.back(s, .{ ctx.source, ctx.disasm, ctx.registers, ctx.backtrace }); + cam.back(s, .{ ctx.source, ctx.registers, ctx.backtrace }); says.line(s, "Nine instructions and three words of stack later\n`fib(4)` begins: the same lines, one call deeper."); at.walk(s, .line, end); diff --git a/anim/src/Recording.zig b/anim/src/Recording.zig index 1a4d859..a6e940c 100644 --- a/anim/src/Recording.zig +++ b/anim/src/Recording.zig @@ -820,7 +820,8 @@ pub fn drawn(r: *const Recording, span: Span, from: u64, to: u64) bool { } pub fn touches(list: []const Span, addr: u64, size: u64) bool { - for (list) |s| if (s.addr < addr + size and s.addr + s.len > addr) return true; + // Saturating: a register's chain asks about any value, to the top of the address space. + for (list) |s| if (s.addr < addr +| size and s.addr + s.len > addr) return true; return false; } diff --git a/anim/src/array.zig b/anim/src/array.zig index 8d53fb8..fad10c5 100644 --- a/anim/src/array.zig +++ b/anim/src/array.zig @@ -191,19 +191,23 @@ pub const Array = struct { // cell to cell as the idea strikes; two in one cell share its pin. var at_cell: [32]std.ArrayList([]const u8) = @splat(.empty); var slide: [32]?f32 = @splat(null); + // At a sprint the pins hold, and move only where a phrase ends: at the mark's moments. + const sprint = now.plan.gait == .sprint; + const pin_is = if (sprint) rec.moment(now.marks[1]) else now.moment(); + const pin_was = if (sprint) rec.moment(now.marks[0]) else now.before(); for (g.indices) |name| { - const iv = rec.variable(f.scratch, now.moment(), name) orelse continue; - const here = number(now.moment(), iv.addr, @min(iv.size, 8), true) orelse continue; + const iv = rec.variable(f.scratch, pin_is, name) orelse continue; + const here = number(pin_is, iv.addr, @min(iv.size, 8), true) orelse continue; if (here < 0 or here >= count) continue; const k: usize = @intCast(here); at_cell[k].append(f.scratch, name) catch {}; - if (number(now.before(), iv.addr, @min(iv.size, 8), true)) |was| if (was != here and was >= 0 and was < count) { + if (number(pin_was, iv.addr, @min(iv.size, 8), true)) |was| if (was != here and was >= 0 and was < count) { slide[k] = @floatFromInt(was); }; } // And the registers that hold a cell's address: a pin, where a link lands. - const is = (now.moment().regs(rec.tid) catch null) orelse @import("ztrace").Regs{}; - const was_regs = (now.before().regs(rec.tid) catch null) orelse is; + const is = (pin_is.regs(rec.tid) catch null) orelse @import("ztrace").Regs{}; + const was_regs = (pin_was.regs(rec.tid) catch null) orelse is; const ink = context.ink(context.regionOf(moment, v.addr)); for (&at_cell, 0..) |*names, k| { const addr = v.addr + k * elem; @@ -218,10 +222,20 @@ pub const Array = struct { const before = was_regs.named(name) == addr; const after = is.named(name) == addr; if (!before and !after) continue; - const s = ties.pinShows(now, i, .node); + const s = if (sprint) blk: { + const p = now.moving(.idea, 0, 0); + break :blk @TypeOf(ties.pinShows(now, i, .node)){ .old = 1 - p, .new = p }; + } else 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; + // Under a sprint's veil the registers' names leave the cells (a cell's + // right name would print over the next cell's left), fading through its middle. + const veiled = now.sprint_veil; + if (veiled > 0) { + if (indices > 0) text = @min(text, @abs(2 * veiled - 1)) else shows = @min(shows, std.math.clamp(1 - 2 * veiled, 0, 1)); + } + if (veiled >= 0.5) continue; names.append(f.scratch, name) catch {}; if (indices == 0) shows = @min(shows, this); } diff --git a/anim/src/calls.zig b/anim/src/calls.zig index 9c3df04..50e83b2 100644 --- a/anim/src/calls.zig +++ b/anim/src/calls.zig @@ -134,8 +134,10 @@ pub const Tree = struct { } 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 }; + // Done: what it returned, on its outer shoulder (a left child's + // left, off its parent's disc); struck as it lands. + const left_child = if (n.parent) |p| n.x < nodes[p].x else false; + const badge: Rect = .{ .x = if (left_child) c[0] - m.badge_at[0] - m.badge else c[0] + m.badge_at[0], .y = c[1] - m.badge_at[1], .w = m.badge, .h = m.badge }; const heat: ui.Heat = if (n.call.exit.? > now.stops[1]) now.heat(0, null, since - time.badge_after) else .none; const ink = u.cellWritten(badge, heat, theme.color.page); // Framed, as every result is, but while the strike's paper is on it. diff --git a/anim/src/context.zig b/anim/src/context.zig index 37a95a6..9829fa7 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -46,6 +46,8 @@ pub const legend = blk: { /// window on the map and its place; its tags, rules and lanes how much shown. pub const Zoom = struct { box: Rect, to: Rect, chrome: f32 }; pub var zoomed: [8]?Zoom = @splat(null); +/// How much the thread shows: it fades in (12 f) once a dive has landed, never in a frame. +pub var thread_shows: f32 = 1; /// A panel's `Ui`, moved to where the stage has its box now (or, in a /// dive, scaled into the rect it is on its way through). @@ -161,6 +163,7 @@ pub const Registers = struct { var marks: rows.Marks = .{}; var landed = now.landed(.cpu, 0); var note: []const u8 = ""; + var note_shows: f32 = 1; const crossing: ?Recording.Syscall = if (r.syscalls) syscalls.inStep(now) else null; // A register is framed as carrying the call only while it holds the // argument in the moment shown: the stop before the call, until the @@ -176,6 +179,8 @@ pub const Registers = struct { // A descriptor says what it is open on: the `value` class `fd`. const names = zt.syscalls.names(made.nr); if (k <= names.len and std.mem.endsWith(u8, names[k - 1], "fd")) note = rec.openOn(u.f.scratch, value_was, made.enter); + // In with its framing, over 12 f, and out with it: never in a frame. + note_shows = @min(std.math.clamp(framed / time.quick, 0, 1), now.reading(.cpu, 0)); }; if (if (std.mem.eql(u8, name, "rax")) crossing else null) |made| { // rax: what was there, then the result, once the kernel's rows @@ -210,8 +215,15 @@ pub const Registers = struct { // 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); + // Its chain reads memory as the panels show it: what the step writes + // there is followed again (`extend`) once the bytes have landed, never before. + var memory = if (landed or ran < 1) is.moment else was.moment; + if (ran >= 1 and landed and !r.quiet) { + memory, const again, marks.hops = now.following(value_now); + if (again) |ago| marks.extend = @min(marks.extend orelse ago, ago); + } + const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, memory, if (landed or ran < 1) value_now else value_was, marks); + fdNote(u.faded(note_shows), hops, y, note); anchor(u, i, hops, y); } @@ -349,12 +361,16 @@ pub const Stack = struct { // stop deeper or shallower than a call is) does not scroll: the old // rows fade out before memory strikes and the new ones in after, // each with the memory of its own stop. - const landed = now.landed(.memory, 0); const jumped = far(window[0], window[1], slots); + // Out over 12 f to memory's landing and in over 12 f (at a run, half + // its step each, the turn no sooner than that): never in a frame. + const fade = @min(time.quick, now.plan.total / 2.0); + const turn = @max(now.plan.at[1] + time.strike.in / 2.0, fade); + const landed = if (jumped and !now.resting()) now.time >= turn else now.landed(.memory, 0); // 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); + const jump_shows: f32 = if (!jumped or now.resting()) 1 else if (!landed) 1 - std.math.clamp((now.time - turn + fade) / fade, 0, 1) else std.math.clamp((now.time - turn) / fade, 0, 1); if (jumped) window = if (landed) .{ window[0], window[0] } else .{ window[1], window[1] }; const v = u.faded(jump_shows); // Going to the hold and coming from it, the rows scroll: the @@ -476,16 +492,19 @@ pub const Stack = struct { const rsp_shown = if (landed) is.rsp else was.rsp; // 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; + // Of the rows of both windows: those sliding out keep theirs as they go. + const roles_from = @min(window[0], window[1]) -% 16; + const roles_n = slots + 4 + @abs(@as(i64, @bitCast(window[0] -% window[1]))) / 8; // 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], + zt.telescope.slots(now.before(), &was, roles_from, roles_buf[0][0..@min(roles_n, roles_buf[0].len)]) catch roles_buf[0][0..0], + zt.telescope.slots(now.moment(), &is, roles_from, roles_buf[1][0..@min(roles_n, 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; + // Each with whether it is a saved rbp before the step and after it. + var pointers: std.ArrayList(struct { hexdump.RowAt, [2]bool }) = .empty; var n: i64 = @as(i64, @intFromFloat(@floor(-slide))) - 1; while (n <= @as(i64, @intCast(slots)) - @as(i64, @intFromFloat(@floor(slide)))) : (n += 1) { const y = top + (@as(f32, @floatFromInt(n)) + slide) * m.row; @@ -501,10 +520,13 @@ pub const Stack = struct { 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); - continue; - } + // A free word rsp reaches (a push, `sub rsp`) becomes a slot as memory strikes (12 f), never in a frame. + const free_was = held and addr < was.rsp; + const free_is = held and addr < is.rsp; + const slot_shows: f32 = if (free_was == free_is or now.resting()) @as(f32, if (free_is) 0 else 1) else if (free_is) 1 - recast else recast; + if (slot_shows < 1) rows.free(v.faded(1 - slot_shows), y, memory, addr, below_rsp, lead); + if (slot_shows <= 0) continue; + const vs = v.faded(slot_shows); // A frame's name beside this row: the chain ends a character before it. var room_w = box.w; for (spans[0..n_spans]) |sp| { @@ -518,7 +540,7 @@ pub const Stack = struct { gap = share * (u.width(.mono, size, name) + ui.advance(size)); } 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); + if (gapped) pinGap(vs.faded(names.shows), y, names.names, lone.?, gap); const k_role = (addr -% roles_from) / 8; var role_at: [2]@TypeOf(roleName(u, .none, 0)) = undefined; for (&role_at, roles, [2]Recording.Moment{ now.before(), now.moment() }) |*r, of, mem| { @@ -533,10 +555,12 @@ pub const Stack = struct { 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 {}; + if (fades) _ = rows.slot(vs.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) vs.faded(ran) else vs, y, room_w, if (fades) now.moment() else now.shownAt(addr, 8), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was); + // An arc's ends are rows on show (the row above the window, there for a slide, is not). + if (y + m.row > top + 1 and y < box.h - m.pad - 1) at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {}; + const what_was: zt.telescope.Role = if (k_role < roles[0].len) roles[0][k_role].role else .none; + if (y + m.row > top + 1 and y < box.h - m.pad - 1) pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, .{ what_was == .saved and std.mem.eql(u8, what_was.saved, "rbp"), what == .saved and std.mem.eql(u8, what.saved, "rbp") } }) catch {}; // Only a row on show is a place a tie can land. if (y >= top - 1 and y + m.row <= box.h - m.pad + 1) { ties.anchor(u, .{ .word = addr }, .{ .x = theme.metric.slot.address, .y = y, .w = if (hops.n > 0) hops.x[0] + hops.w[0] - theme.metric.slot.address else 120, .h = m.row }); @@ -547,12 +571,17 @@ pub const Stack = struct { // 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 word, const saved_was = p_; + const saved = saved_was[1]; + const touched = now.writeAge(word.addr, 8) == 0 or now.wasRead(word.addr, 8); + if (saved and saved_was[0] and !touched) 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); + if (arcs.n == before) continue; // 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); + if (saved and touched) arcs.items[before].shows *= 1 - std.math.clamp((now.time - now.plan.advance) / time.read.out, 0, 1); + // A word becoming a saved rbp, or no longer one, with the step: its arc goes or comes as its role does (12 f). + if (!touched and saved != saved_was[0]) arcs.items[before].shows *= if (saved) 1 - recast else recast; } arcs.draw(v, theme.metric.arc.stack_lanes); // Where the window is, for a link to a word outside it. diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig index 2811488..f0f90ff 100644 --- a/anim/src/cursor.zig +++ b/anim/src/cursor.zig @@ -84,6 +84,10 @@ pub const Plan = struct { /// The line fires (not on a step that goes on from the last one's /// mark: a crossing stepped over, from its call row). fires: bool = true, + /// Seconds of the step before's cool still to run at this one's start + /// (a step that went on from it without its rest: a crossing from its + /// call row): what it struck goes on cooling, never cut in a frame. + cooling: f32 = 0, /// Once the pattern is known: the levels a stagger apart from the /// first frame, the mark after them, in `seconds`. @@ -91,8 +95,9 @@ pub const Plan = struct { return .{ .gait = .run, .at = .{ 0, time.stagger, 2 * time.stagger }, .advance = time.run_ease, .travel = time.run_ease, .total = seconds }; } + /// The mark, seen only where a phrase ends, moves over the step there: never in a frame. pub fn sprinting(seconds: f32) Plan { - return .{ .gait = .sprint, .at = @splat(0), .advance = 0, .travel = 0, .total = seconds }; + return .{ .gait = .sprint, .at = @splat(0), .advance = 0, .travel = seconds, .total = seconds }; } }; @@ -115,7 +120,7 @@ pub const Cursor = struct { /// 0 to 1 through the step it is taking; 1 at rest. phase: anim.Value, /// The step's `Plan`, a value a field. - plan: [9]anim.Value, + plan: [10]anim.Value, /// The moment the current mark was on, and the one it is on (or going to). marks: [2]anim.Value, /// 1 while steps are hurried (the head counts them), and while what @@ -147,7 +152,7 @@ pub const Cursor = struct { .stops = undefined, .gaits = undefined, .phase = s.value(1), - .plan = .{ s.value(0), s.value(plan.at[0]), s.value(plan.at[1]), s.value(plan.at[2]), s.value(plan.advance), s.value(plan.travel), s.value(plan.total), s.value(0), s.value(1) }, + .plan = .{ s.value(0), s.value(plan.at[0]), s.value(plan.at[1]), s.value(plan.at[2]), s.value(plan.advance), s.value(plan.travel), s.value(plan.total), s.value(0), s.value(1), s.value(0) }, .marks = .{ s.value(here), s.value(here) }, .hurried = s.value(0), .veil = s.value(0), @@ -176,7 +181,7 @@ pub const Cursor = struct { stops: [history]anim.Value, gaits: [history]anim.Value, phase: anim.Value, - plan: [9]anim.Value, + plan: [10]anim.Value, marks: [2]anim.Value, hurried: anim.Value, veil: anim.Value, @@ -253,24 +258,24 @@ pub const Cursor = struct { const Step = struct { stops: [history]f32, gaits: [history]f32, - plan: [9]f32, + plan: [10]f32, marks: [2]f32, count: f32, seconds: f32, fn run(st: @This(), sf: *anim.Frame, v: Cursor) void { - var set: [2 * history + 13]anim.Animation = undefined; + var set: [2 * history + 14]anim.Animation = undefined; for (v.stops, st.stops, 0..) |value, is, i| set[i] = value.to(is); - for (v.gaits, st.gaits, 0..) |value, is, i| set[history + 13 + i] = value.to(is); + for (v.gaits, st.gaits, 0..) |value, is, i| set[history + 14 + i] = value.to(is); for (v.plan, st.plan, history..) |value, is, n| set[n] = value.to(is); - set[history + 9] = v.marks[0].to(st.marks[0]); - set[history + 10] = v.marks[1].to(st.marks[1]); - set[history + 11] = v.phase.to(0); - set[history + 12] = v.count.to(st.count); + set[history + 10] = v.marks[0].to(st.marks[0]); + set[history + 11] = v.marks[1].to(st.marks[1]); + set[history + 12] = v.phase.to(0); + set[history + 13] = v.count.to(st.count); sf.play(set, .{ .seconds = 0 }); sf.play(.{v.phase.to(1)}, .{ .seconds = st.seconds, .ease = anim.ease.linear }); } }; - var st: Step = .{ .stops = undefined, .gaits = undefined, .plan = .{ @floatFromInt(@intFromEnum(plan.gait)), plan.at[0], plan.at[1], plan.at[2], plan.advance, plan.travel, plan.total, @floatFromInt(@intFromBool(plan.wave)), @floatFromInt(@intFromBool(plan.fires)) }, .marks = undefined, .count = settled(s, c.count) + 1, .seconds = seconds }; + var st: Step = .{ .stops = undefined, .gaits = undefined, .plan = .{ @floatFromInt(@intFromEnum(plan.gait)), plan.at[0], plan.at[1], plan.at[2], plan.advance, plan.travel, plan.total, @floatFromInt(@intFromBool(plan.wave)), @floatFromInt(@intFromBool(plan.fires)), plan.cooling }, .marks = undefined, .count = settled(s, c.count) + 1, .seconds = seconds }; st.stops[0] = @floatFromInt(to); for (1..history) |i| st.stops[i] = settled(s, c.stops[i - 1]); st.gaits[0] = @floatFromInt(@intFromEnum(plan.gait)); @@ -329,10 +334,15 @@ pub const Cursor = struct { const regs: f32 = @floatFromInt(@popCount(rec.registersChanged(from, to) & ~quiet)); // Memory gives up its slot when nothing it touched is drawn. var wrote_n: usize = 0; - for (rec.written(from, to)) |span| wrote_n += @intFromBool(rec.drawn(span, from, to)); + var strikes_n: usize = 0; + for (rec.written(from, to)) |span| { + wrote_n += @intFromBool(rec.drawn(span, from, to)); + strikes_n += @intFromBool(takesPlace(rec, span, from, to)); + } var read_n: usize = 0; for (rec.read(from, to)) |span| read_n += @intFromBool(rec.drawn(span, from, to)); - const wrote: f32 = @floatFromInt(wrote_n); + // As many strikes as writes take a place (`takesPlace`): the last is 6 f a write after the first. + const wrote: f32 = @floatFromInt(if (wrote_n > 0) @max(strikes_n, 1) else 0); const touched = wrote_n > 0 or read_n > 0; const deeper = rec.depths[to] > rec.depths[from]; const back = rec.depths[to] < rec.depths[from]; @@ -485,6 +495,7 @@ pub const Cursor = struct { .total = placed.value(c.plan[6]), .wave = placed.value(c.plan[7]) >= 0.5, .fires = placed.value(c.plan[8]) >= 0.5, + .cooling = placed.value(c.plan[9]), }, .marks = .{ whole(rec, placed.value(c.marks[0])), whole(rec, placed.value(c.marks[1])) }, .hurried = placed.value(c.hurried), @@ -510,6 +521,13 @@ pub const Cursor = struct { } }; +/// Whether a write of the step from `from` to `to` takes a place among +/// its strikes: not on a stack frame the step has already left (a callee's +/// words, under rsp, that no window shows: `Recording.drawn`). +fn takesPlace(rec: *const Recording, span: Recording.Span, from: u64, to: u64) bool { + return rec.drawn(span, from, to) or zt.telescope.region(rec.moment(to), span.addr) catch .none != .stack; +} + fn whole(rec: *const Recording, value: f32) u64 { return @min(@as(u64, @intFromFloat(@max(value, 0))), rec.end()); } @@ -671,7 +689,9 @@ pub const Now = struct { n.rec.moment(n.stops[age]).read(addr, is[0..l], known_is[0..l]) catch return null; var out: ?[2]u8 = null; for (0..l) |i| if (known_was[i] and known_is[i] and was[i] != is[i]) { - out = .{ if (out) |o| o[0] else @intCast(i), @intCast(i) }; + // Its first apart: assigned in one expression, `out` would be read as it is written. + const first: u8 = if (out) |o| o[0] else @intCast(i); + out = .{ first, @intCast(i) }; }; return out; } @@ -718,6 +738,8 @@ pub const Now = struct { if (a == 0 or a > s.ember_steps) return .none; // A run changes values unmarked: it shows them settled. if (n.gaits[a] == .run) return .none; + // The step before went on into this one before its cool was done: it cools on. + if (a == 1 and n.plan.cooling > 0 and n.gaits[1] == .walk and !n.resting() and n.time < n.plan.cooling) return cooled(1 - (n.plan.cooling - n.time) / s.cool, .nothing, 0); 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. @@ -753,17 +775,23 @@ pub const Now = struct { if (since_strike >= -s.arm) armed.arm = std.math.clamp((since_strike + s.arm) / time.stagger, 0, 1); return armed; } - const cooled = (n.time - n.plan.advance) / s.cool; const in = std.math.clamp(since_strike / s.in, 0, 1); + var h = cooled((n.time - n.plan.advance) / s.cool, if (was.level >= 1) .ember else .nothing, if (was.level >= 1) 1 - in else 0); + h.in = in; + h.out = if (since_strike < s.pulse) theme.pulse(since_strike / s.pulse) else 0; + return h; + } + + /// A struck thing `cooled` of the way through its cool (0 to 1): the + /// paper going on `glide`; the turned corner coming in over the cool's + /// last 6 f (and the old one, `corner_was`, going as a strike comes in over it). + fn cooled(p: f32, from: @FieldType(ui.Heat, "from"), corner_was: f32) ui.Heat { + const s = time.strike; return .{ .level = 1, - .solid = 1 - glide(std.math.clamp(cooled, 0, 1)), - .in = in, - .from = if (was.level >= 1) .ember else .nothing, - .out = if (since_strike < s.pulse) theme.pulse(since_strike / s.pulse) else 0, - // The turned corner: the old one goes as the paper comes in over - // it; the new one comes in over the cool's last 6 f. - .corner = @max(std.math.clamp((cooled - 1) * s.cool / s.corner + 1, 0, 1), if (was.level >= 1) 1 - in else 0), + .solid = 1 - glide(std.math.clamp(p, 0, 1)), + .from = from, + .corner = @max(std.math.clamp((p - 1) * s.cool / s.corner + 1, 0, 1), corner_was), }; } @@ -771,13 +799,33 @@ pub const Now = struct { /// `level`, `delay` seconds after its first, and 6 f after the write of /// this step before theirs. pub fn written(n: Now, addr: u64, size: u64, level: Level, delay: f32) ui.Heat { + var h = n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), n.sinceStrike(addr, size, level, delay)); // What the kernel fills in a crossing lands as its work does it, unpulsed. - if (level == .memory) if (syscalls.filledAt(n, addr)) |at| { - var h = n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), n.time - at); - h.out = 0; - return h; + if (level == .memory and syscalls.filledAt(n, addr) != null) h.out = 0; + return h; + } + + /// Seconds since the strike of `addr .. addr + size` with `level`, + /// `delay` after its first and 6 f after the write of this step before + /// theirs; what the kernel fills in a crossing, as its work lands it. + fn sinceStrike(n: Now, addr: u64, size: u64, level: Level, delay: f32) f32 { + if (level == .memory) if (syscalls.filledAt(n, addr)) |at| return n.time - at; + return n.since(level, delay + n.writeDelay(addr, size)); + } + + /// Seconds since this step's write of `addr .. addr + size` struck in + /// memory, at a walk; null where the step did not write it, or at + /// another pace. Until `in / 2` after it (s+3) the old value stands, + /// through the arm (`shownAt`, a dump's runs, a chain's hops). + pub fn struckAgo(n: Now, addr: u64, size: u64) ?f32 { + if (!n.walking() or n.writeAge(addr, size) != 0) return null; + // What the kernel fills, a byte every 2 f: the value is there once its last byte is. + var last: ?f32 = null; + for (0..size) |i| if (syscalls.filledAt(n, addr + i)) |at| { + last = @max(last orelse at, at); }; - return n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), n.since(level, delay + n.writeDelay(addr, size))); + if (last) |at| return n.time - at; + return n.sinceStrike(addr, size, .memory, 0); } /// `written`, struck `since` seconds ago (a loupe's own times: it strikes once it has opened). @@ -785,11 +833,44 @@ pub const Now = struct { return n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), struck); } - /// The state to draw the memory at `addr` from: `shown(.memory)`, but - /// what the kernel fills in a crossing from when its byte lands. - pub fn shownAt(n: Now, addr: u64) Recording.Moment { - if (syscalls.filledAt(n, addr)) |at| return if (n.time - at >= time.strike.in / 2.0) n.moment() else n.before(); - return n.shown(.memory); + /// The state to draw the memory at `addr .. addr + size` from: + /// `shown(.memory)`, but a write of this step from its own strike + /// (s+3), never before its arm; what the kernel fills in a crossing + /// from when its byte lands. + pub fn shownAt(n: Now, addr: u64, size: u64) Recording.Moment { + return if (n.landedAt(addr, size)) n.moment() else n.before(); + } + + /// Whether memory at `addr .. addr + size` shows the step's state (`shownAt`). + pub fn landedAt(n: Now, addr: u64, size: u64) bool { + if (n.struckAgo(addr, size)) |ago| return ago >= time.strike.in / 2.0; + return n.landed(.memory, 0); + } + + /// The memory a chain from `value` (a register's, struck or not) reads + /// as the panels show it (`shownAt`: the word it points at, from its + /// strike), and, where the step changes what the chain says, seconds + /// since its hops are followed again (`extend`): 4 f after the bytes + /// land, never before. Null where the chain did not change. + /// Before the bytes land, from their strike, the hops it shows fade out + /// (the third: how much they show), so that none goes in a frame. + pub fn following(n: Now, value: u64) struct { Recording.Moment, ?f32, f32 } { + const memory = n.shownAt(value, 8); + if (!n.walking()) return .{ memory, null, 1 }; + const struck = n.struckAgo(value, 8) orelse n.since(.memory, 0); + const land = time.strike.in / 2.0; + // Followed again only while that shows (its hops 4 f apart, 6 f each). + if (struck < 0 or struck > land + 0.5) return .{ memory, null, 1 }; + var bufs: [2][6]zt.telescope.Link = undefined; + var texts: [2][48]u8 = undefined; + const was = zt.telescope.chase(n.before(), value, &bufs[0], &texts[0]) catch return .{ memory, null, 1 }; + const is = zt.telescope.chase(n.moment(), value, &bufs[1], &texts[1]) catch return .{ memory, null, 1 }; + const same = was.len == is.len and for (was, is) |a, b| { + if (a.value != b.value or !std.mem.eql(u8, a.text, b.text)) break false; + } else true; + if (same) return .{ memory, null, 1 }; + if (!n.landedAt(value, 8)) return .{ memory, null, 1 - std.math.clamp(struck / land, 0, 1) }; + return .{ memory, struck - 4.0 / 60.0, 1 }; } /// `written`, on a thing the viewer has watched only through the steps @@ -805,9 +886,9 @@ pub const Now = struct { var order: f32 = 0; var last: ?u64 = null; for (n.rec.written(n.stops[1], n.stops[0])) |span| { - if (span.addr < addr + size and span.addr + span.len > addr) return @min(order, 3) * write_apart; - // The kernel's own writes have their own times (`filledAt`). - if (syscalls.filledAt(n, span.addr) != null) continue; + if (span.addr < addr +| size and span.addr + span.len > addr) return @min(order, 3) * write_apart; + // The kernel's own writes have their own times (`filledAt`); a frame the step has left takes no place. + if (syscalls.filledAt(n, span.addr) != null or !takesPlace(n.rec, span, n.stops[1], n.stops[0])) continue; // Bytes of one write (one store, in pieces) are one strike. if (last == null or span.addr != last.?) order += 1; last = span.addr + span.len; diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig index cf16c6a..4324b42 100644 --- a/anim/src/disasm.zig +++ b/anim/src/disasm.zig @@ -434,7 +434,7 @@ pub const Disasm = struct { marks.read_shows = now.reading(.memory, 0); } if (writes) if (after) |aa| { - if (state == .ran or now.landed(.memory, 0)) shown = rec.moment(aa); + if (state == .ran or now.landedAt(touch.addr, touch.len)) shown = rec.moment(aa); if (in_step) { marks.changed = 1; marks.changed_heat = now.written(touch.addr, touch.len, .memory, 0); diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig index 47283e7..21db91f 100644 --- a/anim/src/hexdump.zig +++ b/anim/src/hexdump.zig @@ -65,6 +65,8 @@ pub const Of = struct { things: []const objects.Object = &.{}, array: ?struct { addr: u64, len: u64, elem: u8, type: ?Recording.types.Type = null } = null, region: u24 = theme.color.region.heap, + /// A lens's view: a row a register points into carries its pin (`rowPin`). + pins: bool = false, }; /// The band's view of bytes: its own panel over the state column, the @@ -106,6 +108,7 @@ pub const Dump = struct { if (v.rows == 0) return; const now = d.cursor.now(placed); var of = d.of; + of.pins = true; of.watched = 0; while (of.watched + 1 < now.stops.len and now.stops[of.watched + 1] >= d.since) of.watched += 1; var shows: [8]f32 = @splat(0); @@ -151,7 +154,9 @@ pub const View = struct { /// always, with `loud`: a loupe's). `rule`: the panel's top and bottom, /// where a stub to a row past the window ends. pub fn draw(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: usize, of: Of) void { - drawArcs(u, now, x, y, first, count, of, false, .{ y - m.pad, y + @as(f32, @floatFromInt(count)) * m.row + m.pad }); + var view = of; + view.pins = true; + drawArcs(u, now, x, y, first, count, view, false, .{ y - m.pad, y + @as(f32, @floatFromInt(count)) * m.row + m.pad }); } pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: usize, of: Of, loud: bool, rule: [2]f32) void { @@ -174,6 +179,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u moment.read(addr, &values, &known) catch return; var runs: [16]rows.Run = undefined; var readings: [16]Field = undefined; + var keeps: [16]bool = @splat(false); var n: usize = 0; var holds_drawn = false; var at: u64 = 0; @@ -206,6 +212,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u } run.heat = now.written(here, run.len, .memory, 0); run.changed = now.changedBytes(here, run.len); + if (now.struckAgo(here, run.len)) |ago| keeps[n] = ago < theme.time.strike.in / 2.0; if (now.wasRead(here, run.len) and now.writeAge(here, run.len) != 0) run.read = now.reading(.memory, 0); if (run.kind == .number or run.kind == .pointer) ties.anchor(v, .{ .dump_run = here }, .{ .x = shift + rows.byteX(run.first) - 4, .y = ry, .w = rows.byteX(run.first + run.len - 1) + 28 - rows.byteX(run.first) + 4, .h = m.row }); readings[n] = .{ .at = run.first, .len = run.len, .reads = switch (run.kind) { @@ -218,9 +225,11 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u at += run.len; } @import("map.zig").row(.view, addr, v, .{ .x = 0, .y = ry, .w = theme.layout.state.w, .h = m.row }); + keepOld(now, addr, &values, &known, runs[0..n], keeps[0..n]); rows.bytesAt(v, ry, addr, &values, &known, runs[0..n], of.region, lead, holds_drawn, moment, shift); if (pass + 1 == passes.n) for (runs[0..n]) |run| if (run.kind == .pointer and run.len == 8) pointerArcs(&arcs, now, addr + run.first, ry, shown_rows, 16, rule, loud, false); - const end = reading(v, ry, shift, moment, &values, &known, readings[0..n]); + const room = if (!of.pins) full_room else if (pass == 0) rowPin(dump, now, addr, ry) else rowPinRoom(dump, now, addr); + const end = readingIn(v, ry, shift, moment, &values, &known, readings[0..n], room); // The size word of the chunk after: malloc's, a note after the reading. const last = runs[n - 1]; if (last.kind == .loose and last.first == 8 and last.len == 8 and std.mem.indexOfScalar(bool, known[8..], false) == null and chunkAfter(moment, addr + 8)) { @@ -263,6 +272,65 @@ fn rowPasses(now: cursors.Now, addr: u64) Passes { return plain; } +/// The registers whose value is in the row `addr .. addr + 16`, as a step +/// moves them (`ties.pinShows`: a name joining or leaving fades through the +/// middle of its change), in pwndbg's order: a view's row a register points +/// into carries its pin, at the row's end (`Ui.pinEnd`). Draws it and +/// returns where the reading must end; publishes the row as a link's +/// target (`dump_pin`), its left edge. +fn rowPin(u: ui.Ui, now: cursors.Now, addr: u64, y: f32) f32 { + ties.anchor(u, .{ .dump_pin = addr }, .{ .x = 0, .y = y, .w = b.bracket, .h = m.row }); + const at = pinned(u, now, addr); + if (at.names.len == 0 or at.shows <= 0) return full_room; + const x = u.faded(at.shows).pinEnd(full_room, y, at.names, rows.ink(rows.regionOf(now.moment(), addr))); + return x - adv; +} + +/// Where the reading of a row must end for its pin (`rowPin`), not drawing it. +fn rowPinRoom(u: ui.Ui, now: cursors.Now, addr: u64) f32 { + const at = pinned(u, now, addr); + if (at.names.len == 0 or at.shows <= 0) return full_room; + const p = theme.metric.pin; + var shown: []const u8 = ""; + for (at.names[0..@min(at.names.len, 3)], 0..) |name, i| shown = if (i == 0) name else u.print("{s} {s}", .{ shown, name }); + if (at.names.len > 3) shown = u.print("{s} +{d}", .{ shown, at.names.len - 3 }); + return full_room - u.width(.mono, theme.size.mono.context, shown) - p.row_gap - p.row_head[0] - adv; +} + +fn pinned(u: ui.Ui, now: cursors.Now, addr: u64) struct { names: []const []const u8, shows: f32 } { + const rec = now.rec; + const context = @import("context.zig"); + const is = (now.moment().regs(rec.tid) catch null) orelse return .{ .names = &.{}, .shows = 0 }; + const was = (now.before().regs(rec.tid) catch null) orelse is; + var names: std.ArrayList([]const u8) = .empty; + var shows: f32 = 1; + for (theme.metric.all_registers[0..16]) |name| { + const in_was = if (was.named(name)) |v| v >= addr and v < addr + 16 else false; + const in_is = if (is.named(name)) |v| v >= addr and v < addr + 16 else false; + if (!in_was and !in_is) continue; + const s = ties.pinShows(now, context.index(name).?, .node); + const this: f32 = if (in_was and in_is) 1 else if (in_is) s.new else s.old; + if (in_was != in_is) shows = @min(shows, @abs(2 * this - 1)); + if (this < 0.5) continue; + names.append(u.f.scratch, name) catch break; + } + return .{ .names = names.items, .shows = shows }; +} + +/// The runs this step writes whose strike has not landed (`keeps`) keep +/// the bytes they had: the digits and the reading change at s+3, as the +/// fill comes in, never before the arm. +fn keepOld(now: cursors.Now, addr: u64, values: *[16]u8, known: *[16]bool, runs: []const rows.Run, keeps: []const bool) void { + if (std.mem.indexOfScalar(bool, keeps, true) == null) return; + var was: [16]u8 = undefined; + var known_was: [16]bool = undefined; + now.before().read(addr, &was, &known_was) catch return; + for (runs, keeps) |run, old| if (old) { + @memcpy(values[run.first..][0..run.len], was[run.first..][0..run.len]); + @memcpy(known[run.first..][0..run.len], known_was[run.first..][0..run.len]); + }; +} + /// A row of a panel: its first byte's address and its top. pub const RowAt = struct { addr: u64, y: f32 }; @@ -400,6 +468,11 @@ pub const Fields = struct { /// Seconds since its strikes began, a field 6 f after the one before /// (a loupe's, once it has opened); null: memory's slot. struck: ?f32 = null, + /// A view: a row a register points into carries its pin (`rowPin`). + pins: bool = false, + /// The fields before the step, where it retypes them: a run whose strike + /// has not landed is read as what it was. + was: []const Field = &.{}, }; /// The region's rows in view `v`, from `y`, sixteen bytes a row from its @@ -440,7 +513,8 @@ pub fn fielded(v: View, now: cursors.Now, y: f32, of: Fields) void { } last = r; 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); + const room = if (of.pins) rowPin(u, now, of.base + 16 * r, ry) else full_room; + 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, room); 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; @@ -509,7 +583,7 @@ fn focus(now: cursors.Now, of: Fields, rs: []const u64) usize { return 0; } -fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Moment, of: Fields, lead: usize, shift: f32) void { +fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Moment, of: Fields, lead: usize, shift: f32, room: f32) void { var values: [16]u8 = undefined; var known: [16]bool = undefined; moment.read(addr, &values, &known) catch return; @@ -537,6 +611,7 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom }; var runs: [16]rows.Run = undefined; var readings: [16]Field = undefined; + var keeps: [16]bool = @splat(false); var n: usize = 0; var at: u8 = 0; while (at < 16 and addr + at < of.base + of.len) { @@ -558,6 +633,9 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom }; run.heat = now.writtenWatched(here, run.len, .memory, 0, 0, of.watched); run.changed = now.changedBytes(here, run.len); + // Until its own strike lands the old value stands: the loupe's own times, or memory's. + const ago = if (of.struck) |since| (if (now.walking() and now.writeAge(here, run.len) == 0) since - @as(f32, @floatFromInt(field_k)) * cursors.write_apart else null) else if (of.watched > 0) now.struckAgo(here, run.len) else null; + if (ago) |a| keeps[n] = a < theme.time.strike.in / 2.0; if (of.struck) |since| run.heat = now.writtenAt(here, run.len, since - @as(f32, @floatFromInt(field_k)) * cursors.write_apart); // What the kernel fills lands a byte every 2 f. if (@import("syscalls.zig").filledAt(now, here) != null) run.apart = 2; @@ -568,6 +646,16 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom if (of.watched > 0 and now.wasRead(here, run.len) and now.writeAge(here, run.len) != 0) framed = @max(framed, now.reading(.memory, 0)); run.read = framed; readings[n] = .{ .at = at, .len = run.len, .reads = fl.reads, .big = fl.big, .type = fl.type, .note = fl.note, .addr = here }; + // Its old bytes read as what they were until its strike lands (the step retypes the field: malloc's). + if (keeps[n]) for (of.was) |old| if (of.base + old.at <= here and here < of.base + old.at + old.len) { + readings[n] = .{ .at = at, .len = run.len, .reads = old.reads, .big = old.big, .type = old.type, .note = old.note, .addr = here }; + run.kind = switch (old.reads) { + .number, .bytes, .size, .protected => .number, + .pointer => .pointer, + .text => .text, + }; + break; + }; ties.anchor(u, .{ .dump_run = here }, .{ .x = shift + rows.byteX(run.first) - 4, .y = y, .w = rows.byteX(run.first + run.len - 1) + 28 - rows.byteX(run.first) + 4, .h = m.row }); } else { // Up to the next field, or the row's end. @@ -582,16 +670,17 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom n += 1; at += run.len; } + keepOld(now, addr, &values, &known, runs[0..n], keeps[0..n]); // The kernel reading them: one frame round what it took of the row. if (gives and of.read > 0) u.faded(of.read).frame(.{ .x = shift + rows.byteX(given_from) - 7, .y = y - 1, .w = rows.byteX(given_to) - rows.byteX(given_from) + 38, .h = m.row + 2 }, theme.mark(.read).solid, 2); const shows = if (of.given) |g| g.shows else 0; if (gives and shows > 0) { if (shows < 1) rows.bytesAt(u.faded(1 - shows), y, addr, &values, &known, runs[0..n], of.region, lead, true, moment, shift); rows.bytesAt(u.faded(shows), y, addr, &given_values, &given_known, runs[0..n], of.region, lead, true, moment, shift); - _ = reading(u.faded(shows), y, shift, moment, &given_values, &given_known, readings[0..n]); + _ = readingIn(u.faded(shows), y, shift, moment, &given_values, &given_known, readings[0..n], room); } else { rows.bytesAt(u, y, addr, &values, &known, runs[0..n], of.region, lead, true, moment, shift); - _ = reading(u, y, shift, moment, &values, &known, readings[0..n]); + _ = readingIn(u, y, shift, moment, &values, &known, readings[0..n], room); } } @@ -604,9 +693,16 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom /// `loose`, as nothing. Cut where the panel ends, with `…`. Returns where /// it ends. pub fn reading(u: ui.Ui, y: f32, shift: f32, moment: Recording.Moment, values: *const [16]u8, known: *const [16]bool, fields: []const Field) f32 { + return readingIn(u, y, shift, moment, values, known, fields, full_room); +} + +/// The panel's width less its side: where a reading ends with no pin at its row's end. +const full_room = theme.layout.state.w - theme.metric.context.side; + +/// `reading`, ending at `room` (a pin at the row's end takes the rest). +pub fn readingIn(u: ui.Ui, y: f32, shift: f32, moment: Recording.Moment, values: *const [16]u8, known: *const [16]bool, fields: []const Field, room: f32) f32 { const size = theme.size.mono.context; const base = rows.baseline(y); - const room = theme.layout.state.w - theme.metric.context.side; var x: f32 = b.reading + shift; for (fields) |fl| { const first: usize = @intCast(fl.at); diff --git a/anim/src/map.zig b/anim/src/map.zig index 255ea2d..c870d60 100644 --- a/anim/src/map.zig +++ b/anim/src/map.zig @@ -383,6 +383,7 @@ pub const Map = struct { const context = @import("context.zig"); context.zoomed = @splat(null); const t = placed.value(m.t); + context.thread_shows = std.math.clamp((t - diving.land) / 12, 0, 1); if (t >= diving.land) return; const fixed = @import("words.zig").fixed(f, placed, 0); const at = m.falling(f, placed, t); @@ -671,6 +672,10 @@ pub fn minimap(m: *const Map, f: *sk.Frame, at: anim.Placed) void { placed.scale = fixed.at.scale * theme.minimap.scale; const values = f.scratch.dupe(f32, at.values) catch return; placed.values = values; + // Its drawings outline the windows in their images' pixels: where the + // falling map has them (a dive's panels set off from there) is kept. + const falling_px = window_px; + defer window_px = falling_px; const n = theme.time.minimap_fade; var weights: [n]f32 = @splat(0); var made: usize = 0; diff --git a/anim/src/root.zig b/anim/src/root.zig index 7e4206a..60ae6dc 100644 --- a/anim/src/root.zig +++ b/anim/src/root.zig @@ -253,6 +253,13 @@ pub const Context = struct { return add(s, Ties{ .cursor = c.cursor, .stage = c.stage, .quiet = c.quiet }); } + /// The ties, and a link the scene plays on a beat of its own (`Beat.play`): + /// register `name` framed as read, then linked to what it points at, held `hold`. + pub fn tiesWith(c: Context, s: *anim.Frame, name: []const u8, hold: f32) struct { anim.Obj, *const tying.Beat } { + const beat = s.new(tying.Beat{ .cursor = c.cursor, .name = name, .hold = hold, .t = s.value(-1) }); + return .{ add(s, Ties{ .cursor = c.cursor, .stage = c.stage, .quiet = c.quiet, .beat = beat }), beat }; + } + /// A scene's opening with a lens drawn from bytes (`nodes`, `array`): /// as `establish`, and from half a second in the drawing's /// `elements` come in, each rising 8 units, 2 f apart in address diff --git a/anim/src/rows.zig b/anim/src/rows.zig index a125b05..95400be 100644 --- a/anim/src/rows.zig +++ b/anim/src/rows.zig @@ -56,6 +56,9 @@ pub const Marks = struct { extend: ?f32 = null, /// The first hop's `lead` (a column of addresses). lead: usize = 0, + /// How much the hops after the first show: they fade out as the memory + /// they read is about to change (`Now.following`). + hops: f32 = 1, }; /// `chain` of a memory access narrower than a word: its address, then what @@ -119,7 +122,8 @@ pub fn chain(u: ui.Ui, x: f32, y: f32, moment: Recording.Moment, value: u64, roo const shown = ui.Value.of(link.value, pointer); const w = shown.width(); // The hops after a struck first one are followed again, one at a time. - const v = if (i > 0 and marks.extend != null) u.faded(std.math.clamp((marks.extend.? - @as(f32, @floatFromInt(i - 1)) * theme.time.unroll) / (6.0 / 60.0), 0, 1)) else u; + const followed: f32 = if (marks.extend) |e| std.math.clamp((e - @as(f32, @floatFromInt(i -| 1)) * theme.time.unroll) / (6.0 / 60.0), 0, 1) else 1; + const v = if (i > 0) u.faded(followed * marks.hops) else u; if (i > 0) { const named: f32 = if (link.region == .code and link.text.len > 0 and !link.string) 10 + @as(f32, @floatFromInt(link.text.len)) * adv else 0; // Room for it, and for saying there is more. diff --git a/anim/src/syscalls.zig b/anim/src/syscalls.zig index ca98920..b568612 100644 --- a/anim/src/syscalls.zig +++ b/anim/src/syscalls.zig @@ -128,7 +128,9 @@ pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void { while (call < made.enter and !(if (rec.insn_branches[call]) |b| b.kind == .call else false)) call += 1; if (call >= made.enter) call = from; // 1, the instructions before the call: a cascade, the plaque onto the - // call's row 12 f after the last strike, no rest (the line stays current). + // call's row 12 f after the last strike, no rest (the line stays current): + // what it struck cools on into the crossing. + var cooling: f32 = 0; if (call > from) { var before = c.reading(from, call); const regs_before: f32 = @floatFromInt(@popCount(rec.registersChanged(from, call) & ~cursors.quiet)); @@ -139,12 +141,14 @@ pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void { before.advance = last + 12.0 / 60.0; before.travel = time.step; before.total = before.advance + before.travel; + cooling = time.strike.cool - before.travel; c.step(s, call, before, before.total); } // 2, the crossing from the call row (its chart's frame 18 first); 3, the stores after. const p = if (call > from) Plan.of(made).shifted(-time.cascade) else Plan.of(made); var plan = p.step(); plan.fires = call == from; + plan.cooling = cooling; // The store after the call: 18 f after rax, and after the registers the call left (6 f apart). const regs: f32 = @floatFromInt(@popCount(rec.registersChanged(call, to) & ~cursors.quiet)); const last_register = p.struck + @min(@max(regs - 1, 0), 3) * cursors.write_apart; @@ -263,35 +267,56 @@ pub const Crossing = struct { var first: usize = 0; while (first < rec.syscalls.len and rec.syscalls[first].enter < c.cursor.first) first += 1; var newest = latest(rec, now.stops[0]); - // A crossing's own row comes in once it is back (rax struck), 12 f. + // A crossing's own row comes in once it is back (rax struck): the + // rows make room for it, a full log scrolling a row (24 f, `glide`), + // as it fades in (12 f), and the count above crossfades with them. var arrives: f32 = 1; if (newest) |n| if (inStep(now) != null and now.walking()) { const p = Plan.in(now, rec.syscalls[n]); - arrives = std.math.clamp((now.time - p.struck - 6.0 / 60.0) / theme.time.quick, 0, 1); + arrives = std.math.clamp((now.time - p.struck - 6.0 / 60.0) / theme.time.move, 0, 1); }; if (newest) |n| if (n < first) { newest = null; }; const count = if (newest) |n| n + 1 - first else 0; - const body = u.panel(box.w, box.h, "system calls", .{ .focus = c.focus, .note = if (count > room) u.print("as strace writes them \u{00b7} newest at the bottom \u{00b7} {d} more above", .{count - room}) else "as strace writes them \u{00b7} newest at the bottom" }); + const above = [2]usize{ (count -| 1) -| room, count -| room }; + const notes = [2][]const u8{ logNote(u, above[0]), logNote(u, above[1]) }; + const scroll = cursors.glide(arrives); + const renote = above[0] != above[1] and arrives < 1; + const body = u.panel(box.w, box.h, "system calls", .{ .focus = c.focus, .note = if (renote) "" else notes[1] }); + if (renote) { + u.faded(1 - scroll).tagNote(box.w, notes[0]); + u.faded(scroll).tagNote(box.w, notes[1]); + } context.clipBody(u, box); defer u.unclip(); const n = newest orelse return; const top = body.y + theme.metric.context.pad; const shown = @min(count, room); - for (0..shown) |j| { - const i = n + 1 - shown + j; - const v = if (i == n) u.faded(arrives) else u; - const y = top + @as(f32, @floatFromInt(j)) * row_h; + // A full log's oldest row shown goes up and out as the new one comes. + const scrolls = arrives < 1 and count > room; + const from = n + 1 - shown - @intFromBool(scrolls); + for (from..n + 1) |i| { + const fresh = std.math.clamp(arrives * theme.time.move / theme.time.quick - 1, 0, 1); + const v = if (i == n) u.faded(fresh) else u; + const row: f32 = @as(f32, @floatFromInt(i - from)) - if (scrolls) scroll else 0; + const y = top + row * row_h; logRow(v, rec, rec.syscalls[i], y, box.w - theme.metric.context.side); // The newest's turned corner; the one before keeps it until the new row is in. if (i == n) v.corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1); - if (i + 1 == n and arrives < 1) u.faded(1 - arrives).corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1); + if (i + 1 == n and fresh < 1) u.faded(1 - fresh).corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1); } } + fn logNote(u: ui.Ui, above: usize) []const u8 { + return if (above > 0) u.print("as strace writes them \u{00b7} newest at the bottom \u{00b7} {d} more above", .{above}) else "as strace writes them \u{00b7} newest at the bottom"; + } + /// A call as strace writes it, its arguments by name: `read fd 3 - /// "note" buf 7fffffffecd0 count 32 = 15`, cut at `room` with `…`. + /// "note" buf 7fffffffecd0 count 32 = 15`, a path by its string (as the + /// kernel took it, where the stop did not read it). Out of room the + /// faint names go first, then the arguments from the right (`…`); what + /// it returned stays. fn logRow(u: ui.Ui, rec: *const Recording, made: Recording.Syscall, y: f32, room: f32) void { const base = theme.baseline(y, row_h, size); const adv = ui.advance(size); @@ -301,16 +326,18 @@ pub const Crossing = struct { x += u.width(.mono_bold, size, name) + adv; const names = zt.syscalls.names(made.nr); const n = @min(zt.syscalls.signature(made.nr).len, 6); - const Part = struct { text: []const u8, ink: u24 }; + const Part = struct { text: []const u8, ink: u24, name: bool = false }; var parts: [32]Part = undefined; var np: usize = 0; for (0..n) |j| { const what = if (j < names.len) names[j] else ""; if (what.len > 0) { - parts[np] = .{ .text = what, .ink = theme.color.text.dim }; + parts[np] = .{ .text = what, .ink = theme.color.text.dim, .name = true }; np += 1; } - parts[np] = .{ .text = @import("disasm.zig").argument(u, rec, made.enter, what, made.args[j]), .ink = theme.color.text.primary }; + var said = @import("disasm.zig").argument(u, rec, made.enter, what, made.args[j]); + if (std.mem.eql(u8, what, "path") and said[0] != '"' and made.text.len > 0) said = u.print("\"{s}\"", .{made.text[0 .. std.mem.indexOfScalar(u8, made.text, 0) orelse made.text.len]}); + parts[np] = .{ .text = said, .ink = theme.color.text.primary }; np += 1; if (std.mem.endsWith(u8, what, "fd")) { const on = rec.openOn(u.f.scratch, made.args[j], made.enter); @@ -320,19 +347,25 @@ pub const Crossing = struct { } } } - parts[np] = .{ .text = "=", .ink = theme.color.text.faint }; - np += 1; - parts[np] = .{ .text = if (made.exit != null) result(u, made) else "?", .ink = theme.color.text.primary }; - np += 1; + const answer = u.print("= {s}", .{if (made.exit != null) result(u, made) else "?"}); + const answer_w = u.width(.mono, size, answer); + var total: f32 = 0; + for (parts[0..np]) |part| total += u.width(.mono, size, part.text) + adv; + // The faint names first, where all of it does not fit. + const named = x + total + answer_w <= room; for (parts[0..np]) |part| { + if (part.name and !named) continue; const w = u.width(.mono, size, part.text); - if (x + w > room) { + if (x + w + adv + answer_w > room) { u.text(.mono, size, x, base, "\u{2026}", theme.color.text.faint); - return; + x += 2 * adv; + break; } u.text(.mono, size, x, base, part.text, part.ink); x += w + adv; } + u.text(.mono, size, x, base, "=", theme.color.text.faint); + u.text(.mono, size, x + 2 * adv, base, answer[2..], theme.color.text.primary); } /// Its view: the bytes the call crossing in this step is given or @@ -390,6 +423,7 @@ pub const Crossing = struct { .region = context.ink(context.regionOf(now.moment(), sp.addr)), .given = .{ .addr = sp.addr, .bytes = text, .shows = 1, .since = if (fills(given) != null) tm - p.fills else null }, .read = if (bufferRead(given) != null) now.held(p.work) else 0, + .pins = true, }); v.veil(now); } diff --git a/anim/src/ties.zig b/anim/src/ties.zig index e25c34b..58ada36 100644 --- a/anim/src/ties.zig +++ b/anim/src/ties.zig @@ -46,8 +46,10 @@ pub const Place = union(enum) { node_pin: u64, /// A part of a node (its value, its pointer half), by the address of the field it is drawn from. node_part: u64, - /// A run of bytes in the lens's dump, by its address. + /// A run of bytes in the lens's dump, by its address; a view's row, by + /// its first byte's: where a link to what a register points at lands. dump_run: u64, + dump_pin: u64, /// The source's current line; the disassembly's pc row; each run of /// the current line's instructions in the disassembly. source, @@ -69,6 +71,7 @@ pub const Place = union(enum) { .source => 10 << 56, .pc => 11 << 56, .run => |k| 12 << 56 | @as(u64, k), + .dump_pin => |a| 13 << 56 | (a & low), }; } }; @@ -178,6 +181,8 @@ pub const Ties = struct { threaded: bool = true, /// No links: the registers are not marked (`Registers.quiet`). quiet: bool = false, + /// A link the scene plays on a beat of its own (`Context.tiesWith`). + beat: ?*const Beat = null, pub fn draw(g: *const Ties, f: *sk.Frame, at: anim.Placed) void { defer said = 0; @@ -192,7 +197,8 @@ pub const Ties = struct { raw.at.xf = .identity; const k = at.scale; const split = g.stage.now(at); - if (g.threaded) thread(raw, at, k); + if (g.threaded) thread(raw.faded(@import("context.zig").thread_shows), at, k); + if (g.beat) |b| named(raw, at, now, k, split, b); if (!now.walking()) return; if (!g.quiet) g.link(raw, at, now, k, split); g.projection(raw, at, now, k, split); @@ -217,84 +223,119 @@ pub const Ties = struct { } /// The step's link: the first register it struck that now holds the - /// address of a pinned thing (a stack slot, a node). rip and rsp are - /// where execution and the stack are, and have none. + /// address of a pinned thing (a stack slot, a node, a view's row). rip + /// and rsp are where execution and the stack are, and have none. fn link(g: *const Ties, raw: ui.Ui, at: anim.Placed, now: cursors.Now, k: f32, split: theme.layout.Split) void { const rec = g.cursor.rec; const regs = (now.moment().regs(rec.tid) catch null) orelse return; - const edge = find(.registers) orelse return; for (theme.metric.all_registers[0..16]) |name| { const i = @import("context.zig").index(name).?; if (now.registerAge(i) != 0 or std.mem.eql(u8, name, "rsp")) continue; const value = regs.named(name) orelse continue; - const from = find(.{ .register = i }) orelse continue; - const node = find(.{ .node_pin = value }); - // A word of the stack outside its window: the link ends at the - // window's edge, with a stub and how many words on it is. - var beyond: ?i64 = null; - const target = node orelse find(.{ .slot_pin = value }) orelse edge: { - const w = stack_window orelse continue; - if (value % 8 != 0 or rows.regionOf(now.moment(), value) != .stack) continue; - const words = @as(i64, @bitCast(value -% w.first)) >> 3; - if (words >= 0 and words < w.slots) continue; - if (@abs(words) > 64) continue; - beyond = if (words < 0) words else words - @as(i64, @intCast(w.slots)) + 1; - // Its nearest row's pin lane. - const y = if (words < 0) w.top else w.top + @as(f32, @floatFromInt(w.slots - 1)) * w.row; - break :edge [4]f32{ w.x, y, w.x + 10 * k, y + w.row }; - }; const since = linkSince(now, i); const l = time.link; - const drawn = cursors.standard(std.math.clamp((since - l.after) / linkTime(if (node != null) .node else .slot), 0, 1)); + const node = find(.{ .node_pin = value }) != null; + const drawn = cursors.standard(std.math.clamp((since - l.after) / linkTime(if (node) .node else .slot), 0, 1)); const back = std.math.clamp((now.time - now.plan.advance) / l.out, 0, 1); - if (drawn <= 0 or back >= 1) return; - const color = rows.ink(rows.regionOf(now.moment(), value)); - const y = (from[1] + from[3]) / 2; - // What climbs into the band takes the gutter's left lane; what - // goes down to a slot, the right. - const lane = at.xf.apply(.{ if (node != null) theme.metric.tie.link_lane else theme.metric.tie.projection_lane, 0 })[0]; - var points: [5]ui.Vec = undefined; - var n: usize = 0; - points[0] = .{ edge[0] + 2 * k, y }; - points[1] = .{ lane, y }; - if (node) |pin| { - // Up the gutter, along the lens's bottom lane, up into the pin under the node. - const bottom = at.xf.apply(.{ 0, split.band.y + split.band.h - theme.metric.lens.bottom_lane })[1]; - const cx = (pin[0] + pin[2]) / 2; - points[2] = .{ lane, bottom }; - points[3] = .{ cx, bottom }; - points[4] = .{ cx, pin[1] }; - n = 5; - } else if (beyond) |words| { - // Off the window: to its nearest row, into the pin lane, out - // to the panel's rule, where a head points on. - const mid = (target[1] + target[3]) / 2; - const rule = if (words < 0) target[1] - 6 * k else target[3] + 6 * k; - points[2] = .{ lane, mid }; - points[3] = .{ target[0] + 6 * k, mid }; - points[4] = .{ target[0] + 6 * k, rule }; - n = 5; - } else { - // Along the gutter to the slot's row, and into its pin lane. - const mid = (target[1] + target[3]) / 2; - points[2] = .{ lane, mid }; - points[3] = .{ target[0] - 2 * k, mid }; - n = 4; - } - raw.route(points[0..n], color, .{ .width = theme.stroke.tie.link * k, .head = if (beyond == null) .{ 10 * k, 10 * k } else .{ 9 * k, 12 * k }, .progress = drawn, .from = cursors.standard(back), .radius = theme.metric.tie.radius * k }); - if (beyond) |words| if (drawn >= 1) { - // How far the target is, faint, 6 past the head. - const v = raw.faded(1 - std.math.clamp((now.time - now.plan.advance) / l.out, 0, 1)); - const tip = points[4]; - v.text(.mono, theme.size.mono.context, tip[0] + 12 * k, tip[1] + (if (words < 0) @as(f32, 6) else 14) * k, v.print("{d} rows", .{@abs(words)}), theme.color.text.faint); - }; - // The pin rides the line's head: the register's name beside it. - if (drawn > 0 and drawn < 1 and beyond == null) { - const tip = along(points[0..n], drawn); - raw.text(.mono_bold, theme.size.mono.context, tip[0] + 8 * k, tip[1] - 6 * k, name, theme.color.text.primary); - } - return; + if (linkTo(raw, at, now, k, split, name, value, drawn, back)) return; + } + } + + /// A link from register `name` to what it points at (`value`): a node's + /// pin, a slot's, a view's row, or a slot past the stack's window (a + /// stub and a row count), `drawn` of the way and drawing back `back` of + /// it. False where `value` is no such place. + fn linkTo(raw: ui.Ui, at: anim.Placed, now: cursors.Now, k: f32, split: theme.layout.Split, name: []const u8, value: u64, drawn: f32, back: f32) bool { + const i = @import("context.zig").index(name) orelse return false; + const edge = find(.registers) orelse return false; + const from = find(.{ .register = i }) orelse return false; + const node = find(.{ .node_pin = value }); + // A view's row it points into: up the gutter to the row's left edge. + const row = if (node == null) find(.{ .dump_pin = value & ~@as(u64, 15) }) else null; + // A word of the stack outside its window: the link ends at the + // window's edge, with a stub and how many words on it is. + var beyond: ?i64 = null; + const target = node orelse find(.{ .slot_pin = value }) orelse row orelse edge: { + const w = stack_window orelse return false; + if (value % 8 != 0 or rows.regionOf(now.moment(), value) != .stack) return false; + const words = @as(i64, @bitCast(value -% w.first)) >> 3; + if (words >= 0 and words < w.slots) return false; + if (@abs(words) > 64) return false; + beyond = if (words < 0) words else words - @as(i64, @intCast(w.slots)) + 1; + // Its nearest row's pin lane. + const y = if (words < 0) w.top else w.top + @as(f32, @floatFromInt(w.slots - 1)) * w.row; + break :edge [4]f32{ w.x, y, w.x + 10 * k, y + w.row }; + }; + const l = time.link; + if (drawn <= 0 or back >= 1) return true; + const color = rows.ink(rows.regionOf(now.moment(), value)); + const y = (from[1] + from[3]) / 2; + // What climbs into the band takes the gutter's left lane; what + // goes down to a slot, the right. + const lane = at.xf.apply(.{ if (node != null or row != null) theme.metric.tie.link_lane else theme.metric.tie.projection_lane, 0 })[0]; + var points: [5]ui.Vec = undefined; + var n: usize = 0; + points[0] = .{ edge[0] + 2 * k, y }; + points[1] = .{ lane, y }; + if (node) |pin| { + // Up the gutter, along the lens's bottom lane, up into the pin under the node. + const bottom = at.xf.apply(.{ 0, split.band.y + split.band.h - theme.metric.lens.bottom_lane })[1]; + const cx = (pin[0] + pin[2]) / 2; + points[2] = .{ lane, bottom }; + points[3] = .{ cx, bottom }; + points[4] = .{ cx, pin[1] }; + n = 5; + } else if (beyond) |words| { + // Off the window: to its nearest row, into the pin lane, out + // to the panel's rule, where a head points on. + const mid = (target[1] + target[3]) / 2; + const rule = if (words < 0) target[1] - 6 * k else target[3] + 6 * k; + points[2] = .{ lane, mid }; + points[3] = .{ target[0] + 6 * k, mid }; + points[4] = .{ target[0] + 6 * k, rule }; + n = 5; + } else { + // Along the gutter to the row, and into its pin lane (a view's row: to its edge). + const mid = (target[1] + target[3]) / 2; + points[2] = .{ lane, mid }; + points[3] = .{ target[0] + (if (row != null) @as(f32, 2) else -2) * k, mid }; + n = 4; + } + raw.route(points[0..n], color, .{ .width = theme.stroke.tie.link * k, .head = if (beyond == null) .{ 10 * k, 10 * k } else .{ 9 * k, 12 * k }, .progress = drawn, .from = cursors.standard(back), .radius = theme.metric.tie.radius * k }); + if (beyond) |words| if (drawn >= 1) { + // How far the target is, faint, 6 past the head. + const v = raw.faded(1 - back); + const tip = points[4]; + v.text(.mono, theme.size.mono.context, tip[0] + 12 * k, tip[1] + (if (words < 0) @as(f32, 6) else 14) * k, v.print("{d} rows", .{@abs(words)}), theme.color.text.faint); + }; + // The pin rides the line's head: the register's name beside it. + if (drawn > 0 and drawn < 1 and beyond == null) { + const tip = along(points[0..n], drawn); + raw.text(.mono_bold, theme.size.mono.context, tip[0] + 8 * k, tip[1] - 6 * k, name, theme.color.text.primary); } + _ = l; + return true; + } + + /// The scene's `Beat`: its register framed as read, then its link. + fn named(raw: ui.Ui, at: anim.Placed, now: cursors.Now, k: f32, split: theme.layout.Split, b: *const Beat) void { + const t = at.value(b.t); + if (t < 0 or t >= b.total()) return; + const i = @import("context.zig").index(b.name) orelse return; + const px = find(.{ .register = i }) orelse return; + const l = time.link; + const back = std.math.clamp((t - (b.total() - l.out)) / l.out, 0, 1); + // Its value framed as read, in the panel's units. + const u: ui.Ui = .{ .f = raw.f, .at = at }; + const inv = at.xf.invert(); + const a = inv.apply(.{ px[0], px[1] }); + const c = inv.apply(.{ px[2], px[3] }); + u.read(.{ .x = a[0], .y = a[1], .w = c[0] - a[0], .h = c[1] - a[1] }, std.math.clamp(t / time.read.in, 0, 1) * (1 - back)); + const rec = b.cursor.rec; + const regs = (now.moment().regs(rec.tid) catch null) orelse return; + const value = regs.named(b.name) orelse return; + const drawn = cursors.standard(std.math.clamp((t - l.after) / l.in_far, 0, 1)); + _ = linkTo(raw, at, now, k, split, b.name, value, drawn, back); } /// The step's projection: the first run of bytes it read or wrote in @@ -361,6 +402,31 @@ pub const Ties = struct { } }; +/// A link the narration plays on a beat the caption names, not a step's: +/// register `name` framed as read (6 f), then its link to what it points at +/// (6 f after, 36 f, `standard`, the name riding its head), held `hold`, +/// and drawn back with the frame (18 f). +pub const Beat = struct { + cursor: cursors.Cursor, + name: []const u8, + hold: f32, + /// Seconds into it; negative: none. + t: anim.Value, + + pub fn total(b: *const Beat) f32 { + return time.link.after + time.link.in_far + b.hold + time.link.out; + } + + /// Plays it from here; the scene's cursor stays where it was. + pub fn play(b: *const Beat, s: *anim.Frame) void { + const start = s.cursor; + s.play(.{b.t.to(0)}, .{ .seconds = 0 }); + s.play(.{b.t.to(b.total())}, .{ .seconds = b.total(), .ease = anim.ease.linear }); + s.play(.{b.t.to(-1)}, .{ .seconds = 0 }); + s.cursor = start; + } +}; + /// The point `p` of the way along the straight path through `points`. fn along(points: []const ui.Vec, p: f32) ui.Vec { var total: f32 = 0; diff --git a/anim/src/ui.zig b/anim/src/ui.zig index d770e05..bcefff3 100644 --- a/anim/src/ui.zig +++ b/anim/src/ui.zig @@ -487,6 +487,21 @@ pub const Ui = struct { sk.draw.polygon(u.f, &.{ .{ hx + p.row_head[0], mid }, .{ hx, mid - p.row_head[1] / 2 }, .{ hx, mid + p.row_head[1] / 2 } }, u.at.pen(.{ .fill = rgb(ink) })); } + /// `pin` `row` at a dump row's right end (a view has no lane before its + /// addresses): the head pointing left at the row, then the names, + /// ending at `right`. Returns where it begins. + pub fn pinEnd(u: Ui, right: f32, y: f32, names: []const []const u8, ink: anytype) f32 { + const size = theme.size.mono.context; + const p = theme.metric.pin; + const shown = joined(u, names); + const x = right - u.width(.mono, size, shown); + u.text(.mono_bold, size, x, theme.baseline(y, theme.metric.context.row, size), shown, theme.color.text.primary); + const hx = x - p.row_gap; + const mid = y + theme.metric.context.row / 2; + sk.draw.polygon(u.f, &.{ .{ hx - p.row_head[0], mid }, .{ hx, mid - p.row_head[1] / 2 }, .{ hx, mid + p.row_head[1] / 2 } }, u.at.pen(.{ .fill = rgb(ink) })); + return hx - p.row_head[0]; + } + /// `pin` `under`: a stub 3 wide rising `size` + 10 to a node's bottom /// edge at (`cx`, `y`), a head 10 by 10 on it, the first name left of /// the stub and the others right, bold, primary. diff --git a/anim/src/words.zig b/anim/src/words.zig index 4d221f4..f66f6d2 100644 --- a/anim/src/words.zig +++ b/anim/src/words.zig @@ -162,9 +162,10 @@ pub const Veil = struct { /// it means: the same in every picture. pub const Legend = struct { box: Rect, - entries: []const Entry = &.{ .current, .written, .changed, .read, .link, .allocated, .freed, .unknown, .kernel }, + /// The marks the scenes use. + entries: []const Entry = &.{ .current, .written, .changed, .read, .waiting, .unknown, .link, .pin, .arc, .loupe, .freed, .kernel }, - pub const Entry = enum { current, written, changed, read, link, allocated, freed, unknown, kernel }; + pub const Entry = enum { current, written, changed, read, link, pin, arc, loupe, waiting, freed, unknown, kernel }; pub fn draw(l: *const Legend, f: *sk.Frame, at: anim.Placed) void { const u: ui.Ui = .{ .f = f, .at = at }; @@ -182,7 +183,10 @@ pub const Legend = struct { .changed => .{ "changed", "a moment ago" }, .read => .{ "read", "by this step" }, .link => .{ "link", "now points at that" }, - .allocated => .{ "allocated", "handed out" }, + .pin => .{ "pin", "who points here" }, + .arc => .{ "arc", "a pointer in its panel" }, + .loupe => .{ "loupe", "where it points" }, + .waiting => .{ "waiting", "for the call it made" }, .freed => .{ "freed", "handed back" }, .unknown => .{ "not seen", "never observed" }, .kernel => .{ "kernel", "the other side" }, @@ -211,9 +215,22 @@ pub const Legend = struct { u.label(.mono, size, cell, .center, digits, t.primary); }, .link => u.route(&.{ .{ r.x, r.y + 23 }, .{ r.x + r.w, r.y + 23 } }, theme.color.region.heap, .{ .width = theme.stroke.tie.link, .head = .{ 10, 10 } }), - .allocated => { - u.fill(r, theme.mark(.allocated).ember); - u.frame(r, theme.mark(.allocated).solid, theme.stroke.line); + .pin => u.pinRow(r.x, r.y + 11, &.{"rsp"}, theme.color.region.stack), + .arc => { + const k = theme.metric.arc; + u.route(&.{ .{ r.x + r.w, r.y + 8 }, .{ r.x + 20, r.y + 8 }, .{ r.x + 20, r.y + 38 }, .{ r.x + r.w, r.y + 38 } }, theme.color.region.heap, .{ .width = k.width, .head = k.head, .radius = k.radius }); + }, + .loupe => { + const k = theme.metric.loupe.shadow[0]; + u.fill(.{ .x = r.x + k[0] / 2, .y = r.y + k[1] / 2, .w = r.w - k[0] / 2, .h = r.h - k[1] / 2 }, theme.color.shade); + const lifted: Rect = .{ .x = r.x, .y = r.y, .w = r.w - k[0] / 2, .h = r.h - k[1] / 2 }; + u.fill(lifted, theme.color.lift); + u.fill(.{ .x = r.x, .y = r.y, .w = lifted.w, .h = 10 }, theme.color.lift_tag); + u.frame(lifted, t.dim, theme.stroke.rule); + }, + .waiting => { + u.frame(.{ .x = r.x + 1, .y = r.y + 1, .w = r.w - 2, .h = r.h - 2 }, t.primary, theme.stroke.rule); + u.label(.mono, size, r, .center, "call", t.primary); }, .freed => u.dashedFrame(r, theme.mark(.freed).solid, theme.stroke.line), .unknown => { diff --git a/anim/test/gallery.script b/anim/test/gallery.script index fb71697..993ff7e 100644 --- a/anim/test/gallery.script +++ b/anim/test/gallery.script @@ -3,31 +3,31 @@ # (its timings change from run to run). A screenshot is saved on the frame after. frames 2 console set playing false -console set t 0.5 +console set t 1.5 screenshot {dir}/atoms.png frames 1 expect-same-screenshot {dir}/atoms.png test/gallery/atoms.png 24 0 0 1920 1040 -console set t 1.5 +console set t 4.5 screenshot {dir}/rows.png frames 1 expect-same-screenshot {dir}/rows.png test/gallery/rows.png 24 0 0 1920 1040 -console set t 2.4 +console set t 7.4 screenshot {dir}/rest.png frames 1 expect-same-screenshot {dir}/rest.png test/gallery/rest.png 24 0 0 1920 1040 -console set t 3.6 +console set t 9.6 screenshot {dir}/step.png frames 1 expect-same-screenshot {dir}/step.png test/gallery/step.png 24 0 0 1920 1040 -console set t 6.4 +console set t 13.4 screenshot {dir}/subject.png frames 1 expect-same-screenshot {dir}/subject.png test/gallery/subject.png 24 0 0 1920 1040 -console set t 8.4 +console set t 16.4 screenshot {dir}/none.png frames 1 expect-same-screenshot {dir}/none.png test/gallery/none.png 24 0 0 1920 1040 -console set t 10.8 +console set t 19.8 screenshot {dir}/loupe.png frames 1 expect-same-screenshot {dir}/loupe.png test/gallery/loupe.png 24 0 0 1920 1040 diff --git a/anim/test/gallery/atoms.png b/anim/test/gallery/atoms.png Binary files differindex 3bfd6ec..6e64609 100644 --- a/anim/test/gallery/atoms.png +++ b/anim/test/gallery/atoms.png diff --git a/anim/test/gallery/loupe.png b/anim/test/gallery/loupe.png Binary files differindex 7661f53..346bd44 100644 --- a/anim/test/gallery/loupe.png +++ b/anim/test/gallery/loupe.png diff --git a/anim/test/gallery/none.png b/anim/test/gallery/none.png Binary files differindex 8abce55..39f0206 100644 --- a/anim/test/gallery/none.png +++ b/anim/test/gallery/none.png diff --git a/anim/test/gallery/rest.png b/anim/test/gallery/rest.png Binary files differindex 61829aa..9dfdbe2 100644 --- a/anim/test/gallery/rest.png +++ b/anim/test/gallery/rest.png diff --git a/anim/test/gallery/rows.png b/anim/test/gallery/rows.png Binary files differindex 2d11a94..7e6ba84 100644 --- a/anim/test/gallery/rows.png +++ b/anim/test/gallery/rows.png diff --git a/anim/test/gallery/step.png b/anim/test/gallery/step.png Binary files differindex 232b235..b85cba0 100644 --- a/anim/test/gallery/step.png +++ b/anim/test/gallery/step.png diff --git a/anim/test/gallery/subject.png b/anim/test/gallery/subject.png Binary files differindex 1175df7..d912474 100644 --- a/anim/test/gallery/subject.png +++ b/anim/test/gallery/subject.png diff --git a/anim/tools/chart.py b/anim/tools/chart.py index 320ba90..1384800 100644 --- a/anim/tools/chart.py +++ b/anim/tools/chart.py @@ -57,9 +57,9 @@ 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} +# `cut`: the gallery is the catalogue's pages, cut from one to the next (scenes/gallery.zig: 3, 6, 9.6, 13, 16 and +# 19.8 s), not a scene: a page's first frame changes everything at once by design. +PAGES = {180, 360, 576, 780, 960, 1188} 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] |
