summaryrefslogtreecommitdiff
path: root/anim
diff options
context:
space:
mode:
Diffstat (limited to 'anim')
-rw-r--r--anim/README.md239
-rw-r--r--anim/scenes/heap.zig249
-rw-r--r--anim/scenes/syscalls.zig10
-rw-r--r--anim/src/calls.zig6
-rw-r--r--anim/src/context.zig44
-rw-r--r--anim/src/cursor.zig195
-rw-r--r--anim/src/descent.zig114
-rw-r--r--anim/src/disasm.zig29
-rw-r--r--anim/src/hexdump.zig66
-rw-r--r--anim/src/loupe.zig39
-rw-r--r--anim/src/map.zig195
-rw-r--r--anim/src/nodes.zig1
-rw-r--r--anim/src/root.zig4
-rw-r--r--anim/src/rows.zig81
-rw-r--r--anim/src/source.zig14
-rw-r--r--anim/src/stage.zig2
-rw-r--r--anim/src/syscalls.zig176
-rw-r--r--anim/src/theme.zig7
-rw-r--r--anim/src/ui.zig7
-rw-r--r--anim/src/words.zig5
-rw-r--r--anim/test/gallery/atoms.pngbin104341 -> 104255 bytes
-rw-r--r--anim/test/gallery/loupe.pngbin237028 -> 237157 bytes
-rw-r--r--anim/test/gallery/none.pngbin226452 -> 226437 bytes
-rw-r--r--anim/test/gallery/rest.pngbin232319 -> 232782 bytes
-rw-r--r--anim/test/gallery/rows.pngbin138579 -> 140407 bytes
-rw-r--r--anim/test/gallery/step.pngbin231969 -> 232046 bytes
-rw-r--r--anim/test/gallery/subject.pngbin208224 -> 208454 bytes
-rw-r--r--anim/test/recordings.zig10
-rw-r--r--anim/tools/chart.py73
29 files changed, 1177 insertions, 389 deletions
diff --git a/anim/README.md b/anim/README.md
index 3e7c8f4..27b0983 100644
--- a/anim/README.md
+++ b/anim/README.md
@@ -16,7 +16,7 @@ zig build test # unit tests, each scene run headless,
zig build gallery # the gallery's pictures drawn anew into test/gallery
zig build bench # what a recording costs a frame
zig build bench -- NAME BY [FUNCTION] # a recording's steps (BY: moment, line, over), with what each changed
-python3 tools/chart.py chart out/fib-1080.mp4 --out out/motion/fib # the designer's timing chart and five checks
+python3 tools/chart.py chart out/fib-1080.mp4 --out out/motion/fib # the designer's timing chart and checks (POP, CROWD, METRONOME, CAPTION, AIR)
```
Needs what sketchbook and ztrace need, and `setarch`, `clang` (the pass
@@ -67,20 +67,23 @@ state at the cursor, at the box its `Stage` gives it now.
a later one (`Recording.Stop`: `.moment`, `.line`, `.over`, `.call`,
`.syscall`). For each step it writes a timetable, a `Plan`: the cascade.
The line fires (12 f); each level the step touched strikes 18 f after the one
-before, in the order CPU, memory, idea (a level the scene does not show, or
+before (after the last of its registers, which strike 6 f apart), in the order CPU, memory, idea (a level the scene does not show, or
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
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) or a sprint, `step` takes an explicit `Plan` (`Array.swap`,
+step: nothing struck, no held corner, no arc, a dump's values crossfading
+over 8 f; the arcs fade back in as it ends) or a sprint, `step` takes an explicit `Plan` (`Array.swap`,
`syscalls.step`), and `continue` goes to a stop far from this one (a
breakpoint): the line it leaves fires, the registers it changed strike in
a wave 2 f apart in pwndbg's order (fill 6 f, no arm, no pulse), then
memory and the idea, a 36 f hold, the mark out and in (6 f each, the
source fading through first if far), a 24 f rest. Components read it
-through `Cursor.now(at)`.
+through `Cursor.now(at)`; the minimap reads the same values 6 f behind
+(`Cursor.lag`, `time.minimap_lag`), so nothing on it starts on a primary
+onset's frame.
## The scenes
@@ -90,8 +93,8 @@ through `Cursor.now(at)`.
| `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, 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 crossing opening under its call | `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; the chunks by fields (`size`, `protected`, `key`), the program's list over the tcache's free list with its `bin`, the tcache in a loupe hung from its chunk's row | `subject`, the scene's own drawing (`nodes` in two rows) and view | `heap` |
+| `syscalls` | glibc's `hello`, by instruction from main: `open` followed down (main's call ringed, the PLT's stub passed, libc's wrapper run to its last three instructions and those walked, the kernel's window at the floor with the call in C's form and `returns`, and back up), then `read`, `close`, `write` stepped over, each in three parts: the instructions before the call a cascade onto the call row, the crossing from that row with the kernel's window opening under it (the rows after it making room), the stores after it 18 f after rax | `beside`, `syscalls` (the calls so far, as strace writes them); the disassembly a `descent` (`Context.Options.descent`) | `hello` |
+| `heap` | glibc's malloc under a list of three: three pushes, two pops, a push, told by motion.md's storyboard (nine captions; pushes 2 and 3 at a run; each `free` and the `malloc` that takes the head back walked); the chunks by fields (`size`, `protected`, `key`), the program's list over the tcache's free list with its `bin` (a chunk in neither list drawn in the program's row, unarrowed), the tcache in a loupe over the stack, its stem down the gutter from its chunk's row, opened in each step that changes the tcache and closed at its advance | `subject`, the scene's own drawing (`nodes` in two rows) and view | `heap` |
| `zoom` | one line of C as its instructions, the call's bytes | `none`, the camera at x2 | `steps` |
| `sqlite` | a row's way to disk in SQLite: from `sqlite3_step` to `sqlite3BtreeInsert` (three continues, the row's struct on the stack), the commit's `unixWrite` nine calls under `main`, `pwrite64` of page 2 into the kernel, and the page read as a B-tree leaf | `subject`, `backtrace` (`Context.Options.backtrace`), then `syscalls`; its view a `hexdump.Dump` | `sqlite` |
| `gallery` | every block in its states | all three | `gallery` |
@@ -105,19 +108,19 @@ every state the code has in the `gallery` scene.
| --- | --- | --- | --- |
| 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 |
-| 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, `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 |
+| | `byte` | `src/rows.zig` `bytes` | `number`, `pointer`, `text` (a string's ink), `loose` (a byte of no field: the allocator's, padding, past what a dump is of), `unread`; `pad`; `bytesAt` moves the bytes right of a long (stack) address, by the dump's widest; a write's arm, strike and held corner cover the bytes whose value changed, first to last (`Run.changed`, `Now.changedBytes`), struck a byte a frame from the low address (what a read fills, 2 f apart) |
+| 2 row | `chain`, `reg` (and `rip` with the flags), `slot`, `line`, `bytes`, `call` (`span`, `callRow`) | `src/rows.zig` | `chain` follows `zt.telescope.chase`; cut at its far end, `more`. `slot`: pins from 16, the offset from rsp ranged right to 172, the address at 184, the chain, its role ranged right where the room ends, from `zt.telescope.slots` (`saved rbx`, a local's name in primary, `n, high half` for a narrower local in the word's top four bytes, `argc`, `argv[0]`, `argv end`, `envp end`, `auxv`; nothing for a return address or `.none`). `bytes`: the bracket at 24, the address at 34, the bytes 12 after it and at 132 at least |
| | `arc` | `src/rows.zig` (`Arcs`), `src/hexdump.zig` (`pointerArcs`) | a pointer to a row of its own panel: lanes at 4, 10, 16 in a dump or a loupe, 4 and 10 on the stack; longest outermost, a chain in one lane; standing at 60% toward the page, full in the step that writes or reads it and always in a loupe; rewritten: the old dashed with the arm, fading from 6 f after the strike as the new draws (12 f), quieting with the cool; a stub to the rule for a target in the region past the window, only in its step; a saved rbp's only in its step; a dump withholds the arcs an open loupe carries |
-| | `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`); 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) |
-| | `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; 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 up the lane, the window drawing back at the advance. A crossing stepped over opens the same window at the floor under the call's line. 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: `descend` (2.7 s), on through a stub's `jmp` (2.0 s), `ascend` (2.3 s), `cross` (`syscalls.step`); with it the source's line `waiting` (ringed, the tag `main waits at line 6 · the pc is in libc's open`) and the thread waiting (primary, 2) |
+| | `insn` | `src/disasm.zig` | columns at 2, 31, 40, 134, 180, 264, 564; size words dropped from every operand, a `width` of byte cells (`metric.width`) after the `]` where no register outside the brackets has the access's size and the mnemonic does not fix it; `nop` and `endbr64` faint; a PLT target named (`401070 open@plt`); the annotation from 564 or a character after the operands, then the operands give way, never inside `[]`; `current`, `ran` (every instruction of the last three steps), `ahead`, `outside`, `waiting`, `pass`; the jump lane from the jump just before the pc's moment. The row's detail, every value the recording's at that moment: a compare's two values and the flags it leaves as chips (those the conditional after it reads; CF ZF SF OF when none); a conditional's `taken`/`not taken · reads` and its flags, `→ target` when it leaves the window, and while it runs the setting row's chips and rip's framed as read (an echo); `lea`'s `= value`; a call through memory or a register `→ target name · read from open@got, 403fd8` (out of room the slot goes, then the digits); a call through a PLT stub by the function it reaches (`the resolver` while its slot is lazy); `fs:[0x28]` as the stack's canary (`canary` where the row has no room); a `rep`'s count and step; `syscall` with its name and number, its arguments under it by register, typed (`-100 AT_FDCWD`, `O_RDONLY`), the rows they hang over giving up their own annotation; a call that has run in C's form with its result (`read(3, …) = 15`: out of room the arguments go from the right, the result stays); a memory access narrower than a word read at its width (`rows.narrow`: `7fffffffecc4 ◂ 15`) |
+| | `descent` | `src/descent.zig` (`Descent`, `step`) | the disassembly a call deep: the root's window on top (main), each callee's under the row that called it (that row `waiting`, ringed, its annotation the call in C's form), a PLT stub gone through kept as its `jmp`, `pass`; a head row over each window (the name at 40, Go Medium 18; what it is ranged right: `libc.so.6 · no source`, `the PLT · its jmp reads open@got, 403fd8`, `the PLT, jumped through`); the call lane at x 14; the nearest caller takes the rows the deepest does not use, all above its call row (one row after it, the return row, the callee's head directly under that), and where its function starts first the rest go back to the deepest window; three code windows at most, the rest one `more` row; each window's addresses its own width; the tag the deepest function and its module (`open · libc.so.6`); at a `syscall` (and the stop after it) the floor's three rows are the kernel's: in a crossing the lane down from the plaque (3, vellum), the window filling down, `the kernel` and `openat, system call 257`, the call in C's form, `returns` struck, `rcx, r11: clobbered`, the answer climbing the lane (24 f, `glide`), the window drawing back at the advance. A crossing stepped over opens the same window under the call row, past the arguments hanging under it, the rows after them making room (18 f) and closing up with the window. Every row keyed (an address, a head), so a step is the rows both stops have gliding and the rest leaving or arriving on its verb's timetable, in two moves, never at once: `descend` (2.9 s: the given-up rows fade 66–78, the kept ones glide 78–96, ring 84–96, lane 96–114, head 108–120, rows 114–138), on through a stub's `jmp` (2.2 s), `ascend` (2.5 s: the window closes 48–72, lane back 72–84, the kept rows glide 84–102, the given-up ones fade in 102–114), `cross` (`syscalls.step`); a row whose state the verb changes (the call row to `waiting` with its hanging arguments, a jmp to `pass`, a waiting call taking its result) crossfades; with it the source's line `waiting` (ringed, the tag `main waits at line 6 · the pc is in libc's open`, crossfading over the 12 f before the advance, as a stack span's name does) and the thread waiting (primary, 2) |
| 3 panel | `registers`, `stack`, `backtrace` | `src/context.zig` | the backtrace newest at the bottom, `#0` last, the oldest dropped from the top (`newest at the bottom · 2 more above`), as a panel, the calls lens's view, the backtrace lens and on the map; the stack's window on `[rsp, rbp+16)` keeping the touched word in view, its tag the first and last word shown (`rsp+20 to rsp+48`), rsp and rbp's pins travelling 18 f after rsp's strike (`time.pin`, keeping their place among the names they leave and join), at rest only where the register points; a window that moves farther than its own height (six or eight slots) fades out and in round memory's strike, and what it brings, and what changed before it, is plain; a frame's name longer than the spans' room shortens the chains beside it; `call` spans and the backtrace (`#n`, name, arguments at 384, file and line) from `zt.telescope.frames`, the frames two stops share sliding to their new depth; the backtrace as a lens's drawing with `Context.Options.backtrace` |
| | `source` | `src/source.zig` | the whole file in a window, its middle third; numbers as wide as the program's largest line (SQLite's six digits), the text moved right by as much; a window going farther than its own height fades out and in |
| | `disasm` | `src/disasm.zig` | 17 rows (9 as subject), fewer above near a function's start; the line column as wide as the source's; two windows that overlap scroll, others fade out and in |
| | `hexdump` | `src/hexdump.zig` | malloc's words: a field read as `size` (`0x20 a m P`, the bits as rip's flags) or `protected` (`→ 405050 ^ 405`, `NULL ^ 405`, its arc to the pointer it protects), and a field's `note` (Go 18 faint: `key`, `top`, `slots left`); a lens's view (`hexdump.panel`): `bytes` rows and their reading, veiled at a sprint; one reading for every dump (`hexdump.reading`), a list a character apart, a typed number as its type reads (`char` quoted, `bool` by name); the address room once a dump, by its widest; `Dump`, a view of a region by the fields a scene gives it (`Field`: where, how long, read as a number, big-endian or not, a pointer, text, or left to the eye), the rows that hold a field and a `more` row for each stretch left out, and where those rows outnumber the window, a window kept round the first row a mark or the step is on, the rest folded into `more` rows; marks the scene plays, and the step's only from the stop it came in at (`since`); the bytes a syscall was given as the kernel took them (`given`), and only what the debugger read at the stop (`seen`) |
-| | `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; from a register, or from a pointer field of a loupe; `open` 36 f (read 6, stem and rise 18 with the shadow, the frame 6 f after), `close` 12 f |
-| | 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 is given or fills, `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 |
+| | `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 |
| 4 tie | `thread`, `link` (and its `pin`), `projection`, `echo` | `src/ties.zig` | panels publish places (`anchor`); `Ties`, added last, draws in the channels: a link climbs to a node by the gutter's left lane and goes down to a slot by the right, its name riding its head, a target past the stack's window a stub and a row count; a projection from the view's bytes, or from a frame's return address to its call's node |
-| 5 frame | `map`, `minimap`, `dive`, `surface` | `src/map.zig` (`Map`, `split`, `minimap`), `Context.map` | the working frame's panels bound to a stage of 3840 by 2160 (`map.split`: the drawing and the source, the disassembly 69, the view 32, the registers and the backtrace, the stack 69 from 16 words above rsp); its rows published while `ui.mapping`; the working windows outlined (2 `dim`, 4 out); 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`), 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 in reading order, opaque on the way, its rows on the window's rows, its tag and rules in at the end; the map falls to the minimap's rect over 72 f; 120 f and 30 f still), `.surface` (the dive back, 84 f, then 30 f still); per-panel transforms through `context.at` (`context.zoomed`) |
+| 5 frame | `map`, `minimap`, `dive`, `surface` | `src/map.zig` (`Map`, `split`, `minimap`), `Context.map` | the working frame's panels bound to a stage of 3840 by 2160 (`map.split`, packed by content: each box as long as the most rows its panel has wanted, `measure`; the drawing, the source and under it the backtrace; the disassembly; the view, the registers, and in the column's rest the stack going on, `stack, continued`; the stack from 16 words above rsp); its rows published while `ui.mapping`; the working windows outlined (2 `dim`, 4 out); the thread across the gutter (x 1008), gold; the minimap the same at a twentieth under the clock (text as 1-unit strokes at 45% toward the page, marks as blocks; `ui.strokes`), 6 f behind the frame, a stack word struck outside the stack's window flashing on it (a ring 8 to 14, 12 f), the count ranged right at 1648; `Map.show`, `.dive` (outlines bright 6 f, veil to 24, each panel from its window to its place 60 f, 6 f apart, a panel drawn over another setting off first (drawing, view, disassembly, stack, source, registers) so that none in its place is crossed by one on its way, opaque on the way, its rows on the window's rows, its tag and rules in at the end; the map falls into the minimap's corner over 72 f, its scale on the logarithm, its corner going toward the minimap's as the scale does, small it is drawn over the panels with its edge, and crossfades into the minimap's drawing at 90–96; 120 f and 30 f still), `.surface` (the dive back, 84 f, then 30 f still); per-panel transforms through `context.at` (`context.zoomed`) |
| | `stage` and `relayout` | `src/stage.zig` | splits `none`, `beside`, `subject` (`theme.layout.split`): the band is `band` (the drawing) and `view`; `relayout` fades the drawing round its move; `holdStack` holds the stack's window for the camera, with `free` slots |
| | `clock`, `caption`, `veil`, `card` | `src/words.zig`, `src/root.zig` (`Narrator`, `Camera`) | the clock still while a step plays, its piece fading in once the mark lands; a caption stays its reading time; the title card is `scenes/title.zig` |
| 6 verb | `fire`, `arm`, `strike`, `cool`, `read`, `extend`, `link`, `project`, `travel` (pins), `advance`, `cascade`, `continue` (`Cursor.continue`, `Plan.wave`), `run`, `sprint`, `establish` (`Context.establish`: a drawing's elements fade in rising, no lines), `scroll`, `relayout`, `visit`, `say` | `src/cursor.zig` (the timetable), the blocks (each draws its state at the instant) | tokens in `theme.time`; a level gives up its slot when nothing it touched is drawn (`Recording.drawn`) |
@@ -162,124 +165,118 @@ holds is named from its module's first mapping (`list+2c89`).
## Motion, as measured
-`tools/chart.py chart` on the 1080p exports in `out/` (the designer's five
-checks; its regions are the working frame's; the minimap, 1664 to 1856 by
-912 to 1020, is in none; `syscalls` now has the `beside` split's regions,
-`heap` the `subject`'s). Encoded with `-g 600`: x264's keyframe at 10,
-20, 30 s is a one-frame fade the instrument sees. "Before" is the last
-pass's exports; "after" this pass's: operands without size words, the
-row's detail, the backtrace newest at the bottom, the syscalls scene
-remade on glibc by instruction with the descent, the heap scene new,
-`list` and `sort` recorded with `--stack 1024`.
+`tools/chart.py chart` on the 1080p exports (the designer's
+`design/motion/motion.py`, its checks and its regions told where canim's
+panels are; the clock, ranged right at 1648, its own region, whose count
+changing in a frame is no POP; the caption's box from 940, under the
+clock's count and a run's step counter; the minimap its own region,
+secondary action, and its one-frame changes POPs). POP: any region still
+for 12 f that changes in one frame and is still again. CAPTION: up over
+720 f, up under 90 f + 3.6 f a character (chart.py counts the characters
+of the scene's `says.line` strings as shown; where the video's arrivals
+and the scene's captions do not pair up it says so and checks no reading
+time), or the picture moving within 60 f of its arrival. Encoded with
+`-g 600`: x264's keyframe at 10, 20, 30 s is a one-frame fade the
+instrument sees. "Before" is the last pass's exports charted by this
+instrument (the old scenes' captions are not the sources' now:
+syscalls' and heap's reading times not checked); "after" this pass's.
-| | fib | list | sort | syscalls | zoom | sqlite | heap |
-| --- | --- | --- | --- | --- | --- | --- | --- |
-| POP, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | new / 0 |
-| CROWD, before / after | 2 / 2 | 6 / 6 | 4 / 4 | 1 / 5 | 3 / 3 | 1 / 0 | new / 10 |
-| RUSH, before / after | 2 / 0 | 2 / 2 | 0 / 0 | 1 / 2 | 0 / 0 | 2 / 2 | new / 3 |
-| AIR, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 2 | 1 / 1 | 5 / 5 | new / 2 |
-| METRONOME, after | 0 | 0 | 0 | 9 | 0 | 0 | 0 |
-| seconds, after | 41.5 | 70.9 | 42.0 | 75.9 | 32.0 | 64.6 | 100.4 |
+| | fib | list | sort | syscalls | zoom | sqlite | heap | gallery |
+| --- | --- | --- | --- | --- | --- | --- | --- | --- |
+| POP, before / after | 43 / 44 | 52 / 43 | 41 / 32 | 72 / 66 | 19 / 22 | 11 / 14 | 83 / 72 | 13 / 10 |
+| of them the minimap's, before / after | 13 / 16 | 31 / 26 | 17 / 15 | 45 / 47 | 12 / 14 | 5 / 8 | 49 / 48 | 6 / 5 |
+| CROWD, before / after | 2 / 2 | 6 / 8 | 4 / 5 | 5 / 2 | 3 / 3 | 0 / 0 | 10 / 7 | 3 / 4 |
+| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 9 / 9 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 |
+| CAPTION up over 720 f, before / after | 0 / 0 | 3 / 2 | 0 / 0 | 0 / 0 | 1 / 1 | 0 / 0 | 4 / 1 | 0 / 0 |
+| CAPTION under its reading time, after | 0 | not paired | 0 | 0 | 0 | 0 | 0 | |
+| CAPTION picture moving within 60 f, before / after | 0 / 0 | 1 / 1 | 0 / 0 | 1 / 1 | 0 / 0 | 2 / 2 | 1 / 1 | 0 / 0 |
+| AIR, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 2 / 2 | 1 / 1 | 5 / 5 | 2 / 0 | 0 / 0 |
+| seconds, before / after | 41.5 / 42.0 | 70.9 / 71.1 | 42.0 / 42.2 | 76.0 / 89.2 | 32.0 / 32.0 | 64.6 / 64.6 | 100.4 / 96.8 | 11.0 / 11.0 |
-New this pass, not examined frame by frame: syscalls' METRONOME (30.62
-to 33.00) is the run through libc's `open` to its `syscall`, steps 0.30 s
-apart by design (a run); its AIRs at 13.42 (3.9 s) and 20.90 (5.0 s) are
-the stage still under a long caption after a `descend` and after the
-stub's `jmp`, which wait for the caption before them to be read; its
-CROWDs (13.10, 59.80, 62.50, 68.50 and one more) are not examined. The
-heap scene's CROWDs (10.00 the keyframe; 15.62, 26.62, 40.22 and six
-more), its RUSHes (29.60, 29.93, 69.68) and its AIRs (65.62, 3.9 s;
-70.03, 7.2 s: the tcache's loupe open under a caption of 120
-characters) are not examined. fib's two RUSHes of the last pass are gone.
+What fires, and why it is left, by kind (examined this pass):
-What fires, and why it is left (as examined the last pass: the times of
-`list` and `sort` moved with their new recordings, and the syscalls scene
-named below is the old one):
-
-- CROWD: fib 12.05 and 27.20, list 30.62 and 32.18, sort 17.60 are the
- veil coming over the registers, stack and disassembly at the first
- shortened step (one veil over three panels); zoom 9.65 and 21.55 the
- camera (the regions are fixed on the screen); zoom 11.75 the stack's
- window scrolling to its hold under the camera (the stack fills every
- region there); sort 30.00 is x264's keyframe on a step's first frame.
- The rest (list 15.92, 19.32 and the others like them, sort 11.68,
- 29.42 and 36.13, syscalls 34.75, zoom 3.62) are an
- `advance`: the thread, the plaques and rip move as one mark, the
- source and the disassembly scroll with it, and a link or projection
- goes back into its pin, all on the catalogue's one frame. (sqlite's,
- the crossing's advance at 43.40, no longer starts with another panel.)
-- RUSH: list 29.20 and 29.55, syscalls 29.32, sqlite 9.10: a caption
- arrives, and the next change the instrument sees is the keyframe at
- 30.00 (10.00) (a fade of every region over one frame, 0.00% at its
- peak).
-- AIR: a caption's reading time on a still picture: the last one's and
- the 2 s on the finished picture (zoom 26.88, 3.1 s; sqlite 60.03,
- 4.6 s), and in sqlite four more, each a dense caption over a stop
- (11.38, 7.2 s: the arguments; 24.57, 3.2 s: the two more rows, now
- that a continue is a wave and a 36 f hold and not a cascade's longest
- hold; 32.95, 3.2 s: the commit's backtrace; 50.03, 4.9 s: the page's
- header), its fields framed as it names them.
+- POP, the minimap (about half of every scene's): it follows the frame
+ 6 f behind, but a row's stroke or a mark's block changes in one frame;
+ a fade of each change is not built.
+- POP, registers, stack, view: a read frame that goes in one frame, a
+ value changing at a run (registers and stack are veiled then), a
+ stack window going farther than its height; the heap's drawing: a
+ node's value turning at the middle of its travel. The heap's pins
+ crossfade now; its dump comes in faded at the first malloc.
+- CROWD: the advance (thread, plaques and rip as one mark, the source and
+ the disassembly scrolling with it), the veil coming over three panels
+ at a run's first step, x264's keyframes; list 0.02 and 2.52, the map
+ coming in and the dive's first frame.
+- METRONOME: syscalls 36.77 to 39.17 is the run through libc's `open`
+ to its last three instructions, 0.30 s a step by design (a run).
+- CAPTION over 720 f: heap 9.83, malloc's caption over its five walked
+ steps (12.9 s); list 21.75 and 46.58 and zoom 8.38, the captions of
+ their walked trips. Picture moving within 60 f: the step firing 60 f
+ after the caption by the narrator's lead, which the check counts from
+ the frame after (heap 9.83), x264's keyframe (syscalls 9.95), and
+ list 3.63, the falling map crossing the caption band in the dive (it
+ also makes list's arrivals 7 to the scene's 6).
+- AIR: syscalls 13.72 and 20.10, the stage still under the two captions
+ that recount the descend and lead the stub's `jmp` (the review's
+ split); sqlite's four dense captions and its last; zoom's last.
## What is not done
-- The descent: a caller's three rows glide to the window's top only
- where the deepest window leaves the caller no more rows (the nearest
- caller keeps the rest round its call row, as mock 16's second panel
- does); when the call row's plaque becomes the ring (72 f) its
- arguments, which hung under it, go in one frame, as its annotation
- turns to the call in C's form. The kernel's three rows are kept at the
- floor from the `syscall` to the stop after it, so the rows under the
- call move up again a step later. A crossing stepped over opens the
- kernel's window at the panel's floor, over its last three rows, not
- under the call row; its lane leaves from the pc's plaque. The fold
- past three windows (`2 calls: fib fib`), a lazy PLT's resolver row and
- the vDSO's window are written but no recording shows them; the descent
- on the map is the same component at 69 rows, not checked. `cross`
- keeps the crossing's timetable of the last pass (`syscalls.Plan`),
- which is motion.md's within a few frames.
+- The descent: the kernel's three rows are kept at the floor from the
+ `syscall` to the stop after it, so the rows under the call move up again
+ a step later. The fold past three windows (`2 calls: fib fib`), a lazy
+ PLT's resolver row and the vDSO's window are written but no recording
+ shows them; the descent on the map is the same component at 69 rows, not
+ checked. At a run the windows do not open and close in 8 f with no lane
+ (the syscalls scene walks every step of the descent).
- `open("note", O_RDONLY) = 3` does not fit 880 from 564 (27
characters): the arguments go from the right, `open("note", …) = 3`.
A call's arguments come from as many as the source's call writes, typed
by the system call of the function's name (`open`, `read`): a libc
function with no system call of its name has its arguments in hex.
- The heap scene's drawing and view are the scene's own components
- (`Lists`, `Chunks` in `scenes/heap.zig`), not blocks of `src/`. A node
- travels between the rows only where both stops have it in a list: the
- first free takes 9 out of the program's list (`head = n->next`) a line
- before `free(n)` gives it to the tcache, so it leaves the top row and
- comes into the bottom one instead of travelling. The bin's box turns
- from dashed to raised, and its count changes, at the idea's slot with
- no strike; a `size` bit that changes is not struck on its chip. Between
- malloc's return and the push's store a chunk taken back is in neither
- list and not drawn (mock 18's fifth panel draws it with its old link).
- The heap's map shows no arena panel.
-
-- The map is packed into fixed places (`map.split`): a panel longer than
- its column is a window of what fits; continuing in the next column's
- free space under `continued`, the key in a column's foot, `memory` in
- a scene without a lens, and loupes as panels on the map (and as lifted
- blocks on the minimap) are not built. The sqlite scene's lenses (the
- backtrace, the calls so far) and the zoom scene have no drawing on
- their map. A disassembly of 69 rows shows what the recording decoded
- round the pc, so a small function leaves rows empty.
-- The minimap draws no thread and no `flash`; its windows are outlined a
- frame behind the panels that publish them after the clock (the lens's
- view). The scene's focus is not set on it.
+ (`Lists`, `Chunks` in `scenes/heap.zig`), not blocks of `src/`: no
+ second scene needs them. It is 96 s, not the storyboard's 79.4: its
+ steps are the engine's cascades (a call 3.1 s, a prologue 2.9 s), longer
+ than the storyboard's budget; its captions keep their order and leads.
+ `free` is stepped over as one step from its line (a continue's wave),
+ not as a cascade onto its call row and then the call (mock 18's
+ `free in libc, stepped over`). A `size` bit that changes is not struck
+ on its chip. The heap's map shows no arena panel and no drawing (the
+ scene adds its lens to the working frame only).
+- The map is packed by content, but a column's rest after the
+ disassembly is page: the 5-row dumps round what the registers' and the
+ stack's pointers point at, loupes as panels on the map (and lifted
+ blocks on the minimap) and the map's key are not built; `continued` is
+ built for the stack alone. The boxes are as long as the most rows each
+ panel has wanted so far (`map.measure`, process-wide, a frame behind):
+ a scene's first frame packs by the defaults. The sqlite scene's lenses
+ (the backtrace, the calls so far), the heap's and the zoom scene's have
+ no drawing on their map.
+- The minimap follows the frame 6 f behind, but its changes are not
+ faded: a row's stroke or a mark's block changes in one frame (most of
+ the instrument's POPs). A struck word outside every window flashes on
+ it only for the stack. Its windows are outlined a frame behind the
+ panels that publish them after the clock (the lens's view). The scene's
+ focus is not set on it.
- `dive`: every panel travels 60 f (the catalogue's 72 f is the map's
fall), so that seven of them 6 f apart land by 120 f; the drawing does
- not crossfade between sizes (the list's are the same, subject on both);
- panels draw in the scene's order (source, disassembly, registers, stack,
- then the lens), not the reading order, so the stack passes over the
- registers' lower rows, opaque, for about 0.35 s before it lands. Only
- the list opens on the map; no scene surfaces, and no sprint or far
+ not crossfade between sizes (the list's are the same, subject on both).
+ Only the list opens on the map; no scene surfaces, and no sprint or far
continue plays on the map.
-- A loupe keeps to the stage but does not yet move past the current marks
- or a changed row; on the 1920 stage a deeper loupe has 20, not 120, to
- its right (the stage's edge), and covers most of the first. The
- catalogue's stem is 3 in its strokes and 4 in the loupe's anatomy: it is
- 4 here.
+- A loupe hung from a register keeps to the stage but does not yet move
+ past the current marks or a changed row; on the 1920 stage a deeper one
+ hangs under the first, not 120 to its right. The catalogue's stem is 3
+ in its strokes and 4 in the loupe's anatomy: it is 4 here.
- An `arc`'s lane change does not glide (12 f): a lane is given each
frame from the arcs then present.
+- At a run only a dump's values crossfade (8 f); a register's, a slot's
+ and a node's change in a frame (the registers and the stack are veiled
+ at a run).
+- The gallery keeps the old recording of the list
+ (`test/gallery/list.ztrace`): on the build's list (by instruction) its
+ loupe page has no second loupe, the nodes being 32 bytes apart and a
+ loupe's five rows holding the next one's target already.
- Back pointers between nodes still run under the nodes: a page keyline
round each pin's stub and head shows them passing behind it (there is
@@ -318,12 +315,12 @@ named below is the old one):
nodes and badges collide (the catalogue's known case).
- 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`) and the
- ties' table and the thread's waiting are process-wide globals, set and
- read in one frame's drawing; two players at once would want them on
- the frame. The gallery keeps the old recording of the list
- (`test/gallery/list.ztrace`), so that its pictures change with the
- drawing alone.
+ `ui.chrome`), a dive's per-panel transforms (`context.zoomed`), the
+ map's measured rows (`map.held`), the ties' table and the thread's
+ waiting are process-wide globals, set and read in one frame's drawing
+ (the measured rows a frame behind); two players at once would want them
+ on the frame. Not moved this pass: each is read by components that the
+ frame reaches only through `anim.Placed`, which carries no frame state.
- A recording holds the bytes it has seen, each as last seen: it cannot
tell a byte read again and unchanged from one not read since. Memory
nothing watches (SQLite's page cache) is read at a stop only where a
@@ -342,4 +339,4 @@ named below is the old one):
kernel's side does not bring its elements in as at `establish`.
- `zig build test` prints "failed command" for each scripted scene: that
is the run echoing its stderr (the Vulkan headless warning), not a
- failure; the summary line is the verdict.
+ failure; the summary line is the verdict (none printed when it passes).
diff --git a/anim/scenes/heap.zig b/anim/scenes/heap.zig
index e227f17..e7f70f7 100644
--- a/anim/scenes/heap.zig
+++ b/anim/scenes/heap.zig
@@ -66,15 +66,44 @@ fn programList(a: std.mem.Allocator, rec: *canim.Recording, i: u64, head_at: u64
/// the free list's) and its index in that row.
const Spot = struct { row: u8, k: usize };
+/// The program's row at a moment: the chunks of 0x20 in neither list (the
+/// one malloc has just returned, the one pop has just taken off), then the
+/// list from `head`. User addresses.
+fn programRow(a: std.mem.Allocator, rec: *canim.Recording, i: u64, head_at: u64, hp: ?zt.heap.Heap) []const u64 {
+ const list = programList(a, rec, i, head_at);
+ var out: std.ArrayList(u64) = .empty;
+ if (hp) |h| for (h.chunks, 0..) |c, k| {
+ if (k + 1 == h.chunks.len or c.size() != 0x20 or c.free or c.in != .none) continue;
+ if (std.mem.indexOfScalar(u64, list, c.addr + 16) != null) continue;
+ out.append(a, c.addr + 16) catch {};
+ };
+ out.appendSlice(a, list) catch {};
+ return out.items;
+}
+
fn spotOf(program: []const u64, free: []const zt.heap.Entry, node: u64) ?Spot {
for (program, 0..) |p, k| if (p == node) return .{ .row = 0, .k = k };
for (free, 0..) |e, k| if (e.chunk + 16 == node) return .{ .row = 1, .k = k };
return null;
}
+/// The value of the stack local `name` of the newest frame, where the debug info places it.
+fn local(a: std.mem.Allocator, m: canim.Recording.Moment, regs: zt.Regs, name: []const u8) ?u64 {
+ if (regs.rbp <= regs.rsp or regs.rbp - regs.rsp > 512) return null;
+ const out = a.alloc(zt.telescope.Slot, (regs.rbp + 16 - regs.rsp) / 8) catch return null;
+ const slots = zt.telescope.slots(m, &regs, regs.rsp, out) catch return null;
+ for (slots, 0..) |sl, k| if (sl.role == .local and sl.frame == 0 and sl.role.local.offset == 0 and std.mem.eql(u8, sl.role.local.name, name)) {
+ return canim.Recording.word(m, regs.rsp + 8 * k, 8) catch null;
+ };
+ return null;
+}
+
/// The drawing: `nodes` in two rows, the program's list over malloc's free
/// list, the `bin` heading the second; a node travels between the rows
-/// when it is freed or taken back (36 f, `glide`, with the idea's slot).
+/// when it is freed or taken back (36 f, `glide`, in the idea's slot).
+/// Nothing changes in one frame: the bin's box and the top's crossfade
+/// (12 f), the top's size and the bin's count are struck, the count fading
+/// in first (design/motion.md, "The first free").
const Lists = struct {
cursor: canim.Cursor,
stage: *const canim.Stage,
@@ -85,12 +114,22 @@ const Lists = struct {
const apart = 28;
const well = theme.metric.node.pointer_w;
const rows_y = [2]f32{ 72, 182 };
- const row_x = [2]f32{ 160, 12 + 160 + 28 };
+ /// Both rows from the free list's first node, under the program's head.
+ const row_x = [2]f32{ 12 + 160 + 28, 12 + 160 + 28 };
fn at(s: Spot) ui.Vec {
return .{ row_x[s.row] + @as(f32, @floatFromInt(s.k)) * (w + apart), rows_y[s.row] };
}
+ /// How far through `len` frames from `from` frames after the idea's slot.
+ fn after(now: canim.Now, from: f32, len: f32) f32 {
+ return switch (now.plan.gait) {
+ .walk => if (now.resting()) 1 else std.math.clamp((now.since(.idea, 0) - from / 60.0) / (len / 60.0), 0, 1),
+ .run => std.math.clamp(now.since(.idea, 0) / theme.time.run_ease, 0, 1),
+ .sprint => 1,
+ };
+ }
+
pub fn draw(l: *const Lists, f: *sk.Frame, placed: anim.Placed) void {
const box = l.stage.box(placed, .band);
if (box.h < cm.tag + 24) return;
@@ -108,49 +147,78 @@ const Lists = struct {
var heaps: [2]?zt.heap.Heap = undefined;
for (stops, 0..) |i, side| {
heaps[side] = heapAt(a, rec, i);
- program[side] = programList(a, rec, i, l.head_at);
+ program[side] = programRow(a, rec, i, l.head_at, heaps[side]);
free[side] = if (heaps[side]) |hp| freeList(hp) else &.{};
}
- // The idea reacts after the bytes: a node travels with the idea's slot.
- const p = canim.ease.glide(now.moving(.idea, 0, 36.0 / 60.0));
+ // The idea reacts after the bytes: the boxes crossfade (12 f), then a node lifts and travels (36 f).
+ const fade = after(now, 0, 12);
+ const p = canim.ease.glide(after(now, 12, 36));
const shown: usize = if (p >= 0.5) 1 else 0;
v.text(.sans, theme.size.sans.micro, 12, rows_y[0] + 28, "the program's", t.faint);
- // The bin: dashed and faint while the thread's tcache is glibc's dummy.
+ // The bin: dashed and faint while the thread's tcache is glibc's dummy; raised once it has one.
const bin: canim.Rect = .{ .x = 12, .y = rows_y[1], .w = 160, .h = h };
- const hp = heaps[shown];
- if (hp == null or hp.?.tcache == null) {
- v.dashedFrame(bin, t.faint, theme.stroke.rule);
- v.label(.mono, theme.size.mono.context, bin, .center, "dummy tcache", t.faint);
- } else {
- v.fill(bin, theme.color.raised);
- v.label(.mono, theme.size.mono.context, bin, .center, "tcache 0x20", t.primary);
- // How many it holds, on its shoulder.
+ const real = [2]bool{ heaps[0] != null and heaps[0].?.tcache != null, heaps[1] != null and heaps[1].?.tcache != null };
+ for (real, 0..) |is, side| {
+ const shows = if (real[0] == real[1]) @as(f32, if (side == 1) 1 else 0) else if (side == 1) fade else 1 - fade;
+ if (shows <= 0) continue;
+ const bv = v.faded(shows);
+ if (!is) {
+ bv.dashedFrame(bin, t.faint, theme.stroke.rule);
+ bv.label(.mono, theme.size.mono.context, bin, .center, "dummy tcache", t.faint);
+ } else {
+ bv.fill(bin, theme.color.raised);
+ bv.label(.mono, theme.size.mono.context, bin, .center, "tcache 0x20", t.primary);
+ }
+ }
+ // How many it holds, on its shoulder: it fades in (6 f), then is armed and struck as the node lands.
+ const counts = [2]?u16{ if (heaps[0]) |hp| holds(hp) else null, if (heaps[1]) |hp| holds(hp) else null };
+ if (counts[1] != null and real[1]) {
const badge: canim.Rect = .{ .x = bin.x + bin.w - 24, .y = bin.y - 34, .w = 30, .h = 30 };
- v.fill(badge, theme.color.page);
- v.frame(badge, t.faint, theme.stroke.rule);
- v.label(.mono, theme.size.mono.small, badge, .center, v.print("{d}", .{holds(hp.?) orelse 0}), t.primary);
- if (free[shown].len > 0) v.route(&.{ .{ bin.x + bin.w, bin.y + h / 2 }, .{ row_x[1] - 2, bin.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
+ const changed = counts[0] == null or !real[0] or counts[0].? != counts[1].?;
+ const comes = !real[0] or counts[0] == null;
+ const bv = v.faded(if (comes) after(now, 42, 6) else 1);
+ const heat = if (changed and now.walking()) now.heat(0, null, now.since(.idea, 0) - 60.0 / 60.0) else if (changed) canim.ui.Heat.ember else canim.ui.Heat.none;
+ bv.fill(badge, theme.color.page);
+ const ink = bv.cellWritten(badge, heat, theme.color.page);
+ // Framed, but while the strike's paper is on it.
+ bv.faded(if (heat.level < 1) 1 else 1 - heat.solid * heat.in).frame(badge, t.faint, theme.stroke.rule);
+ const landed = !changed or now.resting() or !now.walking() or now.since(.idea, 0) >= 60.0 / 60.0 + theme.time.strike.in / 2.0;
+ const count = if (landed or comes) counts[1].? else counts[0].?;
+ bv.label(ink.face, theme.size.mono.small, badge, .center, bv.print("{d}", .{count}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
}
- // The top: what is left of the arena, its size.
- if (hp) |hh| if (hh.chunks.len > 0) {
- const top = hh.chunks[hh.chunks.len - 1];
- const r: canim.Rect = .{ .x = box.w - 12 - 160, .y = rows_y[1], .w = 160, .h = h };
- v.dashedFrame(r, t.faint, theme.stroke.rule);
- v.label(.mono, theme.size.mono.context, r, .center, v.print("top 0x{x}", .{top.size()}), t.dim);
- _ = v.address(r.x + 16, r.y - 8, top.addr, .{ .ink = ui.rgb(theme.color.region.heap) });
+ if (real[shown] and free[shown].len > 0) v.route(&.{ .{ bin.x + bin.w, bin.y + h / 2 }, .{ row_x[1] - 2, bin.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
+ // The top: what is left of the arena, its place and size; crossfading where the step moved it, its size struck.
+ const tops = [2]?zt.heap.Chunk{ if (heaps[0]) |hp| (if (hp.chunks.len > 0) hp.chunks[hp.chunks.len - 1] else null) else null, if (heaps[1]) |hp| (if (hp.chunks.len > 0) hp.chunks[hp.chunks.len - 1] else null) else null };
+ const top_r: canim.Rect = .{ .x = box.w - 12 - 160, .y = rows_y[1], .w = 160, .h = h };
+ const moved = if (tops[0] != null and tops[1] != null) tops[0].?.addr != tops[1].?.addr or tops[0].?.size() != tops[1].?.size() else tops[0] != null or tops[1] != null;
+ for (tops, 0..) |maybe, side| if (maybe) |top| {
+ const shows = if (!moved) @as(f32, if (side == 1) 1 else 0) else if (side == 1) fade else 1 - fade;
+ if (shows <= 0) continue;
+ const tv = v.faded(shows);
+ tv.dashedFrame(top_r, t.faint, theme.stroke.rule);
+ const size_text = tv.print("0x{x}", .{top.size()});
+ const sx = top_r.x + top_r.w - 16 - tv.width(.mono, theme.size.mono.context, size_text);
+ tv.text(.mono, theme.size.mono.context, top_r.x + 16, theme.baseline(top_r.y, h, theme.size.mono.context), "top", t.dim);
+ var ink: canim.ui.Ink = .{ .ink = ui.rgb(t.dim) };
+ if (side == 1 and moved and tops[0] != null and now.walking()) ink = tv.cellWritten(.{ .x = sx - 4, .y = top_r.y + 10, .w = tv.width(.mono, theme.size.mono.context, size_text) + 8, .h = 24 }, now.heat(0, null, now.since(.idea, 0) - 12.0 / 60.0), null);
+ tv.text(ink.face, theme.size.mono.context, sx, theme.baseline(top_r.y, h, theme.size.mono.context), size_text, ink.ink);
+ _ = tv.address(top_r.x + 16, top_r.y - 8, top.addr, .{ .ink = ui.rgb(theme.color.region.heap) });
};
// Every node of either moment, where it was and where it goes.
var nodes: std.ArrayList(u64) = .empty;
for (program) |list| for (list) |n| if (std.mem.indexOfScalar(u64, nodes.items, n) == null) nodes.append(a, n) catch {};
for (free) |list| for (list) |e| if (std.mem.indexOfScalar(u64, nodes.items, e.chunk + 16) == null) nodes.append(a, e.chunk + 16) catch {};
- const regs = (now.moment().regs(rec.tid) catch null) orelse zt.Regs{};
+ // Who points at each node, before the step and after it: its pin's names crossfade (12 f, with the idea).
+ const regs = [2]zt.Regs{ (now.before().regs(rec.tid) catch null) orelse zt.Regs{}, (now.moment().regs(rec.tid) catch null) orelse zt.Regs{} };
+ const locals = [2]?u64{ local(a, now.before(), regs[0], "n"), local(a, now.moment(), regs[1], "n") };
+ const heads = [2]?u64{ canim.Recording.word(now.before(), l.head_at, 8) catch null, canim.Recording.word(now.moment(), l.head_at, 8) catch null };
for (nodes.items) |node| {
const from = spotOf(program[0], free[0], node);
const to = spotOf(program[1], free[1], node);
const s0 = from orelse to.?;
const s1 = to orelse from.?;
const xy = canim.ui.Vec{ std.math.lerp(at(s0)[0], at(s1)[0], p), std.math.lerp(at(s0)[1], at(s1)[1], p) };
- const shows: f32 = if (from == null) p else if (to == null) 1 - p else 1;
+ const shows: f32 = if (from == null) after(now, 0, 12) else if (to == null) 1 - after(now, 0, 12) else 1;
const nv = v.faded(shows);
const freed = (if (p >= 0.5) s1 else s0).row == 1;
const r: canim.Rect = .{ .x = xy[0], .y = xy[1], .w = w, .h = h };
@@ -169,9 +237,13 @@ const Lists = struct {
nv.fill(.{ .x = r.x, .y = r.y, .w = w - well, .h = h }, theme.color.raised);
nv.fill(.{ .x = r.x + w - well, .y = r.y, .w = well, .h = h }, theme.color.well);
const value = (canim.Recording.word(m, node, 8) catch null) orelse 0;
- const heat = now.written(node, 8, .idea, 0);
- const ink = nv.cellWritten(.{ .x = r.x, .y = r.y, .w = w - well, .h = h }, heat, theme.color.raised);
- nv.label(ink.face, theme.size.mono.small, .{ .x = r.x, .y = r.y, .w = w - well, .h = h }, .center, nv.print("{d}", .{@as(i64, @bitCast(value))}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
+ // A node changing hands is not struck: its words are the other list's now (the dump strikes them).
+ const heat = if (s0.row == s1.row) now.written(node, 8, .idea, 0) else canim.ui.Heat.none;
+ const cell: canim.Rect = .{ .x = r.x, .y = r.y, .w = w - well, .h = h };
+ const ink = nv.cellWritten(cell, heat, theme.color.raised);
+ // Taken back before the program writes it: the old link, faint, as stored.
+ const stale = value != 0 and value >> 12 == node >> 12;
+ if (stale) nv.label(.mono, theme.size.mono.context, cell, .center, nv.print("{x}", .{value}), t.faint) else nv.label(ink.face, theme.size.mono.small, cell, .center, nv.print("{d}", .{@as(i64, @bitCast(value))}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
}
// Its link: the next node in its row, as the pointer protects or holds it.
const sq: canim.Rect = .{ .x = if (freed) r.x + 18 else r.x + w - well / 2 - 5, .y = r.y + h / 2 - 5, .w = 10, .h = 10 };
@@ -182,20 +254,33 @@ const Lists = struct {
} else if (spotOf(program[shown], free[shown], next)) |ns| {
nv.fill(sq, theme.color.region.heap);
const nx = at(ns);
- if (nx[1] == r.y and nx[0] > r.x) nv.route(&.{ .{ sq.x + 10, r.y + h / 2 }, .{ nx[0] - 2, r.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
+ if (@abs(nx[1] - r.y) < 1 and nx[0] > r.x) nv.route(&.{ .{ sq.x + 10, r.y + h / 2 }, .{ nx[0] - 2, r.y + h / 2 } }, theme.color.region.heap, .{ .width = theme.stroke.line, .head = theme.metric.node.arrow_head });
}
- // Who points here: `head`, and the registers.
- var names: [4][]const u8 = undefined;
- var n: usize = 0;
- if ((canim.Recording.word(m, l.head_at, 8) catch null) == node) {
- names[n] = "head";
- n += 1;
+ // Who points here: `head`, the local `n`, and the registers.
+ var names: [2][4][]const u8 = undefined;
+ var count = [2]usize{ 0, 0 };
+ for (0..2) |side| {
+ if (heads[side] == node) {
+ names[side][count[side]] = "head";
+ count[side] += 1;
+ }
+ if (locals[side] == node) {
+ names[side][count[side]] = "n";
+ count[side] += 1;
+ }
+ for ([_][]const u8{ "rax", "rdi" }) |reg| if (regs[side].named(reg) == node and count[side] < 4) {
+ names[side][count[side]] = reg;
+ count[side] += 1;
+ };
+ }
+ const same = count[0] == count[1] and for (names[0][0..count[0]], names[1][0..count[1]]) |x, y| {
+ if (!std.mem.eql(u8, x, y)) break false;
+ } else true;
+ const turn = if (same) 1 else after(now, 0, 12);
+ for (0..2) |side| {
+ const pin = if (same) @as(f32, if (side == 1) 1 else 0) else if (side == 1) turn else 1 - turn;
+ if (pin > 0 and count[side] > 0) nv.faded(pin).pinUnder(r.x + 40, r.y + h + 2, names[side][0..count[side]], theme.color.region.heap, theme.size.mono.context);
}
- for ([_][]const u8{ "rax", "rdi" }) |reg| if (regs.named(reg) == node and n < names.len) {
- names[n] = reg;
- n += 1;
- };
- if (n > 0) nv.pinUnder(r.x + 40, r.y + h + 2, names[0..n], theme.color.region.heap, theme.size.mono.context);
}
}
};
@@ -236,7 +321,10 @@ const Chunks = struct {
defer v.u.unclip();
if (v.rows == 0) return;
const now = c.cursor.now(placed);
- canim.hexdump.fielded(v, now, cm.tag + cm.pad, .{ .base = view_base, .len = view_len, .fields = fieldsAt(f.scratch, c.cursor.rec, now.stop(.memory)) });
+ // 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) });
v.veil(now);
}
};
@@ -273,10 +361,37 @@ fn lineIn(rec: *canim.Recording, function: []const u8, n: usize, line: u32) u64
return rec.lineMoment(line, rec.call(function, n).enter);
}
+/// A step that changes the tcache, walked (`wave`: as a continue, free
+/// having been stepped over): after memory has struck, the loupe opens over
+/// the stack (36 f), its fields strike in it (6 f after, 6 f apart), then
+/// the idea; it closes with the advance. Never open over a step it does not concern.
+fn tcacheStep(at: canim.Cursor, s: *anim.Frame, tcache: *const canim.Loupe, wave: bool) void {
+ const tm = theme.time;
+ const from = at.moment(s);
+ const to = at.rec.next(.line, from);
+ var plan = at.planned(from, to, wave);
+ const opens = plan.at[1] + 3 * 6.0 / 60.0 + 12.0 / 60.0;
+ const idea = opens + tm.loupe.open + 24.0 / 60.0;
+ const later = @max(idea - plan.at[2], 0);
+ plan.at[2] += later;
+ plan.advance += later;
+ plan.total += later;
+ const start = s.cursor;
+ at.step(s, to, plan, plan.total);
+ const end = s.cursor;
+ s.cursor = start + opens;
+ tcache.open(s);
+ s.cursor = start + plan.advance;
+ tcache.close(s);
+ s.cursor = end;
+ if (at.phraseEnds(from, to)) s.wait(tm.phrase_rest);
+}
+
fn frame(s: *anim.Frame) void {
const rec = canim.open(recordings.heap);
const main = rec.call("main", 0);
- var at = canim.cursor(s, rec, main.enter);
+ // From main's first line, `push(7)`.
+ var at = canim.cursor(s, rec, rec.lineMoment(24, main.enter));
at.journey(.line, rec.lineMoment(30, main.enter));
at.levels = .{ .idea = .data, .source_rows = 10 };
const ctx = canim.context(s, at, .{ .split = canim.layout.split.subject });
@@ -284,40 +399,44 @@ fn frame(s: *anim.Frame) void {
const head_at = globalOf(rec, lineIn(rec, "push", 0, 13));
const lists = canim.add(s, Lists{ .cursor = at, .stage = ctx.stage, .head_at = head_at });
const chunks = canim.add(s, Chunks{ .cursor = at, .stage = ctx.stage });
- // The tcache, once there is one: a loupe from the row of the chunk it lives in.
+ // The tcache, once there is one: a loupe from the row of the chunk it lives in, over the stack.
const tc = tcacheOf(rec);
const tcache = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .row = .{
.at = tc.addr - 8,
.name = "tcache",
- .note = "tcache_perthread_struct \u{00b7} 0x2f0 bytes",
- .fields = .{ .base = tc.addr, .len = 0x2f0, .fields = &.{
+ // 76 two-byte counts and 76 pointers (glibc 2.44): 760 bytes.
+ .note = "tcache_perthread_struct \u{00b7} 0x2f8 bytes",
+ .fields = .{ .base = tc.addr, .len = 0x2f8, .fields = &.{
.{ .at = 0, .len = 2, .note = "slots left" },
.{ .at = 0x98, .len = 8, .reads = .pointer, .note = "the head of 0x20" },
} },
} } });
var says: canim.Narrator = .{};
- const tm = theme.time;
const joins = ctx.ties(s);
canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, chunks, lists, joins });
- says.line(s, "A list of three, pushed and popped: what malloc and free\ndo to the heap under it, a stop after each.");
- at.walk(s, .line, lineIn(rec, "push", 0, 12));
- says.line(s, "malloc(16) cut a chunk of 0x20 off the top: its size word,\n0x21, then the 16 bytes rax points at.");
- at.walk(s, .line, lineIn(rec, "push", 1, 10));
- at.hurry(s, .line, rec.lineMoment(26, main.enter), .{});
- says.line(s, "Three pushes, three chunks in a row, each with P: the chunk\nbefore it is in use. The next pointers are arcs in the bytes.");
- at.walk(s, .line, lineIn(rec, "pop", 0, 21));
- says.line(s, "free gives 9's chunk to the tcache, malloc's bin for 0x20.\nIts first word is the link now: 405, NULL safe-linked.");
- at.walk(s, .line, rec.lineMoment(27, main.enter));
- tcache.open(s);
- s.wait(tm.phrase_rest);
- at.hurry(s, .line, lineIn(rec, "pop", 1, 21), .{});
- says.line(s, "The second chains to the first: 405455 is 405050 xor 405,\nthe chunk's own address shifted 12.");
+ // design/motion.md, "A scene: libc's heap from the inside": each caption
+ // leads the steps it is about, and changes only in a rest.
+ says.line(s, "Three pushes and two pops: what malloc and free\ndo to the heap.");
+ at.walk(s, .line, lineIn(rec, "push", 0, 11));
+ says.line(s, "malloc(16) cut a chunk of 0x20 off the top: its size word,\n0x21, then the 16 bytes rax points at. The top is 0x20 smaller.");
+ at.walk(s, .line, rec.lineMoment(25, main.enter));
+ says.line(s, "Two more pushes, at a run: three chunks in a row, each\nwith P set, the chunk before it in use.");
+ at.hurry(s, .line, rec.lineMoment(27, main.enter), .{});
+ says.line(s, "pop takes the head off the list: head = n->next.");
+ at.walk(s, .line, lineIn(rec, "pop", 0, 20));
+ says.line(s, "free gave 9's chunk to the tcache, malloc's bin for 0x20.\nIts first word is the link now: 405, which is NULL, safe-linked.");
+ tcacheStep(at, s, tcache, true);
at.walk(s, .line, rec.lineMoment(28, main.enter));
- s.wait(tm.phrase_rest);
- says.line(s, "malloc(16) takes the bin's head back: the tcache points\nat 405050 again, the key is wiped, the old link stays.");
- at.walk(s, .line, lineIn(rec, "push", 3, 12));
+ says.line(s, "The second pop: head moves on, to 7's node.");
+ at.walk(s, .line, lineIn(rec, "pop", 1, 20));
+ says.line(s, "The second free chains to the first: 405455 is 405050 xor 405,\nthe chunk's own address shifted 12. The arc is the pointer it hides.");
+ tcacheStep(at, s, tcache, true);
+ at.walk(s, .line, rec.lineMoment(29, main.enter));
+ says.line(s, "malloc(16) took the bin's head, 405030: the tcache points\nat 405050 again, the key is wiped, the old link stays.");
+ at.walk(s, .line, lineIn(rec, "push", 3, 11));
+ tcacheStep(at, s, tcache, false);
+ says.line(s, "push writes 25 over the old link: the list is 25, then 7.");
at.walk(s, .line, rec.lineMoment(30, main.enter));
- tcache.close(s);
says.close(s);
}
diff --git a/anim/scenes/syscalls.zig b/anim/scenes/syscalls.zig
index db67045..0d39089 100644
--- a/anim/scenes/syscalls.zig
+++ b/anim/scenes/syscalls.zig
@@ -58,11 +58,15 @@ fn frame(s: *anim.Frame) void {
says.line(s, "`main` calls `open` by its stub in the PLT. The arguments\nare in rdi and rsi: \"note\" and O_RDONLY.");
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;\nthe stub's jmp reads the GOT, and goes on to libc.");
+ 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`.");
canim.descent.step(cur, s, .moment);
s.wait(t.phrase_rest);
- says.line(s, "libc's `open` is a wrapper: it puts openat's number in rax\nand its arguments in rdi, rsi, rdx and r10.");
- cur.hurry(s, .moment, crossing, .{});
+ // The wrapper at a run, veiled; its last three instructions walked, named as they run.
+ says.line(s, "libc's `open` is a wrapper: no source, its own code,\nup to the instruction that calls the kernel.");
+ cur.hurry(s, .moment, crossing - 3, .{});
+ says.line(s, "Its last three set r8 to 0, rdi to AT_FDCWD (-100)\nand rax to 257: openat's number.");
+ cur.walk(s, .moment, crossing);
says.line(s, "`syscall` crosses down. The kernel opens the file\nand answers in rax: 3, the descriptor.");
canim.descent.step(cur, s, .moment);
s.wait(t.phrase_rest);
diff --git a/anim/src/calls.zig b/anim/src/calls.zig
index d78c26c..4a669f3 100644
--- a/anim/src/calls.zig
+++ b/anim/src/calls.zig
@@ -45,8 +45,9 @@ pub const Tree = struct {
for (nodes) |n| leaves = @max(leaves, n.x + 1);
// The caller's box left of the root on its level; the leaves spread over the rest.
const caller_room = m.caller[0] + 48;
- const pitch = (body.w - 2 * theme.metric.panel.pad_x - 2 * m.radius - caller_room) / @max(leaves - 1, 1);
const left = theme.metric.panel.pad_x + caller_room + m.radius;
+ // The last leaf's centre 69 in from the drawing's right edge: room for its badge on its shoulder.
+ const pitch = (box.w - 69 - left) / @max(leaves - 1, 1);
const top = body.y + m.root;
const since = now.since(.idea, 0);
const returned = now.walking() and rec.depths[now.stops[0]] < rec.depths[now.stops[1]];
@@ -122,7 +123,8 @@ pub const Tree = struct {
const badge: Rect = .{ .x = 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);
- if (heat.level < 1) u.frame(badge, t.faint, theme.stroke.rule);
+ // Framed, as every result is, but while the strike's paper is on it.
+ u.faded(if (heat.level < 1) 1 else 1 - heat.solid * heat.in).frame(badge, t.faint, theme.stroke.rule);
u.label(ink.face, size, badge, .center, u.print("{d}", .{@as(i64, @bitCast(n.call.result))}), if (heat.level >= 1) ink.ink else ui.rgb(t.primary));
}
}
diff --git a/anim/src/context.zig b/anim/src/context.zig
index 6123d26..f551aa8 100644
--- a/anim/src/context.zig
+++ b/anim/src/context.zig
@@ -168,7 +168,7 @@ pub const Registers = struct {
if (std.mem.eql(u8, carried, name) and value_was == made.args[k - 1]) break k;
} else null else null;
if (carrier) |k| if (crossing) |made| {
- const framed = now.time - syscalls.Plan.of(made).registers - @as(f32, @floatFromInt(k - 1)) * time.flight.second;
+ const framed = now.time - syscalls.Plan.in(now, made).registers - @as(f32, @floatFromInt(k - 1)) * time.flight.second;
marks.read = 0;
marks.read_shows = @min(std.math.clamp(framed / time.read.in, 0, 1), now.reading(.cpu, 0));
// A descriptor says what it is open on: the `value` class `fd`.
@@ -178,7 +178,7 @@ pub const Registers = struct {
if (if (std.mem.eql(u8, name, "rax")) crossing else null) |made| {
// rax: what was there, then the result, once the kernel's rows
// have said it (the call's number went in at the wrapper).
- const back = now.time - syscalls.Plan.of(made).struck;
+ const back = now.time - syscalls.Plan.in(now, made).struck;
const result = back >= time.strike.in / 2.0;
const value: u64 = if (result) value_now else value_was;
if (back >= -time.strike.arm) {
@@ -309,11 +309,15 @@ pub const Stack = struct {
cursor: cursors.Cursor,
stage: *const Stage,
focus: bool = false,
- /// On the map: the window from this many words above rsp, not scrolled.
- above: u32 = 0,
+ /// On the map: the window from this many words above rsp, not scrolled
+ /// (negative: below it, the stack going on in another column's rest).
+ above: i32 = 0,
+ /// Which box of its stage it is in: the map's `more` holds the stack continued.
+ part: @import("stage.zig").Part = .stack,
pub fn draw(k: *const Stack, f: *sk.Frame, placed: anim.Placed) void {
- const box = k.stage.box(placed, .stack);
+ const box = k.stage.box(placed, k.part);
+ if (box.h < m.tag + m.row) return;
const u = at(f, placed, box);
const now = k.cursor.now(placed);
const rec = k.cursor.rec;
@@ -329,7 +333,7 @@ pub const Stack = struct {
const hold = placed.value(k.stage.hold);
const held = hold >= 0;
const held_at: u64 = if (held) rec.register(@intFromFloat(hold), "rsp") -% 8 * @as(u64, @intFromFloat(placed.value(k.stage.hold_free))) else 0;
- var window = if (held) [2]u64{ held_at, held_at } else if (k.above > 0) [2]u64{ is.rsp -% 8 * @as(u64, k.above), was.rsp -% 8 * @as(u64, k.above) } else [2]u64{ windowAt(now, is, slots, 0), windowAt(now, was, slots, 1) };
+ var window = if (held) [2]u64{ held_at, held_at } else if (k.above != 0) [2]u64{ is.rsp -% @as(u64, @bitCast(@as(i64, 8 * k.above))), was.rsp -% @as(u64, @bitCast(@as(i64, 8 * k.above))) } else [2]u64{ windowAt(now, is, slots, 0), windowAt(now, was, slots, 1) };
// A window that goes farther than its own height (a continue to a
// 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,
@@ -360,7 +364,7 @@ pub const Stack = struct {
};
// The first word shown and the last.
const range = if (from_rsp == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, from_rsp), offset(u, from_rsp + 8 * (@as(i64, @intCast(slots)) - 1)) });
- const body = u.panel(box.w, box.h, "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) });
+ const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) });
const p = cursors.glide(now.moving(.memory, 0, time.move));
const moved = @as(f32, @floatFromInt(@as(i64, @bitCast(window[0] -% window[1])))) / 8;
const slide: f32 = (if (jumped) 0 else moved * (1 - p)) + hold_scroll;
@@ -402,7 +406,11 @@ pub const Stack = struct {
return @as(f32, @floatFromInt(@as(i64, @bitCast(addr -% base)))) / 8;
}
}.at;
- const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool };
+ const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool, was: ?[]const u8 = null };
+ // A frame whose name changes in place (on through a stub) crossfades over the 12 f before the advance.
+ const renamed = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ const calls_was = rec.stack(u.f.scratch, now.stops[1]);
+ const calls_is = rec.stack(u.f.scratch, now.stops[0]);
var spans: [16]Span = undefined;
var n_spans: usize = 0;
for (chain, 0..) |frame, i| {
@@ -414,6 +422,14 @@ pub const Stack = struct {
const open = last >= @as(f32, @floatFromInt(slots));
const y1 = top + (@min(last, @as(f32, @floatFromInt(slots)) - 1) + 1) * m.row;
spans[n_spans] = .{ .y0 = top + @max(first, 0) * m.row, .y1 = y1, .name = spanName(u, rec, open_calls, i, if (i < named.len) named[i].pc else frame.pc), .newest = i == 0, .open = open };
+ if (now.walking() and !jumped and i < old_chain.len and old_chain[i].lo == frame.lo) {
+ const was_name = spanName(u, rec, calls_was, i, old_chain[i].pc);
+ const is_name = spanName(u, rec, calls_is, i, frame.pc);
+ if (!std.mem.eql(u8, was_name, is_name)) {
+ spans[n_spans].name = is_name;
+ spans[n_spans].was = was_name;
+ }
+ }
n_spans += 1;
}
// rsp or rbp travelling alone keeps its place in the pin it leaves and
@@ -455,7 +471,7 @@ pub const Stack = struct {
marks.read_shows = now.reading(.memory, 0);
}
const below_rsp: i64 = @bitCast(addr -% rsp_shown);
- map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
+ if (k.part == .stack) 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);
@@ -478,7 +494,7 @@ pub const Stack = struct {
const k_role = (addr -% roles_from) / 8;
const what: zt.telescope.Role = if (k_role < roles.len) roles[k_role].role else .none;
const role = roleName(u, what, (Recording.word(memory, addr, 8) catch null) orelse 1);
- const hops = rows.slot(v, y, room_w, memory, addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local);
+ const hops = rows.slot(v, y, room_w, now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local);
at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {};
pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, what == .saved and std.mem.eql(u8, what.saved, "rbp") }) catch {};
// Only a row on show is a place a tie can land.
@@ -515,7 +531,10 @@ pub const Stack = struct {
const x = if (lone != null) std.math.lerp(pinPlace(u, pins(u, now, is, was, was.named(name) orelse 0, travel).names, name), pinPlace(u, pins(u, now, is, was, is.named(name) orelse 0, travel).names, name), goes(now, was, is, name)) else theme.metric.slot.lane;
u.pinRow(x, top + place * m.row, if (both) &.{ "rsp", "rbp" } else &.{name}, theme.color.region.stack);
}
- for (spans[0..n_spans]) |sp| rows.span(v, box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open);
+ for (spans[0..n_spans]) |sp| if (sp.was) |was_name| {
+ rows.span(v.faded(1 - renamed), box.w, sp.y0, sp.y1, was_name, sp.newest, sp.open);
+ rows.span(v.faded(renamed), box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open);
+ } else rows.span(v, box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open);
veiled(u, box, now.veil);
}
@@ -527,7 +546,7 @@ pub const Stack = struct {
return switch (role) {
.none, .return_address => .{ .name = "" },
.saved => |r| .{ .name = u.print("saved {s}", .{r}) },
- .local => |l| .{ .name = if (l.offset > 0) u.print("{s}+{x}", .{ l.name, @as(u32, @intCast(l.offset)) }) else l.name, .local = true },
+ .local => |l| .{ .name = if (l.offset > 0) u.print("{s}+{x}", .{ l.name, @as(u32, @intCast(l.offset)) }) else if (l.offset == -4 and l.size == 4) u.print("{s}, high half", .{l.name}) else if (l.offset < 0) u.print("{s}, from byte {d}", .{ l.name, -l.offset }) else l.name, .local = true },
.argc => .{ .name = "argc" },
.argv => |i| .{ .name = if (word == 0) "argv end" else u.print("argv[{d}]", .{i}) },
.envp => |i| .{ .name = if (word == 0) "envp end" else u.print("envp[{d}]", .{i}) },
@@ -663,6 +682,7 @@ pub const Backtrace = struct {
const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1);
const room = rowsOf(box);
const total = chains[if (slide >= 0.5) 1 else 0].len;
+ map.measure(.backtrace, @max(chains[0].len, chains[1].len));
const body = u.panel(box.w, box.h, "backtrace", .{ .focus = b.focus, .note = newestAtBottom(u, total, room) });
clipBody(u, box);
defer u.unclip();
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index 6a02948..bbc3cf1 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -16,6 +16,7 @@ const anim = @import("anim");
const zt = @import("ztrace");
const Recording = @import("Recording.zig");
const ui = @import("ui.zig");
+const syscalls = @import("syscalls.zig");
const theme = ui.theme;
const time = theme.time;
@@ -80,6 +81,9 @@ pub const Plan = struct {
total: f32 = time.fire + time.step + time.rest,
/// A `continue`: the registers strike in a wave, no arm and no pulse.
wave: bool = false,
+ /// 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,
/// Once the pattern is known: the levels a stagger apart from the
/// first frame, the mark after them, in `seconds`.
@@ -93,7 +97,7 @@ pub const Plan = struct {
};
/// Registers whose change is no value to read: where execution is, and the flags.
-const quiet: u32 = blk: {
+pub const quiet: u32 = blk: {
var mask: u32 = 0;
for (zt.Regs.names, 0..) |name, i| {
if (std.mem.eql(u8, name, "rip") or std.mem.eql(u8, name, "eflags")) mask |= 1 << i;
@@ -105,10 +109,13 @@ pub const Cursor = struct {
rec: *Recording,
/// Where it is (or is arriving), where it came from, and before that.
stops: [history]anim.Value,
+ /// The pace each of those steps was taken at (`Gait`): what a run
+ /// changed is not marked, then or after.
+ gaits: [history]anim.Value,
/// 0 to 1 through the step it is taking; 1 at rest.
phase: anim.Value,
/// The step's `Plan`, a value a field.
- plan: [8]anim.Value,
+ plan: [9]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
@@ -119,6 +126,10 @@ pub const Cursor = struct {
sprint_veil: anim.Value,
/// Steps taken.
count: anim.Value,
+ /// The same values a little behind (`time.minimap_lag`): what the
+ /// minimap draws from, secondary action that never starts on a primary
+ /// onset's frame.
+ lag: Lagged,
/// The levels the scene shows: set before the first step.
levels: Levels = .{},
/// The scene's whole way, for the head's progress line and counter (`journey`).
@@ -133,21 +144,62 @@ pub const Cursor = struct {
var c: Cursor = .{
.rec = rec,
.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) },
+ .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) },
.marks = .{ s.value(here), s.value(here) },
.hurried = s.value(0),
.veil = s.value(0),
.sprint_veil = s.value(0),
.count = s.value(0),
+ .lag = undefined,
.first = start,
.last = start,
};
// shortcut: an f32 holds whole moments up to 16 million; a longer recording needs two values a stop.
for (&c.stops) |*stop| stop.* = s.value(here);
+ for (&c.gaits) |*gait| gait.* = s.value(0);
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
+ const from = @field(c, name);
+ if (@TypeOf(from) == anim.Value) {
+ @field(c.lag, name) = s.value(s.get(from));
+ } else for (&@field(c.lag, name), from) |*to, one| {
+ to.* = s.value(s.get(one));
+ }
+ }
return c;
}
+ /// The cursor's animated values, mirrored for the minimap.
+ pub const Lagged = struct {
+ stops: [history]anim.Value,
+ gaits: [history]anim.Value,
+ phase: anim.Value,
+ plan: [9]anim.Value,
+ marks: [2]anim.Value,
+ hurried: anim.Value,
+ veil: anim.Value,
+ sprint_veil: anim.Value,
+ count: anim.Value,
+ };
+
+ /// Plays `plays(values)` on the cursor's values from here, and on their
+ /// lagging mirror `time.minimap_lag` later; the cursor ends where the first left it.
+ fn both(c: Cursor, s: *anim.Frame, plays: anytype) void {
+ const start = s.cursor;
+ s.cursor = start + time.minimap_lag;
+ plays.run(s, lagged(c));
+ s.cursor = start;
+ plays.run(s, c);
+ }
+
+ /// `c` with its lagging values in place of its own.
+ fn lagged(c: Cursor) Cursor {
+ var out = c;
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| @field(out, name) = @field(c.lag, name);
+ return out;
+ }
+
/// Where the timeline has taken the cursor so far: for scene code that
/// finds the next place from the last.
pub fn moment(c: Cursor, s: *const anim.Frame) u64 {
@@ -174,18 +226,36 @@ pub const Cursor = struct {
/// sentence said faster).
pub fn step(c: Cursor, s: *anim.Frame, to: u64, plan: Plan, seconds: f32) void {
const from = c.moment(s);
- var set: [history + 12]anim.Animation = undefined;
- for (1..history) |i| set[i] = c.stops[i].to(settled(s, c.stops[i - 1]));
- set[0] = c.stops[0].to(@floatFromInt(to));
- for (c.plan, [_]f32{ @floatFromInt(@intFromEnum(plan.gait)), plan.at[0], plan.at[1], plan.at[2], plan.advance, plan.travel, plan.total, @floatFromInt(@intFromBool(plan.wave)) }, history..) |value, is, n| set[n] = value.to(is);
+ // Where each value goes, from the cursor's own (the mirror goes the same way, later).
+ const Step = struct {
+ stops: [history]f32,
+ gaits: [history]f32,
+ plan: [9]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;
+ 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.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);
+ 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 };
+ 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));
+ for (1..history) |i| st.gaits[i] = settled(s, c.gaits[i - 1]);
// At a sprint the mark is seen only where a phrase ends.
const was = settled(s, c.marks[1]);
- set[history + 8] = c.marks[0].to(was);
- set[history + 9] = c.marks[1].to(if (plan.gait == .sprint and !c.phraseEnds(from, to)) was else @floatFromInt(to));
- set[history + 10] = c.phase.to(0);
- set[history + 11] = c.count.to(settled(s, c.count) + 1);
- s.play(set, .{ .seconds = 0 });
- s.play(.{c.phase.to(1)}, .{ .seconds = seconds, .ease = anim.ease.linear });
+ st.marks = .{ was, if (plan.gait == .sprint and !c.phraseEnds(from, to)) was else @floatFromInt(to) };
+ c.both(s, st);
}
/// Steps of `by` up to moment `until`, each shown in full and as long
@@ -212,6 +282,11 @@ pub const Cursor = struct {
return c.timetable(from, to, false);
}
+ /// The timetable a step from `from` to `to` gets walked (`wave`: as a `continue`), for a scene that adds a beat to it.
+ pub fn planned(c: Cursor, from: u64, to: u64, wave: bool) Plan {
+ return c.timetable(from, to, wave);
+ }
+
/// `continue`: straight to a stop far from this one (a breakpoint, not
/// a step). The line it leaves fires; the registers it changed strike
/// in a wave, 2 f apart in pwndbg's order, the fill in over 6 f, no arm
@@ -256,8 +331,9 @@ pub const Cursor = struct {
const projected = level == 2 and is and levels[1] and (c.levels.idea == .data or deeper);
if (projected) slot += time.project.bracket + @as(f32, if (c.levels.idea == .data) time.project.draw else time.project.far) + @as(f32, if (wrote > 0 and c.levels.idea == .data) time.strike.arm else 0) else if (is) slot += time.cascade;
strikes.* = @max(slot, time.cascade);
- // A wave's last register strikes 2 f a register after its first: the next level is 18 f after that.
- if (wave and level == 0 and is) slot += (regs - 1) * time.continue_wave;
+ // A wave's last register strikes 2 f a register after its first,
+ // a cascade's 6 f (the fourth and on with the third): the next level is 18 f after that.
+ if (level == 0 and is) slot += if (wave) (regs - 1) * time.continue_wave else @min(regs - 1, 3) * write_apart;
}
// The writes of one step strike 6 f apart: the last is later.
if (levels[1]) slot += @min(@max(wrote - 1, 0), 3) * write_apart;
@@ -327,7 +403,7 @@ pub const Cursor = struct {
// What changes faster than it can be read is veiled at a run too.
const veiled = options.veil orelse true;
const start = s.cursor;
- s.play(.{ c.hurried.to(1), c.veil.to(if (veiled) 1 else 0), c.sprint_veil.to(if (options.pace < time.run) 1 else 0) }, .{ .seconds = time.veil, .ease = anim.ease.linear });
+ c.both(s, Veils{ .to = .{ 1, if (veiled) 1 else 0, if (options.pace < time.run) 1 else 0 } });
s.cursor = start;
var k: f32 = 0;
while (here < until) : (k += 1) {
@@ -343,22 +419,37 @@ pub const Cursor = struct {
here = next;
}
if (!options.settle) return;
- s.play(.{ c.hurried.to(0), c.veil.to(0), c.sprint_veil.to(0) }, .{ .seconds = time.veil, .ease = anim.ease.linear });
+ c.both(s, Veils{ .to = .{ 0, 0, 0 } });
s.wait(time.beat);
}
+ /// The hurry's veils going to `to` (hurried, veil, sprint_veil).
+ const Veils = struct {
+ to: [3]f32,
+ fn run(v: Veils, s: *anim.Frame, c: Cursor) void {
+ s.play(.{ c.hurried.to(v.to[0]), c.veil.to(v.to[1]), c.sprint_veil.to(v.to[2]) }, .{ .seconds = time.veil, .ease = anim.ease.linear });
+ }
+ };
+
/// There at once, with nothing struck: a cut.
pub fn jump(c: Cursor, s: *anim.Frame, to: u64) void {
- var all: [history + 3]anim.Animation = undefined;
- for (c.stops, 0..) |stop_value, i| all[i] = stop_value.to(@floatFromInt(to));
- all[history] = c.phase.to(1);
- all[history + 1] = c.marks[0].to(@floatFromInt(to));
- all[history + 2] = c.marks[1].to(@floatFromInt(to));
- s.play(all, .{ .seconds = 0 });
+ const Jump = struct {
+ to: u64,
+ fn run(j: @This(), sf: *anim.Frame, v: Cursor) void {
+ var all: [history + 3]anim.Animation = undefined;
+ for (v.stops, 0..) |stop_value, i| all[i] = stop_value.to(@floatFromInt(j.to));
+ all[history] = v.phase.to(1);
+ all[history + 1] = v.marks[0].to(@floatFromInt(j.to));
+ all[history + 2] = v.marks[1].to(@floatFromInt(j.to));
+ sf.play(all, .{ .seconds = 0 });
+ }
+ };
+ c.both(s, Jump{ .to = to });
}
- /// For a component, while it draws.
- pub fn now(c: Cursor, placed: anim.Placed) Now {
+ /// For a component, while it draws (on the minimap, `time.minimap_lag` behind).
+ pub fn now(c_: Cursor, placed: anim.Placed) Now {
+ const c = if (ui.strokes) lagged(c_) else c_;
const rec = c.rec;
var n: Now = .{
.rec = rec,
@@ -371,6 +462,7 @@ pub const Cursor = struct {
.travel = placed.value(c.plan[5]),
.total = placed.value(c.plan[6]),
.wave = placed.value(c.plan[7]) >= 0.5,
+ .fires = placed.value(c.plan[8]) >= 0.5,
},
.marks = .{ whole(rec, placed.value(c.marks[0])), whole(rec, placed.value(c.marks[1])) },
.hurried = placed.value(c.hurried),
@@ -384,6 +476,7 @@ pub const Cursor = struct {
.way = .{ c.first, c.last },
};
for (&n.stops, c.stops) |*stop_at, v| stop_at.* = whole(rec, placed.value(v));
+ for (&n.gaits, c.gaits) |*gait, v| gait.* = @enumFromInt(@as(u2, @intFromFloat(std.math.clamp(@round(placed.value(v)), 0, 2))));
const phase = placed.value(c.phase);
if (phase < 1) n.time = phase * n.plan.total;
if (c.last > c.first) {
@@ -417,6 +510,8 @@ pub const Now = struct {
/// `stops[0]` is the moment shown, `stops[1]` where the step came
/// from: the step is every moment after it up to the one shown.
stops: [history]u64,
+ /// The pace each step to them was taken at: `gaits[0]` this one's.
+ gaits: [history]Gait = @splat(.walk),
/// Seconds into the step's plan; infinite at rest.
time: f32,
plan: Plan,
@@ -494,7 +589,7 @@ pub const Now = struct {
/// The fire: how far out (in units) the edges of the mark's plaque
/// are, on the line about to run. The step's first beat, alone.
pub fn fire(n: Now) f32 {
- return if (n.walking() and n.time < time.fire) theme.pulse(n.time / time.fire) else 0;
+ return if (n.walking() and n.plan.fires and n.time < time.fire) theme.pulse(n.time / time.fire) else 0;
}
/// The same for the view the scene fires in, 0 for the other.
@@ -528,6 +623,25 @@ pub const Now = struct {
return n.writeAgeFrom(addr, size, 0);
}
+ /// Of the bytes `addr .. addr + len` (16 at most), the first and the last
+ /// (from `addr`) whose value the step that last wrote them changed: what
+ /// its strike covers. Null where that is not known.
+ pub fn changedBytes(n: Now, addr: u64, len: u64) ?[2]u8 {
+ const age = n.writeAge(addr, len) orelse return null;
+ const l: usize = @intCast(@min(len, 16));
+ var was: [16]u8 = undefined;
+ var is: [16]u8 = undefined;
+ var known_was: [16]bool = undefined;
+ var known_is: [16]bool = undefined;
+ n.rec.moment(n.stops[age + 1]).read(addr, was[0..l], known_was[0..l]) catch return null;
+ 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) };
+ };
+ return out;
+ }
+
/// The same, not counting the `skip` newest steps.
fn writeAgeFrom(n: Now, addr: u64, size: u64, skip: usize) ?u64 {
for (skip..history - 1) |age| {
@@ -568,6 +682,8 @@ pub const Now = struct {
const s = time.strike;
const a = age orelse return .none;
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;
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.
@@ -587,7 +703,8 @@ pub const Now = struct {
switch (n.plan.gait) {
// Faster than a strike can be seen: embers only.
.sprint => return .ember,
- .run => return if (was.level >= 1 or n.resting()) .ember else .{ .level = std.math.clamp(since_strike / time.snap, 0, 1) },
+ // A run strikes nothing: its values change in place.
+ .run => return .none,
.walk => {},
}
if (n.resting()) return .ember;
@@ -614,9 +731,27 @@ 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 {
+ // 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;
+ };
return n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), n.since(level, delay + n.writeDelay(addr, size)));
}
+ /// `written`, struck `since` seconds ago (a loupe's own times: it strikes once it has opened).
+ pub fn writtenAt(n: Now, addr: u64, size: u64, struck: f32) ui.Heat {
+ 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);
+ }
+
/// `written`, on a thing the viewer has watched only through the steps
/// `lo` to `hi` ago (a window that faded to its place, a view that came
/// in after its step): what changed in any other step is plain.
@@ -631,6 +766,8 @@ pub const Now = struct {
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;
// 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;
@@ -704,8 +841,8 @@ test "a write is armed, strikes, holds, cools with the advance, and leaves after
// Struck again over its ember: armed with the ember still under it.
h = instant(0.20, plan).heat(0, 1, -0.10);
try expect(h.level == 1 and h.arm == 1 and h.solid == 0);
- // Running: an ember and no more. Sprinting: the same, at once.
- try expect(instant(0.2, Plan.running(0.3)).heat(0, null, 0.2).solid == 0);
+ // Running: nothing struck. Sprinting: an ember, at once.
+ try expectEqual(ui.Heat.none, instant(0.2, Plan.running(0.3)).heat(0, null, 0.2));
try expectEqual(ui.Heat.ember, instant(0.01, Plan.sprinting(0.05)).heat(0, null, 0.01));
}
diff --git a/anim/src/descent.zig b/anim/src/descent.zig
index 302de38..3394eaa 100644
--- a/anim/src/descent.zig
+++ b/anim/src/descent.zig
@@ -44,9 +44,11 @@ fn clamp01(v: f32) f32 {
}
/// One step of `by` from where the cursor is, timed as its verb
-/// (design/motion.md, "A call followed down"): into a call (`descend`, 2.7
-/// s), on through a PLT stub's `jmp` (2.0 s), out by a `ret` (`ascend`, 2.3
+/// (design/motion.md, "A call followed down"): into a call (`descend`, 2.9
+/// s), on through a PLT stub's `jmp` (2.2 s), out by a `ret` (`ascend`, 2.5
/// s), across into the kernel (`cross`: `syscalls.step`); any other walked.
+/// A window opens and closes in two moves, never at once: the rows it gives
+/// up fade, then the rows it keeps glide (and back: they glide, then fade in).
pub fn step(cur: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
const rec = cur.rec;
const from = cur.moment(s);
@@ -57,9 +59,9 @@ pub fn step(cur: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
var name_buf: [256]u8 = undefined;
const here = (rec.moment(from).string(rec.register(from, "rip"), &name_buf) catch null) orelse "";
const plan: cursors.Plan = switch (b.kind) {
- .call => .{ .at = .{ f(24), f(60), f(60) }, .advance = f(126), .travel = f(12), .total = f(162) },
- .ret => .{ .at = .{ f(36), f(18), f(36) }, .advance = f(102), .travel = f(12), .total = f(138) },
- .jump => if (std.mem.indexOf(u8, here, "@plt") != null) .{ .at = .{ f(18), f(24), f(24) }, .advance = f(84), .travel = f(12), .total = f(120) } else return cur.walk(s, by, to),
+ .call => .{ .at = .{ f(24), f(60), f(60) }, .advance = f(138), .travel = f(12), .total = f(174) },
+ .ret => .{ .at = .{ f(36), f(18), f(36) }, .advance = f(114), .travel = f(12), .total = f(150) },
+ .jump => if (std.mem.indexOf(u8, here, "@plt") != null) .{ .at = .{ f(18), f(24), f(24) }, .advance = f(96), .travel = f(12), .total = f(132) } else return cur.walk(s, by, to),
.none => return cur.walk(s, by, to),
};
cur.step(s, to, plan, plan.total);
@@ -118,11 +120,20 @@ pub const Descent = struct {
// of each that leaves or comes shows: the verb's timetable.
const move: f32 = switch (kind) {
.same => cursors.glide(going),
- .down => cursors.glide(clamp01((tm - f(72)) / f(18))),
- .through => cursors.glide(clamp01((tm - f(24)) / f(18))),
+ .down => cursors.glide(clamp01((tm - f(78)) / f(18))),
+ .through => cursors.glide(clamp01((tm - f(36)) / f(18))),
.up => cursors.glide(clamp01((tm - f(84)) / f(18))),
};
- const Placed = struct { item: Item, y: f32, shows: f32, rise: f32, old: ?Item, new: ?Item };
+ const Placed = struct { item: Item, y: f32, shows: f32, rise: f32, old: ?Item, new: ?Item, twin: bool = false };
+ // A row whose state the verb changes (the call row going to wait, a
+ // stub's jmp passing, a waiting call taking its result) crossfades from
+ // the one to the other (12 f; 6 f up), its hanging arguments with it.
+ const turn: f32 = switch (kind) {
+ .same => 0,
+ .down => clamp01((tm - f(66)) / f(12)),
+ .through => clamp01((tm - f(24)) / f(12)),
+ .up => clamp01((tm - f(114)) / f(6)),
+ };
var placed_items: std.ArrayList(Placed) = .empty;
const a = u.f.scratch;
// Leaving: bottom up when a window closes, all at once when a caller gives up rows.
@@ -146,22 +157,20 @@ pub const Descent = struct {
for (after.items) |it| {
if (find(before.items, it.key)) |old| {
const y = top + std.math.lerp(old.row, it.row, move) * m.row;
- // Going up the rows keep what they were (the ring) until the advance.
- const now_item = switch (kind) {
- .same, .up => if (going >= 0.5) it else old,
- // The call row is current until its plaque becomes the ring; a stub's jmp until it passes.
- .down => if (tm >= f(72)) it else old,
- .through => if (tm >= f(24)) it else old,
- };
- placed_items.append(a, .{ .item = now_item, .y = y, .shows = 1, .rise = 0, .old = old, .new = it }) catch {};
+ if (kind != .same and old.state != it.state) {
+ placed_items.append(a, .{ .item = old, .y = y, .shows = 1 - turn, .rise = 0, .old = old, .new = it }) catch {};
+ placed_items.append(a, .{ .item = it, .y = y, .shows = turn, .rise = 0, .old = old, .new = it, .twin = true }) catch {};
+ continue;
+ }
+ placed_items.append(a, .{ .item = if (going < 0.5) old else it, .y = y, .shows = 1, .rise = 0, .old = old, .new = it }) catch {};
continue;
}
const head = it.what == .head;
const shows: f32 = switch (kind) {
.same => clamp01(2 * going - 1),
- .down => if (head) clamp01((tm - f(96)) / f(12)) else clamp01((tm - f(102) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
- .through => if (head) clamp01((tm - f(54)) / f(12)) else clamp01((tm - f(60) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
- .up => clamp01((tm - f(84)) / f(18)),
+ .down => if (head) clamp01((tm - f(108)) / f(12)) else clamp01((tm - f(114) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
+ .through => if (head) clamp01((tm - f(66)) / f(12)) else clamp01((tm - f(72) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
+ .up => clamp01((tm - f(102)) / f(12)),
};
if (!head) arriving += 1;
placed_items.append(a, .{ .item = it, .y = top + it.row * m.row, .shows = shows, .rise = if (head and kind != .same) (1 - cursors.standard(shows)) * theme.time.caption_rise else 0, .old = null, .new = it }) catch {};
@@ -176,17 +185,33 @@ pub const Descent = struct {
// on the next; the ring on a waiting call; a passed stub's bar.
const marked = now.marks[if (going >= 0.5) 1 else 0];
const plaque = [2]f32{
- // The one it leaves: in a descend it becomes the ring (72 to 84 f),
+ // The one it leaves: in a descend it becomes the ring (84 to 96 f),
// through a stub the pass bar (24 to 36), up it closes with its window.
switch (kind) {
.same => 1,
- .down => 1 - clamp01((tm - f(72)) / f(12)),
+ .down => 1 - clamp01((tm - f(84)) / f(12)),
.through => 1 - clamp01((tm - f(24)) / f(12)),
.up => 1 - clamp01((tm - f(48)) / f(12)),
},
// The one it lands on, with the advance.
if (kind == .same) 1 else clamp01(going * 2),
};
+ // A crossing stepped over: the kernel's window opens under the call
+ // row, past the arguments hanging under it; the rows after them make
+ // room first (18 f, as the lane sets off) and close up with the
+ // window as it draws back.
+ var under: ?f32 = null;
+ if (steppedOver(now)) |made| for (placed_items.items) |p| if (p.old) |o| if (o.state == .current and o.what == .insn) {
+ const at = p.y + @as(f32, @floatFromInt(1 + disasm.hanging(u, rec, o.what.insn, now.stops[1]))) * m.row;
+ const sp = syscalls.Plan.in(now, made);
+ const opening = cursors.glide(clamp01((tm - sp.enters) / f(18)));
+ const room_ = 3 * m.row * @min(opening, 1 - clamp01((tm - now.plan.advance) / f(12)));
+ for (placed_items.items) |*q| if (q.y >= at - 1) {
+ q.y += room_;
+ };
+ under = at;
+ break;
+ };
var pc_y = [2]?f32{ null, null };
for (placed_items.items) |p| {
if (p.old) |o| if (o.state == .current) {
@@ -216,6 +241,7 @@ pub const Descent = struct {
const current_line = rec.own[marked];
const widen0 = rows.numberRoom(rec.line_count);
var covered: usize = 0;
+ var covered_before: usize = 0;
var runs: disasm.Runs = .{};
var last_line: ?u32 = null;
var last_window: ?u8 = null;
@@ -263,15 +289,17 @@ pub const Descent = struct {
.pass => v.trail(c.mark, y, 0),
.waiting => {
// The ring comes as the plaque leaves; going up it becomes a trail bar.
- const ring: f32 = if (p.old != null and p.old.?.state == .waiting) (if (kind == .up) 1 - clamp01((tm - f(102)) / f(12)) else 1) else if (kind == .down) clamp01((tm - f(72)) / f(12)) else 1;
+ const ring: f32 = if (p.old != null and p.old.?.state == .waiting) (if (kind == .up) 1 - clamp01((tm - f(114)) / f(12)) else 1) else if (kind == .down) clamp01((tm - f(84)) / f(12)) else 1;
ringAt(v.faded(ring), y);
if (ring < 1) v.faded(1 - ring).trail(c.mark, y, 0);
},
.current => {},
}
runs.add(line != null and line.? == current_line, y, y + m.row);
- const hangs = dd.insn(v, now, row, y, box.w, widen0 + wide, line, line != last_line, current_line, lead, state, base, covered > 0, .{ addrs[0], addrs[n -| 1] }, null);
- covered = @max(covered -| 1, hangs);
+ // A row drawn twice (crossfading) counts once for the arguments that hang over the rows under it.
+ const hangs = dd.insn(v, now, row, y, box.w, widen0 + wide, line, line != last_line, current_line, lead, state, base, if (p.twin) covered_before > 0 else covered > 0, .{ addrs[0], addrs[n -| 1] }, null);
+ if (!p.twin) covered_before = covered;
+ covered = if (p.twin) @max(covered, hangs) else @max(covered -| 1, hangs);
last_line = line;
map.row(.disasm, row.addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
},
@@ -288,8 +316,8 @@ pub const Descent = struct {
if (q.item.window + 1 == p.item.window and (q.item.state == .waiting or q.item.state == .pass)) break q;
} else continue;
const drawn: f32 = if (p.old != null and p.new != null) 1 else if (p.new != null) switch (kind) {
- .down => clamp01((tm - f(84)) / f(18)),
- .through => clamp01((tm - f(42)) / f(18)),
+ .down => clamp01((tm - f(96)) / f(18)),
+ .through => clamp01((tm - f(54)) / f(18)),
else => clamp01(2 * going - 1),
} else switch (kind) {
.up => 1 - clamp01((tm - f(72)) / f(12)),
@@ -302,7 +330,7 @@ pub const Descent = struct {
}
map.window(.disasm, first(shown), last(shown));
if (pc_y[1] orelse pc_y[0]) |y| ties.anchor(u, .pc, .{ .x = 0, .y = y, .w = theme.metric.plaque.pc, .h = m.row });
- kernel(u, now, box, top, room, pc_y[0] orelse pc_y[1]);
+ kernel(u, now, box, under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row, pc_y[0] orelse pc_y[1]);
context.veiled(u, box, now.veil);
}
};
@@ -443,8 +471,19 @@ fn layout(u: ui.Ui, rec: *const Recording, i: u64, room: usize, root: []const u8
}
if (fold.len > 0) fixed += 1;
const remaining = room -| fixed;
- const deepest_rows = if (kept.len == 1) room else if (in_stub) @min(remaining, stubRows(rec, i, pc)) else remaining;
+ var deepest_rows = if (kept.len == 1) room else if (in_stub) @min(remaining, stubRows(rec, i, pc)) else remaining;
const extra = remaining -| deepest_rows;
+ // The nearest caller takes the rows the deepest does not use, all above
+ // its call row: it keeps one row after the call, so the callee's head is
+ // directly under its return row. Where its function starts first, what
+ // is left goes back to the deepest window.
+ var nearest_rows: usize = 3 + extra;
+ if (kept.len >= 2 and kept[kept.len - 2].kind == .caller) {
+ const above = disasm.listingAt(u, rec, i, kept[kept.len - 2].at, nearest_rows, nearest_rows - 2).pc;
+ const short = nearest_rows - 2 - above;
+ nearest_rows -= short;
+ deepest_rows += short;
+ }
var row: f32 = 0;
var tag: []const u8 = "";
for (kept, 0..) |l, li| {
@@ -459,12 +498,12 @@ fn layout(u: ui.Ui, rec: *const Recording, i: u64, room: usize, root: []const u8
}
const nearest = li + 2 == kept.len and l.kind == .caller;
const count: usize = switch (l.kind) {
- .caller => 3 + if (nearest) extra else 0,
+ .caller => if (nearest) nearest_rows else 3,
.pass => 1,
.deepest => deepest_rows,
};
const above: usize = switch (l.kind) {
- .caller => (count - 1) / 2,
+ .caller => count - 2,
.pass => 0,
// Under a `syscall` four rows hold its arguments.
.deepest => if (in_stub) 0 else if (isSyscall(rec, i, pc) and count > 5) count - 5 else (count -| 1) / 2,
@@ -502,6 +541,14 @@ fn madeAt(rec: *const Recording, i: u64, addr: u64) u64 {
return i;
}
+/// The call this step crosses with, where it was stepped over (the step
+/// began on a call to libc's wrapper, not on the `syscall` itself).
+fn steppedOver(now: cursors.Now) ?Recording.Syscall {
+ if (!now.crossings or !now.walking()) return null;
+ const made = syscalls.inStep(now) orelse return null;
+ return if (isSyscall(now.rec, now.stops[1], now.rec.register(now.stops[1], "rip"))) null else made;
+}
+
fn isSyscall(rec: *const Recording, i: u64, pc: u64) bool {
var buf: [256]u8 = undefined;
const here = rec.instruction(i, pc, &buf) orelse return false;
@@ -555,13 +602,12 @@ fn moduleOf(u: ui.Ui, rec: *const Recording, i: u64, addr: u64) []const u8 {
/// the head and the call in C's form, `returns` and what crossed back
/// with what it clobbered; the answer up the lane; and at the advance the
/// window drawing back up into the lane.
-fn kernel(u: ui.Ui, now: cursors.Now, box: Rect, top: f32, room: usize, pc_y: ?f32) void {
+fn kernel(u: ui.Ui, now: cursors.Now, box: Rect, y0: f32, pc_y: ?f32) void {
if (!now.crossings or !now.walking()) return;
const made = syscalls.inStep(now) orelse return;
const rec = now.rec;
- const p = syscalls.Plan.of(made);
+ const p = syscalls.Plan.in(now, made);
const tm = now.time;
- const y0 = top + @as(f32, @floatFromInt(room -| 3)) * m.row;
const from = (pc_y orelse y0 - m.row) + m.row;
const back_up = clamp01((tm - now.plan.advance) / f(12));
// The lane: down 24 f from the plaque, 3 units of vellum; back into it after the window.
@@ -572,7 +618,7 @@ fn kernel(u: ui.Ui, now: cursors.Now, box: Rect, top: f32, room: usize, pc_y: ?f
u.fill(.{ .x = 14 - 1.5, .y = from, .w = 3, .h = @max(end - from, 0) }, theme.color.kernel);
}
// The answer climbs the lane to the `syscall` row: a head of vellum going up it.
- const climb = cursors.standard(clamp01((tm - p.back) / syscalls.Plan.cross));
+ const climb = cursors.glide(clamp01((tm - p.back) / syscalls.Plan.cross));
if (climb > 0 and climb < 1) {
const yh = std.math.lerp(y0, from, climb);
sk.draw.polygon(u.f, &.{ .{ 14, yh - 8 }, .{ 7, yh + 2 }, .{ 21, yh + 2 } }, u.at.pen(.{ .fill = ui.rgb(theme.color.kernel) }));
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig
index 0b6f931..e871cc6 100644
--- a/anim/src/disasm.zig
+++ b/anim/src/disasm.zig
@@ -81,6 +81,8 @@ pub const Disasm = struct {
const going = now.advancing();
const from = listing(u, rec, now.marks[0], room, above);
const to = listing(u, rec, now.marks[1], room, above);
+ // On the map its box is as long as the instructions the recording has round the pc.
+ if (ui.mapping) map.measure(.disasm, listing(u, rec, now.marks[1], theme.map.disasm_rows, (theme.map.disasm_rows - 1) / 2).rows.len);
const pc = [2]u64{ rec.register(now.marks[0], "rip"), rec.register(now.marks[1], "rip") };
const name = rec.strings.get(pc[if (going >= 0.5) 1 else 0]) orelse "";
@@ -274,7 +276,8 @@ pub const Disasm = struct {
var x = room + gap;
if (need.drawn) x = annotationX(operandsWidth(u, row, ops, stub), room, need.end - c.annotation);
operands(u, row, ops, stub, base_y, (if (covered) @min(x, c.annotation) else x) - gap - c.operands, if (pad) t.faint else theme.color.code.plain);
- return if (need.drawn) d.annotation(u, now, row, y, x, room, state, base, window, echo).hangs else 0;
+ // Its annotation column holds the arguments of a call above: its own gives way.
+ return if (need.drawn and !covered) d.annotation(u, now, row, y, x, room, state, base, window, echo).hangs else 0;
}
const Note = struct { drawn: bool = false, end: f32 = 0, hangs: usize = 0 };
@@ -427,6 +430,8 @@ pub const Disasm = struct {
marks.changed_heat = now.written(touch.addr, touch.len, .memory, 0);
}
};
+ // Narrower than a word, it is read at its width.
+ if (touch.len < 8) return .{ .drawn = true, .end = rows.narrow(u, x, y, shown, touch.addr, touch.len, room, marks).end };
return .{ .drawn = true, .end = rows.chain(u, x, y, shown, touch.addr, room, marks).end };
}
// Only a register: a small `reg` of what it left there.
@@ -481,9 +486,7 @@ const Say = struct {
/// its name), three when none says. How many rows they take.
fn arguments(a: Say, row: Insn, to: u64, moment: u64) usize {
const name = a.functionName(to, moment);
- const count = @min(row.params orelse for (a.rec.functions) |fun| {
- if (std.mem.eql(u8, fun.name, name)) break fun.params;
- } else argumentCount(a.rec, row, name) orelse 3, 6);
+ const count = a.argumentRows(row, to, moment);
const shown = a.rec.moment(moment);
// Flags by name, where a system call of its name says which argument they are.
const nr: ?u64 = if (std.meta.stringToEnum(std.os.linux.SYS, name)) |sys| @intFromEnum(sys) else null;
@@ -499,6 +502,14 @@ const Say = struct {
return count;
}
+ /// How many argument rows hang under a call to `to`.
+ fn argumentRows(a: Say, row: Insn, to: u64, moment: u64) usize {
+ const name = a.functionName(to, moment);
+ return @min(row.params orelse for (a.rec.functions) |fun| {
+ if (std.mem.eql(u8, fun.name, name)) break fun.params;
+ } else argumentCount(a.rec, row, name) orelse 3, 6);
+ }
+
/// The call at `row` (to `to`, made at `moment`) in C's form, its
/// arguments as the source wrote that many and as the system call of its
/// name types them; with ` = result` when it has returned.
@@ -601,6 +612,16 @@ const Say = struct {
}
};
+/// How many rows of arguments hang under `row` while it is current at
+/// `moment`: a direct call's, a `syscall`'s; 0 for anything else.
+pub fn hanging(u: ui.Ui, rec: *const Recording, row: Insn, moment: u64) usize {
+ const a: Say = .{ .u = u, .rec = rec, .y = 0, .x = 0, .room = 0 };
+ if (std.mem.eql(u8, row.mnemonic(), "syscall")) return @min(zt.syscalls.signature(rec.register(moment, "rax")).len, 6);
+ const b = rec.insn_branches[moment] orelse return 0;
+ if (b.kind != .call or target(row) == null) return 0;
+ return a.argumentRows(row, b.to, moment);
+}
+
/// A call's argument registers, in order; a system call's.
const carriers = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9" };
const carriers_sys = [_][]const u8{ "rdi", "rsi", "rdx", "r10", "r8", "r9" };
diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig
index cbd8f7f..3abd052 100644
--- a/anim/src/hexdump.zig
+++ b/anim/src/hexdump.zig
@@ -155,16 +155,18 @@ pub fn draw(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: usize
}
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 {
- const v = u.moved(x, 0);
+ const dump = u.moved(x, 0);
var arcs: rows.Arcs = .{};
var at_rows: [64]RowAt = undefined;
for (at_rows[0..@min(count, at_rows.len)], 0..) |*r, i| r.* = .{ .addr = first + 16 * i, .y = y + @as(f32, @floatFromInt(i)) * m.row };
const shown_rows = at_rows[0..@min(count, at_rows.len)];
- const moment = now.shown(.memory);
const lead = ui.shared(&.{ first, first + 16 * @as(u64, count -| 1) });
// Room for the addresses, once for the dump: by its widest.
const shift = rows.addressRoom(first + 16 * @as(u64, count -| 1));
- for (0..count) |i| {
+ // At a run the values crossfade (8 f), unmarked: the rows twice, the arcs once.
+ const passes = crossfade(now);
+ for (passes.moments[0..passes.n], passes.shows[0..passes.n], 0..) |moment, shows, pass| for (0..count) |i| {
+ const v = dump.faded(shows);
const addr = first + 16 * i;
const ry = y + @as(f32, @floatFromInt(i)) * m.row;
var values: [16]u8 = undefined;
@@ -203,6 +205,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.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) {
@@ -216,7 +219,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
}
@import("map.zig").row(.view, addr, v, .{ .x = 0, .y = ry, .w = theme.layout.state.w, .h = m.row });
rows.bytesAt(v, ry, addr, &values, &known, runs[0..n], of.region, lead, holds_drawn, moment, shift);
- 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);
+ 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]);
// The size word of the chunk after: malloc's, a note after the reading.
const last = runs[n - 1];
@@ -224,8 +227,19 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
const size = std.mem.readInt(u64, values[8..16], .little) & ~@as(u64, 7);
v.text(.sans, theme.size.sans.micro, end, rows.baseline(ry) - 1, v.print("malloc's: a chunk of {d}", .{size}), t.faint);
}
+ };
+ arcs.draw(dump, theme.metric.arc.lanes.len);
+}
+
+/// The memory a dump draws now, and how much each shows: at a run, what
+/// the step changed crossfades over 8 f, unmarked; otherwise memory's state.
+const Passes = struct { moments: [2]Recording.Moment, shows: [2]f32, n: usize };
+fn crossfade(now: cursors.Now) Passes {
+ if (now.plan.gait == .run and !now.resting()) {
+ const q = std.math.clamp(now.since(.memory, 0) / (8.0 / 60.0), 0, 1);
+ if (q > 0 and q < 1) return .{ .moments = .{ now.before(), now.moment() }, .shows = .{ 1 - q, q }, .n = 2 };
}
- arcs.draw(v, theme.metric.arc.lanes.len);
+ return .{ .moments = .{ now.shown(.memory), undefined }, .shows = .{ 1, 0 }, .n = 1 };
}
/// A row of a panel: its first byte's address and its top.
@@ -270,6 +284,8 @@ fn aim(arcs: *rows.Arcs, now: cursors.Now, field: u64, target: u64, from: f32, s
const moment = now.moment();
var arc = state;
arc.from = from;
+ // A run draws no arcs: they fade in, settled, as it ends.
+ arc.shows *= 1 - now.hurried;
arc.ink = rows.ink(rows.regionOf(moment, target));
for (shown) |r| if (target >= r.addr and target < r.addr + size) {
if (r.y == from) return;
@@ -342,7 +358,14 @@ pub const Fields = struct {
marks: []const f32 = &.{},
/// Bytes known from elsewhere than the moment's memory (what a syscall
/// was given, as the kernel took them), and how much they show (0 to 1).
- given: ?struct { addr: u64, bytes: []const u8, shows: f32 } = null,
+ given: ?struct {
+ addr: u64,
+ bytes: []const u8,
+ shows: f32,
+ /// What a read fills: seconds since the kernel's work reached the
+ /// first byte; they land a byte every 2 f from the low address (null: all at once).
+ since: ?f32 = null,
+ } = null,
/// How much a frame round every field shows: the kernel reading them.
read: f32 = 0,
/// The part of the region the recording read at the stop shown (null:
@@ -353,6 +376,9 @@ pub const Fields = struct {
/// How many of the newest steps it has been on screen through: only
/// their changes are marked.
watched: usize = std.math.maxInt(usize),
+ /// 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,
};
/// The region's rows in view `v`, from `y`, sixteen bytes a row from its
@@ -392,7 +418,8 @@ pub fn fielded(v: View, now: cursors.Now, y: f32, of: Fields) void {
ry += m.row;
}
last = r;
- fieldRow(u, now, ry, of.base + 16 * r, moment, of, lead, shift);
+ const passes = crossfade(now);
+ for (passes.moments[0..passes.n], passes.shows[0..passes.n]) |mm, shows| fieldRow(u.faded(shows), now, ry, of.base + 16 * r, if (passes.n == 2) mm else moment, of, lead, shift);
at_rows.append(u.f.scratch, .{ .addr = of.base + 16 * r, .y = ry }) catch {};
ry += m.row;
}
@@ -479,6 +506,7 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
if (of.given) |g| for (0..16) |i| {
const a = addr + i;
if (a < g.addr or a >= g.addr + g.bytes.len) continue;
+ if (g.since) |since| if (since < @as(f32, @floatFromInt(a - g.addr)) * @import("syscalls.zig").Plan.byte) continue;
given_values[i] = g.bytes[a - g.addr];
given_known[i] = true;
gives = true;
@@ -491,8 +519,12 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
var at: u8 = 0;
while (at < 16 and addr + at < of.base + of.len) {
const here = addr + at;
- const field = for (of.fields) |field| {
- if (of.base + field.at <= here and here < of.base + field.at + field.len) break field;
+ var field_k: usize = 0;
+ const field = for (of.fields, 0..) |field, fk| {
+ if (of.base + field.at <= here and here < of.base + field.at + field.len) {
+ field_k = fk;
+ break field;
+ }
} else null;
var run: rows.Run = .{ .first = at, .len = 1, .kind = .loose };
if (field) |fl| {
@@ -503,6 +535,10 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
.text => .text,
};
run.heat = now.writtenWatched(here, run.len, .memory, 0, 0, of.watched);
+ run.changed = now.changedBytes(here, run.len);
+ 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;
var framed: f32 = 0;
if (fl.mark) |k| if (k < of.marks.len) {
framed = of.marks[k];
@@ -556,8 +592,16 @@ pub fn reading(u: ui.Ui, y: f32, shift: f32, moment: Recording.Moment, values: *
const len: usize = @intCast(if (fl.type) |ty| @min(fl.len, ty.size() orelse fl.len) else fl.len);
if (len == 0 or std.mem.indexOfScalar(bool, known[first..][0..len], false) != null) continue;
defer if (fl.note.len > 0) {
- u.text(.sans, theme.size.sans.micro, x, base - 1, fl.note, t.faint);
- x += u.width(.sans, theme.size.sans.micro, fl.note) + adv;
+ // Cut where the panel ends, at a word, with `…`; never mid-word without it.
+ var note = fl.note;
+ while (note.len > 0 and x + u.width(.sans, theme.size.sans.micro, if (note.len == fl.note.len) note else u.print("{s}\u{2026}", .{note})) > room) {
+ note = std.mem.trimEnd(u8, note[0 .. std.mem.lastIndexOfScalar(u8, note, ' ') orelse 0], " \u{00b7}");
+ }
+ if (note.len > 0) {
+ const said = if (note.len == fl.note.len) note else u.print("{s}\u{2026}", .{note});
+ u.text(.sans, theme.size.sans.micro, x, base - 1, said, t.faint);
+ x += u.width(.sans, theme.size.sans.micro, said) + adv;
+ }
};
if (fl.reads == .bytes) continue;
const bytes = values[first..][0..len];
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig
index 623e966..65a9463 100644
--- a/anim/src/loupe.zig
+++ b/anim/src/loupe.zig
@@ -54,9 +54,15 @@ pub const Loupe = struct {
/// `open`: its pointer framed as read; the stem draws and the loupe
/// rises with it, its shadow growing; its target's frame lands last.
+ /// It may open again after a `close`. (Its clock runs on past the
+ /// open, for the strikes in it: `opening` counts open's lengths.)
pub fn open(l: *const Loupe, s: *anim.Frame) void {
- s.play(.{l.opening.to(1)}, .{ .seconds = time.open, .ease = anim.ease.linear });
+ const start = s.cursor;
+ s.play(.{ l.opening.to(0), l.closing.to(0) }, .{ .seconds = 0 });
+ s.play(.{l.opening.to(open_lengths)}, .{ .seconds = open_lengths * time.open, .ease = anim.ease.linear });
+ s.cursor = start + time.open;
}
+ const open_lengths = 8;
/// `close`: the stem draws back and the loupe sinks, fading as it falls.
pub fn close(l: *const Loupe, s: *anim.Frame) void {
@@ -99,14 +105,24 @@ pub const Loupe = struct {
const b = back.apply(.{ px[2], px[3] });
pointer = .{ .x = a[0], .y = a[1], .w = b[0] - a[0], .h = b[1] - a[1] };
target = row.fields.base;
+ // From the band's view it lies over the stack, never the registers (what a step changes there is what the captions are about).
+ const stack = l.stage.box(u.at, .stack);
+ const h = theme.layout.panelH(k.rows);
+ return .{ .box = .{ .x = stack.x, .y = stack.y + stack.h - h, .w = k.width, .h = h }, .pointer = pointer, .target = target, .first = target, .ink = rows.ink(rows.regionOf(moment, target)) };
},
}
if (target == 0) return null;
// shortcut: it keeps to the stage and does not yet move past the current marks or a changed row; the scene picks a pointer whose loupe covers neither.
const stage = theme.canvas.stage;
const h = theme.layout.panelH(k.rows);
- const x = std.math.clamp(@max(pointer.x - k.hang, right), stage.x, stage.x + stage.w - k.width);
- const y = @min(pointer.y + pointer.h - 1, stage.y + stage.h - h);
+ var x = std.math.clamp(@max(pointer.x - k.hang, right), stage.x, stage.x + stage.w - k.width);
+ var y = @min(pointer.y + pointer.h - 1, stage.y + stage.h - h);
+ // A deeper one with no room to the right hangs under the one it opens from, both whole.
+ if (l.from == .field and x < right) {
+ const parent = l.from.field.loupe.place(u, now).?.box;
+ x = parent.x;
+ y = @min(parent.y + parent.h + k.shadow[0][1], stage.y + stage.h - h);
+ }
return .{ .box = .{ .x = x, .y = y, .w = k.width, .h = h }, .pointer = pointer, .target = target, .first = (target & ~@as(u64, 15)) - 16 * (k.rows / 2), .ink = rows.ink(rows.regionOf(moment, target)) };
}
@@ -171,7 +187,10 @@ pub const Loupe = struct {
const top = m.tag + m.pad;
v.clip(.{ .x = 0, .y = m.tag, .w = b.w, .h = b.h - m.tag });
// By the scene's fields: the rows that hold them, the rest `more`.
- if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, l.from.row.fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad });
+ // Its fields strike once it has opened, 6 f after it and 6 f apart.
+ var fields = if (l.from == .row) l.from.row.fields else undefined;
+ if (l.from == .row and now.walking()) fields.struck = opened - time.open - cursors.write_apart;
+ if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad });
v.unclip();
// Its target, framed bright: each field of the struct, or the word.
const framed = std.math.clamp((since - time.stem - time.frame) / time.frame, 0, 1);
@@ -183,8 +202,18 @@ pub const Loupe = struct {
for (o.type.record.fields) |field| frameRun(w, row_y, shift, o.addr + field.offset - (p.target & ~@as(u64, 15)), field.type.size() orelse 8);
} else frameRun(w, row_y, shift, p.target % 16, 8);
}
- // The stem: a bracket under the pointer's digits, lying on the tag, drawn head first.
const drawn = cursors.standard(std.math.clamp(since / time.stem, 0, 1)) * (1 - closed);
+ // From a row of the band's view: the stem leaves the row's left, goes down the gutter's right lane, into the tag.
+ if (l.from == .row) {
+ const view = l.stage.box(placed, .view);
+ const mid = p.pointer.y + p.pointer.h / 2;
+ const lane = view.x - k.lane;
+ u.faded(@min(rise * 2, 1)).route(&.{ .{ view.x, mid }, .{ lane, mid }, .{ lane, b.y + lower + m.tag / 2 }, .{ b.x - 2, b.y + lower + m.tag / 2 } }, p.ink, .{ .width = theme.stroke.line, .head = .{ 10, 10 }, .radius = 4, .progress = drawn });
+ return;
+ }
+ // Hung under the one it opens from: the stem goes down from the pointer to its tag.
+ if (b.y > p.pointer.y + p.pointer.h + 1) u.faded(@min(rise * 2, 1)).fill(.{ .x = p.pointer.x + 8, .y = p.pointer.y + p.pointer.h - 3, .w = k.stem, .h = (b.y + lower - (p.pointer.y + p.pointer.h - 3)) * drawn }, p.ink);
+ // The stem: a bracket under the pointer's digits, lying on the tag, drawn head first.
u.faded(@min(rise * 2, 1)).fill(.{ .x = p.pointer.x - 2, .y = p.pointer.y + p.pointer.h - 3, .w = (p.pointer.w + 4) * drawn, .h = k.stem }, p.ink);
}
};
diff --git a/anim/src/map.zig b/anim/src/map.zig
index e22db9f..341d75f 100644
--- a/anim/src/map.zig
+++ b/anim/src/map.zig
@@ -36,6 +36,14 @@ pub const diving = struct {
pub const surface = 84;
};
+/// The dive's frames over which the falling map crossfades into the minimap's drawing.
+pub const minimap_lands = [2]f32{ 90, 96 };
+
+/// How much of the minimap shows at dive frame `t`: none while the map falls, crossfading in as it lands.
+pub fn minimapShows(t: f32) f32 {
+ return std.math.clamp((t - minimap_lands[0]) / (minimap_lands[1] - minimap_lands[0]), 0, 1);
+}
+
/// Where each working window is on the map this frame, in canvas pixels.
var window_px: [7]?[4]f32 = @splat(null);
@@ -46,6 +54,16 @@ var windows: [7]?[2]u64 = @splat(null);
var rows: [7][160]struct { key: u64, box: [4]f32 } = undefined;
var counts: [7]usize = @splat(0);
+/// The most rows each map panel has wanted so far (`measure`): its box is
+/// as long as that, its content, and no longer.
+/// shortcut: process-wide and a frame behind, as the drawing flags are; a scene's first frame packs by the defaults.
+var held: [7]usize = @splat(0);
+
+/// While the map draws: `panel` wants `n` rows for what it shows now.
+pub fn measure(panel: Panel, n: usize) void {
+ if (ui.mapping) held[@intFromEnum(panel)] = @max(held[@intFromEnum(panel)], n);
+}
+
/// A working panel shows the rows of keys `first` to `last`.
pub fn window(panel: Panel, first: u64, last: u64) void {
if (!ui.mapping) windows[@intFromEnum(panel)] = .{ first, last };
@@ -62,12 +80,13 @@ pub fn row(panel: Panel, key: u64, u: ui.Ui, r: Rect) void {
counts[i] += 1;
}
-/// The map's boxes for a recording: the drawing (with a lens) and the
-/// source in the first column, the disassembly in the second, the lens's
-/// view (its region whole), the registers and the backtrace in the third,
-/// the stack in the fourth. Each as long as its content where that is
-/// shorter than the column.
-// shortcut: a panel longer than its column is a window of what fits; continuing it in the next column's free space (`continued`), and the key in a column's foot, are not built.
+/// The map's boxes for a recording, packed by content: each panel as long
+/// as its rows (`measure`), the next under it 12 apart (design/README.md,
+/// "The map and the minimap"). The drawing and the source in the first
+/// column, the backtrace at its foot; the disassembly in the second; the
+/// lens's view, the registers, and in the rest the stack going on
+/// (`continued`), in the third; the stack in the fourth, whole.
+// shortcut: a column's rest after the disassembly is page: the 5-row dumps round what the registers point at, the open loupes and the key are not built.
pub fn split(rec: *const Recording, lens: bool) Split {
const st = theme.map.stage;
const c = theme.map.columns;
@@ -75,21 +94,32 @@ pub fn split(rec: *const Recording, lens: bool) Split {
const gap = theme.canvas.row_gap;
const panelH = theme.layout.panelH;
const foot = st.y + st.h;
+ const want = struct {
+ fn of(panel: Panel, default: usize) f32 {
+ const n = held[@intFromEnum(panel)];
+ return @floatFromInt(if (n > 0) n else default);
+ }
+ }.of;
const band: Rect = .{ .x = c[0], .y = st.y, .w = w, .h = if (lens) theme.layout.split.subject.band.h else 0 };
const source_y = if (lens) band.y + band.h + gap else st.y;
- const source_rows: f32 = @floatFromInt(@min(rec.line_count, theme.layout.rowsIn(foot - source_y)));
- const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens) panelH(theme.map.memory_rows) else 0 };
+ const bt_rows = want(.backtrace, 5);
+ const source_rows: f32 = @floatFromInt(@min(rec.line_count, theme.layout.rowsIn(foot - source_y - gap - panelH(bt_rows))));
+ const source: Rect = .{ .x = c[0], .y = source_y, .w = w, .h = panelH(source_rows) };
+ const bt_y = source.y + source.h + gap;
+ const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens) panelH(@min(want(.view, theme.map.memory_rows), theme.map.memory_rows)) else 0 };
const registers: Rect = .{ .x = c[2], .y = if (lens) view.y + view.h + gap else st.y, .w = w, .h = panelH(17) };
- const bt_y = registers.y + registers.h + gap;
+ const more_y = registers.y + registers.h + gap;
+ const more_h = foot - more_y;
return .{
.band = band,
.view = view,
- .source = .{ .x = c[0], .y = source_y, .w = w, .h = panelH(source_rows) },
- .disasm = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(theme.map.disasm_rows) },
+ .source = source,
+ .disasm = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(@min(want(.disasm, theme.map.disasm_rows), theme.map.disasm_rows)) },
.registers = registers,
.stack = .{ .x = c[3], .y = st.y, .w = w, .h = st.h },
- .backtrace = .{ .x = c[2], .y = bt_y, .w = w, .h = @min(panelH(12), foot - bt_y) },
+ .backtrace = .{ .x = c[0], .y = bt_y, .w = w, .h = @min(panelH(bt_rows), foot - bt_y) },
.dump_rows = theme.map.memory_rows,
+ .more = .{ .x = c[2], .y = more_y, .w = w, .h = if (more_h >= panelH(3)) theme.layout.panelH(@floor((more_h - 32) / 24)) else 0 },
};
}
@@ -108,6 +138,8 @@ pub const Map = struct {
t: anim.Value,
/// The map as an object of the scene, under the panels: it shows from `show`.
obj: anim.Obj = undefined,
+ /// Where the program is: for the thread across the gutter, and the minimap's flashes.
+ cursor: ?@import("cursor.zig").Cursor = null,
const Part = struct { ctx: *const anyopaque, draw: *const fn (*const anyopaque, *sk.Frame, anim.Placed) void };
@@ -164,33 +196,27 @@ pub const Map = struct {
const t = placed.value(m.t);
if (t >= diving.land) return;
const fixed = @import("words.zig").fixed(f, placed, 0);
- // The map: from filling the frame (half its units) to the minimap's rect (a twentieth).
- const q = theme.ease(.glide, std.math.clamp((t - diving.move) / diving.fall, 0, 1));
- const mini = theme.minimap.box;
- const k = std.math.pow(f32, 0.5, 1 - q) * std.math.pow(f32, theme.minimap.scale, q);
- const origin = [2]f32{ q * mini.x, q * mini.y };
- var at = fixed.at;
- at.xf = at.xf.mul(.translate(origin[0], origin[1])).mul(.scale(k, k));
- at.scale = fixed.at.scale * k;
- fixed.fill(.{ .x = 0, .y = 0, .w = theme.canvas.width, .h = theme.canvas.height }, theme.color.page);
- m.drawAt(f, at, k < 0.12);
- // The rest of the map veiled from 6 f to 24 f, lifting as it lands.
- const veil = std.math.clamp((t - diving.bright) / (diving.move - diving.bright), 0, 1) * (1 - std.math.clamp((t - diving.lift) / (diving.land - diving.lift), 0, 1));
- (ui.Ui{ .f = f, .at = at }).veil(theme.map.stage, veil);
- // The windows bright from 0 to 6 f, over the veil.
- m.outline(f, at, k < 0.12, std.math.clamp(t / diving.bright, 0, 1));
+ const at = m.falling(f, placed, t);
+ // Large, it is under the panels diving out of it; small (`falling`), over them, into the corner.
+ if (at.scale >= small * fixed.at.scale) m.copy(f, at, fixed, t) else fixed.fill(.{ .x = 0, .y = 0, .w = theme.canvas.width, .h = theme.canvas.height }, theme.color.page);
// Each working panel: from its window on the map at the start to its place, 6 f after the one before.
const back = at.xf.invert();
const working = m.frame.now(placed);
- inline for (.{ "band", "view", "source", "registers", "disasm", "stack", "backtrace" }, 0..) |name, order| {
+ // In the frame's reading order, except that a panel drawn over another
+ // sets off first: a panel in its place is never crossed by one still
+ // on its way (the disassembly over the source's foot, the stack over
+ // the registers' lower rows were, for a third of a second).
+ inline for (.{ "band", "view", "disasm", "stack", "source", "registers", "backtrace" }, 0..) |name, order| {
const i = @intFromEnum(@field(Panel, name));
const box = @field(working, name);
if (box.h > 0) if (window_px[i]) |w| {
const a = back.apply(.{ w[0], w[1] });
const b = back.apply(.{ w[2], w[3] });
- // On the map as it fills the frame (half its units): the panel's rows on the window's rows, its tag above them.
+ // On the map as it fills the frame (half its units): the panel's rows on the window's rows, its tag above them;
+ // a window that is the panel whole (the band, the registers) has its tag in it.
const s0 = (b[0] - a[0]) / 2 / box.w;
- const lead = (if (i == @intFromEnum(Panel.band)) 0 else theme.metric.context.tag + theme.metric.context.pad) * s0;
+ const whole = i == @intFromEnum(Panel.band) or i == @intFromEnum(Panel.registers);
+ const lead = (if (whole) 0 else theme.metric.context.tag + theme.metric.context.pad) * s0;
const from: Rect = .{ .x = a[0] / 2, .y = a[1] / 2 - lead, .w = box.w * s0, .h = box.h * s0 };
const p = theme.ease(.glide, std.math.clamp((t - diving.move - @as(f32, @floatFromInt(order)) * diving.apart) / diving.travel, 0, 1));
const scale = std.math.pow(f32, s0, 1 - p);
@@ -203,6 +229,64 @@ pub const Map = struct {
}
}
+ /// Below this scale (of the frame's) the falling map is drawn over the
+ /// panels, on its way into the corner, and not under them.
+ const small = 0.12;
+
+ /// Where the map is at dive frame `t`: from filling the frame (half
+ /// its units) to the minimap's rect (a twentieth), its scale on the
+ /// logarithm, its corner going toward the minimap's as the scale does,
+ /// so that it falls into the corner.
+ fn falling(m: *const Map, f: *sk.Frame, placed: anim.Placed, t: f32) anim.Placed {
+ _ = m;
+ const fixed = @import("words.zig").fixed(f, placed, 0);
+ const q = theme.ease(.glide, std.math.clamp((t - diving.move) / diving.fall, 0, 1));
+ const mini = theme.minimap.box;
+ const k = std.math.pow(f32, 0.5, 1 - q) * std.math.pow(f32, theme.minimap.scale, q);
+ const toward = (0.5 - k) / (0.5 - theme.minimap.scale);
+ var at = fixed.at;
+ at.xf = at.xf.mul(.translate(toward * mini.x, toward * mini.y)).mul(.scale(k, k));
+ at.scale = fixed.at.scale * k;
+ return at;
+ }
+
+ /// The falling map, veiled, its windows outlined, and its edge as the
+ /// minimap's; it crossfades into the minimap's own drawing as it lands.
+ fn copy(m: *const Map, f: *sk.Frame, at: anim.Placed, fixed: ui.Ui, t: f32) void {
+ const shows = 1 - minimapShows(t);
+ if (shows <= 0) return;
+ const mini = at.scale < small * fixed.at.scale;
+ if (!mini) fixed.fill(.{ .x = 0, .y = 0, .w = theme.canvas.width, .h = theme.canvas.height }, theme.color.page);
+ var faded = at;
+ faded.pose.opacity *= shows;
+ m.drawAt(f, faded, mini);
+ // The rest of the map veiled from 6 f to 24 f, lifting as it lands.
+ const veil = std.math.clamp((t - diving.bright) / (diving.move - diving.bright), 0, 1) * (1 - std.math.clamp((t - diving.lift) / (minimap_lands[1] - diving.lift), 0, 1));
+ (ui.Ui{ .f = f, .at = faded }).veil(theme.map.stage, veil);
+ // The windows bright from 0 to 6 f, over the veil.
+ m.outline(f, faded, mini, std.math.clamp(t / diving.bright, 0, 1));
+ var edge: ui.Ui = .{ .f = f, .at = faded };
+ edge.at.xf = .identity;
+ const a = at.xf.apply(.{ 0, 0 });
+ const b = at.xf.apply(.{ 2 * theme.canvas.width, 2 * theme.canvas.height });
+ const q = std.math.clamp((0.5 * fixed.at.scale - at.scale) / ((0.5 - theme.minimap.scale) * fixed.at.scale), 0, 1);
+ edge.faded(q).frame(.{ .x = a[0] - 1, .y = a[1] - 1, .w = b[0] - a[0] + 2, .h = b[1] - a[1] + 2 }, theme.color.rule, @max(1, fixed.at.scale));
+ }
+
+ /// Small, the falling map over the working panels (the minimap's drawer calls it).
+ pub fn fallingOver(m: *const Map, f: *sk.Frame, placed: anim.Placed) void {
+ const t = placed.value(m.t);
+ if (t >= minimap_lands[1]) return;
+ const fixed = @import("words.zig").fixed(f, placed, 0);
+ const at = m.falling(f, placed, t);
+ if (at.scale >= small * fixed.at.scale) return;
+ // Its ground, so that it reads over what it passes.
+ var ground: ui.Ui = .{ .f = f, .at = at };
+ ground.at.pose.opacity *= 1 - minimapShows(t);
+ ground.fill(.{ .x = 0, .y = 0, .w = 2 * theme.canvas.width, .h = 2 * theme.canvas.height }, theme.color.page);
+ m.copy(f, at, fixed, t);
+ }
+
/// The map in `at`'s transform (the map's units), and the working
/// frame's windows outlined on it: a 2-unit `dim` frame 4 out; on the
/// minimap (`mini`) a pixel of primary, the focused one 1.5.
@@ -216,10 +300,56 @@ pub const Map = struct {
ui.strokes = mini;
counts = @splat(0);
for (m.parts[0..m.n]) |p| p.draw(p.ctx, f, at);
+ if (m.cursor) |c| m.thread(f, at, c.now(at), mini);
ui.mapping = false;
ui.strokes = false;
}
+ /// The thread on the map: the current line and the pc's row, joined
+ /// across the gutter between source and disassembly (x 1008), gold; on
+ /// the minimap a stroke a pixel wide. And there, a mark no working
+ /// window shows `flash`es: a ring 8 across drawing out to 14 and gone
+ /// (12 f), with the strike (the minimap's own time, 6 f behind).
+ fn thread(m: *const Map, f: *sk.Frame, at: anim.Placed, now: @import("cursor.zig").Now, mini: bool) void {
+ _ = m;
+ const rec = now.rec;
+ const k = at.scale;
+ var raw: ui.Ui = .{ .f = f, .at = at };
+ raw.at.xf = .identity;
+ const marked = now.marked();
+ const line = rows_of(.source, rec.own[marked]);
+ const pc = rows_of(.disasm, rec.register(marked, "rip"));
+ if (line != null and pc != null) {
+ const a = line.?;
+ const b = pc.?;
+ const lane = at.xf.apply(.{ 1008, 0 })[0];
+ const w = if (mini) @max(1, k / theme.minimap.scale) else theme.stroke.line * k;
+ const gold = theme.mark(.current).solid;
+ raw.route(&.{ .{ a[2], (a[1] + a[3]) / 2 }, .{ lane, (a[1] + a[3]) / 2 }, .{ lane, (b[1] + b[3]) / 2 }, .{ b[0], (b[1] + b[3]) / 2 } }, gold, .{ .width = w, .head = null, .radius = 0 });
+ }
+ if (!mini or !now.walking()) return;
+ // A struck word outside every window: the stack's, round its rsp.
+ const since = now.since(.memory, 0);
+ const p = since / (12.0 / 60.0);
+ if (p < 0 or p > 1) return;
+ const win = windows[@intFromEnum(Panel.stack)] orelse return;
+ for (rec.written(now.stops[1], now.stops[0])) |span| {
+ const word = span.addr & ~@as(u64, 7);
+ if (word >= win[0] and word <= win[1]) continue;
+ const box = rows_of(.stack, word) orelse continue;
+ const c = ui.Vec{ (box[0] + box[2]) / 2, (box[1] + box[3]) / 2 };
+ const r = std.math.lerp(@as(f32, 4), 7, p) * k / theme.minimap.scale;
+ raw.faded(1 - p).disc(c, r, null, ui.rgb(theme.color.struck), @max(1, k / theme.minimap.scale));
+ }
+ }
+
+ /// Where the map's row of key `key` in `panel` is this frame, in canvas pixels.
+ fn rows_of(panel: Panel, key: u64) ?[4]f32 {
+ const i = @intFromEnum(panel);
+ for (rows[i][0..counts[i]]) |rw| if (rw.key == key) return rw.box;
+ return null;
+ }
+
/// The working windows' outlines on the map in `at`, `bright` of the way
/// from `dim` to bright; where they are is kept (`window_px`).
fn outline(m: *const Map, f: *sk.Frame, at: anim.Placed, mini: bool, bright: f32) void {
@@ -265,7 +395,10 @@ pub const Map = struct {
/// The minimap: `m` at a twentieth in the caption band's right end, still
/// while the camera moves; the page under it, framed a pixel in `rule`.
pub fn minimap(m: *const Map, f: *sk.Frame, at: anim.Placed) void {
- const fixed = @import("words.zig").fixed(f, at, 0);
+ var shown = at;
+ shown.pose.opacity *= minimapShows(at.value(m.t));
+ if (shown.pose.opacity <= 0) return;
+ const fixed = @import("words.zig").fixed(f, shown, 0);
const box = theme.minimap.box;
fixed.fill(box, theme.color.page);
var placed = fixed.at;
diff --git a/anim/src/nodes.zig b/anim/src/nodes.zig
index b4ba951..81a9953 100644
--- a/anim/src/nodes.zig
+++ b/anim/src/nodes.zig
@@ -71,6 +71,7 @@ pub const Nodes = struct {
hi = @max(hi, (a.ptr + a.size + 15) & ~@as(u64, 15));
};
if (lo < hi) {
+ @import("map.zig").measure(.view, (hi - lo) / 16);
const count = theme.layout.rowsIn(g.stage.box(placed, .view).h);
const first = hexdump.window(now, lo, hi, count);
const shown = @min(count, (hi - first) / 16);
diff --git a/anim/src/root.zig b/anim/src/root.zig
index 84758f8..e289641 100644
--- a/anim/src/root.zig
+++ b/anim/src/root.zig
@@ -275,12 +275,14 @@ pub fn context(s: *anim.Frame, cursor_: Cursor, options: Context.Options) Contex
var at = cursor_;
at.levels.crossings = options.syscalls;
// The map first: while it fills the frame or falls to the minimap it is under the panels diving out of it.
- const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0)), .frame = stage, .t = s.value(map.diving.land + map.diving.still) });
+ const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0)), .frame = stage, .t = s.value(map.diving.land + map.diving.still), .cursor = at });
whole.obj = s.custom(whole, .{ .x = -640, .y = -360, .scale = ui.scale });
whole.add(s, Source{ .cursor = at, .stage = whole.stage, .descent = options.descent });
if (options.descent) whole.add(s, Descent{ .cursor = at, .stage = whole.stage }) else whole.add(s, Disasm{ .cursor = at, .stage = whole.stage });
whole.add(s, Registers{ .cursor = at, .stage = whole.stage, .syscalls = options.syscalls, .quiet = options.quiet });
whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above });
+ // The stack goes on in the rest of the memory's column, from where its own column ends.
+ whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above - @as(i32, @intCast(theme.layout.rowsIn(whole.stage.first.stack.h))), .part = .more });
whole.add(s, Backtrace{ .cursor = at, .stage = whole.stage });
return .{
.stage = stage,
diff --git a/anim/src/rows.zig b/anim/src/rows.zig
index 1d097a1..69aa62b 100644
--- a/anim/src/rows.zig
+++ b/anim/src/rows.zig
@@ -58,6 +58,41 @@ pub const Marks = struct {
lead: usize = 0,
};
+/// `chain` of a memory access narrower than a word: its address, then what
+/// the access reads there at its width (`7fffffffecc4 ◂ 15`), the marks
+/// as `chain` takes them (`first`, `read` on the address; `changed` 1 on the value).
+pub fn narrow(u: ui.Ui, x: f32, y: f32, moment: Recording.Moment, addr: u64, len: u64, room: f32, marks: Marks) Hops {
+ const base = baseline(y);
+ const w = ui.Value.of(addr, true).width();
+ const at_addr: Rect = .{ .x = x, .y = y, .w = w, .h = row_h };
+ var face_ink: ui.Ink = .{ .ink = ui.rgb(ink(regionOf(moment, addr))) };
+ if (u.written(at_addr, marks.first)) |struck| face_ink = struck;
+ if (marks.read == 0) u.read(at_addr, marks.read_shows);
+ _ = u.address(x, base, addr, .{ .ink = face_ink.ink, .face = face_ink.face, .lead = marks.lead });
+ var hops: Hops = .{ .n = 1, .end = x + w };
+ hops.x[0] = x;
+ hops.w[0] = w;
+ var raw: [8]u8 = @splat(0);
+ var known: [8]bool = @splat(false);
+ moment.read(addr, raw[0..@min(len, 8)], known[0..@min(len, 8)]) catch return hops;
+ if (std.mem.indexOfScalar(bool, known[0..@min(len, 8)], false) != null) return hops;
+ const value = std.mem.readInt(u64, &raw, .little);
+ const shown = ui.Value.of(value, false);
+ if (hops.end + m.arrow_w + shown.width() > room) return hops;
+ const at = u.arrow(hops.end, y + row_h / 2, .holds);
+ const marked: Rect = .{ .x = at, .y = y, .w = shown.width(), .h = row_h };
+ var value_ink: ui.Ink = .{ .ink = ui.rgb(t.primary) };
+ if (marks.changed == 1) if (u.written(marked, marks.changed_heat)) |struck| {
+ value_ink = struck;
+ };
+ _ = u.value(at, base, value, false, value_ink);
+ hops.x[1] = at;
+ hops.w[1] = shown.width();
+ hops.n = 2;
+ hops.end = at + shown.width() + if (shown.decimal) 8 + @as(f32, @floatFromInt(std.fmt.count("{d}", .{value}))) * adv else 0;
+ return hops;
+}
+
/// Where a chain's hops were drawn: x and width of each one's digits.
pub const Hops = struct {
x: [6]f32 = undefined,
@@ -348,6 +383,11 @@ pub const Run = struct {
/// Its mark: struck (heat), read (shows), held is in the heat.
heat: ui.Heat = .none,
read: f32 = 0,
+ /// The bytes of it whose value the heat's step changed, first and last
+ /// (from `first`): what the strike, the arm and the corner cover. Null: all of it.
+ changed: ?[2]u8 = null,
+ /// Frames between the strikes of its bytes, from the low address.
+ apart: f32 = 1,
};
/// `bytes`: a hexdump row of sixteen bytes at `addr`: a bracket at 7
@@ -384,22 +424,28 @@ pub fn bytesAt(at: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *cons
const r: Rect = .{ .x = x0, .y = y + 1, .w = x1 - x0, .h = row_h - 2 };
const field = run.kind == .number or run.kind == .pointer or run.kind == .text;
if (field) u.fill(r, theme.color.raised);
- // Marks per run, never per byte: struck (the softened paper, the
- // digits bold and bright), read (a frame 3 out), held (a turned
- // corner at the run's top left).
- var face: ui.Face = .mono;
- var struck_ink: ?ui.Color = null;
+ // Read is per run (a frame 3 out). A write's marks cover the bytes
+ // whose value changed, first to last (`changed`): armed, then struck
+ // a byte a frame from the low address (the softened paper, the
+ // digits bold and bright), held by a turned corner on the first.
const h = run.heat;
- if (h.arm > 0) u.faded(h.arm).frame(.{ .x = x0 - 3, .y = y - 1, .w = x1 - x0 + 6, .h = row_h + 2 }, theme.mark(.write).solid, 2);
- const solid = if (h.level >= 1) h.solid * h.in else 0;
- if (solid > 0) {
- u.fill(.{ .x = r.x - h.out, .y = r.y - h.out, .w = r.w + 2 * h.out, .h = r.h + 2 * h.out }, ui.mix(theme.color.raised, theme.color.struck, solid));
- if (solid >= 0.5) {
- face = .mono_bold;
- struck_ink = ui.rgb(t.bright);
- }
- }
- u.corner(x0, y + 2, m.corner, h.level * h.corner);
+ const lo: u8 = if (run.changed) |c| c[0] else 0;
+ const hi: u8 = if (run.changed) |c| c[1] else run.len - 1;
+ const s0 = byteX(run.first + lo) - 4;
+ const s1 = byteX(run.first + hi) + 28;
+ if (h.arm > 0) u.faded(h.arm).frame(.{ .x = s0 - 3, .y = y - 1, .w = s1 - s0 + 6, .h = row_h + 2 }, theme.mark(.write).solid, 2);
+ var solid_of: [16]f32 = @splat(0);
+ if (h.level >= 1 and h.solid > 0) for (lo..@as(usize, hi) + 1) |j| {
+ const i: u8 = @intCast(run.first + j);
+ const solid = h.solid * std.math.clamp(h.in - @as(f32, @floatFromInt(j - lo)) * run.apart / (60.0 * theme.time.strike.in), 0, 1);
+ solid_of[j] = solid;
+ if (solid <= 0) continue;
+ // Each byte's paper up to the next one's, the pulse on the span's outer edges.
+ const bx0 = byteX(i) - 4 - if (j == lo) h.out else 0;
+ const bx1 = (if (j < hi) byteX(i + 1) - 4 else byteX(i) + 28) + if (j == hi) h.out else 0;
+ u.fill(.{ .x = bx0, .y = r.y - h.out, .w = bx1 - bx0, .h = r.h + 2 * h.out }, ui.mix(theme.color.raised, theme.color.struck, solid));
+ };
+ u.corner(s0, y + 2, m.corner, h.level * h.corner);
if (run.read > 0) u.faded(run.read).frame(.{ .x = x0 - 3, .y = y - 1, .w = x1 - x0 + 6, .h = row_h + 2 }, theme.mark(.read).solid, 2);
// A little-endian word: the bytes above its highest non-zero one are its padding.
var top: usize = 0;
@@ -422,8 +468,9 @@ pub fn bytesAt(at: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *cons
u.fill(.{ .x = x + 15, .y = y + 11, .w = 4, .h = 4 }, t.faint);
continue;
}
- const c = struck_ink orelse if (j <= top) run_ink else ui.mix(run_ink, theme.color.page, theme.metric.context.pad_alpha);
- u.text(face, size, x, base, u.print("{x:0>2}", .{values[i]}), c);
+ const struck = solid_of[j] >= 0.5;
+ const c = if (struck) ui.rgb(t.bright) else if (j <= top) run_ink else ui.mix(run_ink, theme.color.page, theme.metric.context.pad_alpha);
+ u.text(if (struck) .mono_bold else .mono, size, x, base, u.print("{x:0>2}", .{values[i]}), c);
}
}
}
diff --git a/anim/src/source.zig b/anim/src/source.zig
index bbc985e..3843825 100644
--- a/anim/src/source.zig
+++ b/anim/src/source.zig
@@ -58,8 +58,18 @@ pub const Source = struct {
const shown_first: u32 = @intFromFloat(windows[if (going >= 0.5) 1 else 0]);
// Waiting: the pc is in code with no source, under this line's call.
const waits = p.descent and !rec.sourced(now.marked()) and rec.own[now.marked()] != 0;
- const note = if (waits) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(firstOwn(rec, now.marked()), "rip")), rec.own[now.marked()], whereIs(u, rec, now.marked()) }) else if (rec.line_count > fit) u.print("lines {d} to {d} of {d}", .{ shown_first, @min(shown_first + fit - 1, rec.line_count), rec.line_count }) else u.print("{d} lines", .{rec.line_count});
- const body = u.panel(box.w, box.h, rec.file, .{ .focus = p.focus, .note = note });
+ const lines_note = if (rec.line_count > fit) u.print("lines {d} to {d} of {d}", .{ shown_first, @min(shown_first + fit - 1, rec.line_count), rec.line_count }) else u.print("{d} lines", .{rec.line_count});
+ // Where the pc is, said where it waits: a change of it (on through a
+ // stub) crossfades over the 12 f before the advance, never in a frame.
+ var notes: [2][]const u8 = undefined;
+ for (now.marks, &notes) |mk, *note| note.* = if (p.descent and !rec.sourced(mk) and rec.own[mk] != 0) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(firstOwn(rec, mk), "rip")), rec.own[mk], whereIs(u, rec, mk) }) else lines_note;
+ const swap = !std.mem.eql(u8, notes[0], notes[1]) and (notes[0].ptr != lines_note.ptr or notes[1].ptr != lines_note.ptr) and now.walking();
+ const body = u.panel(box.w, box.h, rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note });
+ if (swap) {
+ const c = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ u.faded(1 - c).tagNote(box.w, notes[0]);
+ u.faded(c).tagNote(box.w, notes[1]);
+ }
const top = body.y + m.pad;
// Where the mark is, and how much of it.
diff --git a/anim/src/stage.zig b/anim/src/stage.zig
index e650906..a24ec28 100644
--- a/anim/src/stage.zig
+++ b/anim/src/stage.zig
@@ -10,7 +10,7 @@ const theme = ui.theme;
const Split = theme.layout.Split;
const Rect = theme.Rect;
-pub const Part = enum { band, view, source, disasm, registers, stack, backtrace };
+pub const Part = enum { band, view, source, disasm, registers, stack, backtrace, more };
pub const Stage = struct {
first: Split,
diff --git a/anim/src/syscalls.zig b/anim/src/syscalls.zig
index 4a46170..ca98920 100644
--- a/anim/src/syscalls.zig
+++ b/anim/src/syscalls.zig
@@ -63,12 +63,15 @@ pub const Plan = struct {
pub fn of(call: Recording.Syscall) Plan {
var p: Plan = .{};
- // Down: the bytes it was given. Up: the bytes it wrote into the program.
- const down: usize = @min(call.text.len, shown_bytes);
+ // Down: the bytes of a buffer it was given (a path is read as the
+ // call comes in: no work). Up: the bytes it wrote into the program.
+ const down: usize = if (bufferRead(call) != null) @min(call.text.len, shown_bytes) else 0;
const up: u64 = if (fills(call)) |span| span.len else 0;
p.bytes = @floatFromInt(@max(down, @min(up, 32)));
- if (p.bytes > 0) p.back = p.fills + p.bytes * byte + 10.0 / 60.0;
- p.returns = p.back - 6.0 / 60.0;
+ // The kernel answers when its work is done; a call with none (open,
+ // close) at frame 108, straight after its call has come in.
+ p.returns = if (p.bytes > 0) p.fills + p.bytes * byte + 6.0 / 60.0 else 108.0 / 60.0;
+ p.back = p.returns + 6.0 / 60.0;
p.struck = p.back + cross;
p.stored = p.struck + time.cascade;
p.advance = p.stored + time.read_value;
@@ -76,6 +79,25 @@ pub const Plan = struct {
return p;
}
+ /// The plan of the call this step crosses with: stepped over (the step
+ /// went on from the call row the cascade before it advanced onto), the
+ /// chart with its frame 18 at the step's first: no second fire.
+ pub fn in(now: cursors.Now, made: Recording.Syscall) Plan {
+ const p = of(made);
+ return if (fromCall(now.rec, now.stops[1])) p.shifted(-time.cascade) else p;
+ }
+
+ fn shifted(p: Plan, by: f32) Plan {
+ var q = p;
+ inline for (.{ "registers", "enters", "leaves", "name", "rows", "card", "work", "fills", "returns", "back", "struck", "stored", "advance", "total" }) |field| @field(q, field) += by;
+ return q;
+ }
+
+ /// When byte `k` of what the call fills lands in the program's memory.
+ pub fn filled(p: Plan, k: u64) f32 {
+ return p.fills + @as(f32, @floatFromInt(@min(k, 31))) * byte;
+ }
+
/// The same as the cursor's plan: the registers are the CPU's level,
/// the bytes memory's.
pub fn step(p: Plan) cursors.Plan {
@@ -88,17 +110,65 @@ pub const Plan = struct {
const per_row = 10;
const shown_bytes = 2 * per_row;
-/// One line of the program and the call into the kernel it makes, as one
-/// step of the cursor, timed by the crossing. A line that makes no call
-/// is walked like any other.
+/// One line of the program and the call into the kernel it makes, timed
+/// by the crossing. Stepped over (the line calls libc's wrapper), in two
+/// steps of the cursor: the instructions before the call as a cascade, the
+/// mark advancing onto the call's row; then the crossing from that row,
+/// with what the line stores after the call in memory's slot, after rax.
+/// A line that makes no call is walked like any other.
pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
+ const rec = c.rec;
const from = c.moment(s);
- const to = c.rec.next(by, from);
- const made = for (c.rec.syscalls) |made| {
+ const to = rec.next(by, from);
+ const made = for (rec.syscalls) |made| {
if (made.enter > from and made.enter <= to) break made;
} else return c.walk(s, by, to);
- const p = Plan.of(made);
- c.step(s, to, p.step(), p.total);
+ // The call that leads to it: the line's first.
+ var call = from;
+ 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).
+ if (call > from) {
+ var before = c.reading(from, call);
+ const regs_before: f32 = @floatFromInt(@popCount(rec.registersChanged(from, call) & ~cursors.quiet));
+ var last = before.at[0] + @min(@max(regs_before - 1, 0), 3) * cursors.write_apart;
+ for (rec.written(from, call)) |span| if (rec.drawn(span, from, call)) {
+ last = @max(last, before.at[1]);
+ };
+ before.advance = last + 12.0 / 60.0;
+ before.travel = time.step;
+ before.total = before.advance + 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;
+ // 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;
+ var stores = false;
+ for (rec.written(call, to)) |span| if (rec.drawn(span, call, to)) {
+ if (fills(made)) |fill| if (span.addr >= fill.addr and span.addr < fill.addr + fill.len) continue;
+ stores = true;
+ };
+ plan.at[1] = @max(p.stored, last_register + cursors.write_apart);
+ plan.at[2] = plan.at[1];
+ plan.advance = (if (stores) plan.at[1] else last_register) + time.read_value;
+ plan.total = plan.advance + time.step + time.rest;
+ c.step(s, to, plan, plan.total);
+}
+
+/// In a crossing, when the kernel's write of the byte at `addr` lands in
+/// the program's memory (seconds into the step): what a read fills strikes
+/// there as the kernel's work does it, before it returns. Null for any other byte.
+pub fn filledAt(now: cursors.Now, addr: u64) ?f32 {
+ if (!now.crossings) return null;
+ const made = inStep(now) orelse return null;
+ const span = fills(made) orelse return null;
+ if (addr < span.addr or addr >= span.addr + span.len) return null;
+ return Plan.in(now, made).filled(addr - span.addr);
}
/// How long after its slot in the cascade a register this step changed
@@ -107,10 +177,16 @@ pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
pub fn crossingDelay(now: cursors.Now) f32 {
if (!now.crossings) return 0;
const made = inStep(now) orelse return 0;
- const p = Plan.of(made);
+ const p = Plan.in(now, made);
return p.struck - p.registers;
}
+/// Whether the instruction at moment `i` is a call: a step from it that
+/// crosses into the kernel went over libc's wrapper.
+fn fromCall(rec: *const Recording, i: u64) bool {
+ return if (i < rec.insn_branches.len) if (rec.insn_branches[i]) |b| b.kind == .call else false else false;
+}
+
/// The argument registers of a syscall, in order.
const carriers = [_][]const u8{ "rdi", "rsi", "rdx", "r10", "r8", "r9" };
@@ -190,7 +266,7 @@ pub const Crossing = struct {
// A crossing's own row comes in once it is back (rax struck), 12 f.
var arrives: f32 = 1;
if (newest) |n| if (inStep(now) != null and now.walking()) {
- const p = Plan.of(rec.syscalls[n]);
+ 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);
};
if (newest) |n| if (n < first) {
@@ -208,7 +284,9 @@ pub const Crossing = struct {
const v = if (i == n) u.faded(arrives) else u;
const y = top + @as(f32, @floatFromInt(j)) * 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);
}
}
@@ -257,39 +335,61 @@ pub const Crossing = struct {
}
}
- /// Its view: the bytes the newest call is given or fills (its path, a
- /// buffer), as a dump over the state column; struck as the kernel
- /// fills them.
+ /// Its view: the bytes the call crossing in this step is given or
+ /// fills (its path, a buffer), as a dump over the state column. They
+ /// come in with the argument framing (the note before them out 12 f,
+ /// they in 12 f); what a read fills lands a byte every 2 f with the
+ /// kernel's work, struck; a write's buffer is framed as read while the
+ /// kernel takes it; and they clear with the log's new row. Between
+ /// crossings the view is clear.
fn bytesView(c: *const Crossing, f: *sk.Frame, placed: anim.Placed) void {
- const rec = c.cursor.rec;
const now = c.cursor.now(placed);
- var newest = latest(rec, now.stops[0]);
- // No effect before its cause: until the kernel has taken the call, the last one's bytes.
- if (newest) |n| if (inStep(now) != null and now.walking() and now.time < Plan.of(rec.syscalls[n]).name) {
- newest = if (n > 0) n - 1 else null;
- };
- const made: ?Recording.Syscall = if (newest) |n| rec.syscalls[n] else null;
+ const made: ?Recording.Syscall = if (now.walking()) inStep(now) else null;
+ const tm = now.time;
+ const quick = theme.time.quick;
+ // The call's bytes, and the note that says there is none crossing.
+ var shows: f32 = 0;
+ var clear: f32 = 1;
+ if (made) |given| {
+ const p = Plan.in(now, given);
+ const out = std.math.clamp((tm - p.struck - 6.0 / 60.0) / quick, 0, 1);
+ shows = std.math.clamp((tm - p.registers - quick) / quick, 0, 1) * (1 - out);
+ clear = @max(1 - std.math.clamp((tm - p.registers) / quick, 0, 1), std.math.clamp((tm - p.struck - 6.0 / 60.0 - quick) / quick, 0, 1));
+ }
const path_at: ?usize = if (made) |given| std.mem.indexOfScalar(u8, zt.syscalls.signature(given.nr), 's') else null;
const span: ?Recording.Span = if (made) |given| bufferRead(given) orelse fills(given) orelse if (given.text.len > 0 and path_at != null) .{ .addr = given.args[path_at.?], .len = given.text.len + 1 } else null else null;
- const scratch = context.at(f, placed, c.stage.box(placed, .view));
- const about = if (span) |sp| scratch.print("the {s}, {x} to {x}", .{ if (bufferRead(made.?) != null) "buffer given" else if (fills(made.?) != null) "buffer filled" else "path given", sp.addr, sp.addr + sp.len - 1 }) else "the call names no bytes";
- const v = hexdump.panel(f, placed, c.stage, about, &.{});
+ if (span) |sp| @import("map.zig").measure(.view, (sp.len + 15) / 16);
+ const v = hexdump.panel(f, placed, c.stage, "", &.{});
defer v.u.unclip();
+ const note_x = 28 + v.u.width(.sans_medium, theme.size.sans.tag, "its bytes") + 12;
+ const note_y = theme.metric.context.tag - 6;
+ if (clear > 0) v.u.faded(clear).text(.sans, theme.size.sans.micro, note_x, note_y, "no call crossing now", theme.color.text.faint);
+ if (shows <= 0) return;
+ const given = made.?;
+ const about = if (span) |sp| v.u.print("the {s}, {x} to {x}", .{ if (bufferRead(given) != null) "buffer given" else if (fills(given) != null) "buffer it fills" else "path given", sp.addr, sp.addr + sp.len - 1 }) else "the call names no bytes";
+ v.u.faded(shows).text(.sans, theme.size.sans.micro, note_x, note_y, about, theme.color.text.faint);
const sp = span orelse return;
if (v.rows == 0) return;
// The bytes it names are the field the view is about: a path or a
// buffer of text reads as text, anything else is left to the eye.
- const given = made.?;
- const text = given.text[0..@min(given.text.len, sp.len)];
+ const p = Plan.in(now, given);
+ // What a read fills is what the program's memory holds after it.
+ var text = given.text[0..@min(given.text.len, sp.len)];
+ if (fills(given) != null) {
+ const after = v.u.f.scratch.alloc(u8, sp.len) catch return;
+ now.moment().read(sp.addr, after, null) catch return;
+ text = after;
+ }
const printable = for (text) |byte| {
if (!std.ascii.isPrint(byte) and byte != '\n' and byte != '\t' and byte != 0) break false;
} else true;
- hexdump.fielded(v, now, theme.metric.context.tag + theme.metric.context.pad, .{
+ hexdump.fielded(.{ .u = v.u.faded(shows), .rows = v.rows, .box = v.box }, now, theme.metric.context.tag + theme.metric.context.pad, .{
.base = sp.addr,
.len = sp.len,
.fields = &.{.{ .at = 0, .len = sp.len, .reads = if (printable) .text else .bytes }},
.region = context.ink(context.regionOf(now.moment(), sp.addr)),
- .given = .{ .addr = sp.addr, .bytes = text, .shows = 1 },
+ .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,
});
v.veil(now);
}
@@ -355,14 +455,18 @@ pub const Timeline = struct {
};
test "a crossing is as long as what the call does" {
- // A call with no work: 3.9 s. Fifteen bytes copied up: 5.0.
- try std.testing.expectApproxEqAbs(@as(f32, 3.90), Plan.of(.{ .nr = 3, .args = @splat(0), .enter = 0 }).total, 1e-3);
+ // A call with no bytes to move: `returns` at 108 f, then the full climb; 3.8 s. Fifteen bytes filled: 5.0.
+ const close = Plan.of(.{ .nr = 3, .args = @splat(0), .enter = 0 });
+ try std.testing.expectApproxEqAbs(@as(f32, 108.0 / 60.0), close.returns, 1e-3);
+ try std.testing.expectApproxEqAbs(@as(f32, 3.80), close.total, 1e-3);
const read = Plan.of(.{ .nr = 0, .args = .{ 3, 0x1000, 32, 0, 0, 0 }, .enter = 0, .exit = 0, .result = 15 });
- try std.testing.expectApproxEqAbs(@as(f32, 4.97), read.total, 1e-2);
- // What came back is in the kernel's rows before the arrow back leaves,
+ try std.testing.expectApproxEqAbs(@as(f32, 5.0), read.total, 1e-2);
+ // What came back is in the kernel's rows before the answer climbs (24 f),
// struck in rax as it lands (armed on its way), then stored.
try std.testing.expect(read.returns < read.back and read.struck == read.back + Plan.cross and read.struck - time.strike.arm > read.back and read.stored > read.struck);
- // Nothing on the kernel's side before the arrow is through the line.
+ // Nothing on the kernel's side before the lane is through; the last byte filled before `returns`.
try std.testing.expect(read.leaves >= read.enters and read.name >= read.enters + Plan.cross);
- try std.testing.expect(read.fills > read.name and read.returns > read.fills + 15 * Plan.byte);
+ try std.testing.expect(read.fills > read.name and read.returns > read.filled(14));
+ // Stepped over: the chart from its frame 18.
+ try std.testing.expectApproxEqAbs(read.enters - time.cascade, read.shifted(-time.cascade).enters, 1e-4);
}
diff --git a/anim/src/theme.zig b/anim/src/theme.zig
index 0c646d8..78c1d7d 100644
--- a/anim/src/theme.zig
+++ b/anim/src/theme.zig
@@ -109,6 +109,8 @@ pub const layout = struct {
backtrace: Rect,
/// `bytes` rows of the lens's dump.
dump_rows: u32,
+ /// On the map: the rest of a column, where the stack goes on (`continued`).
+ more: Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
};
pub const split = struct {
/// The machine alone: fourteen lines over seventeen instructions;
@@ -657,6 +659,8 @@ pub const metric = struct {
pub const hang = 92;
pub const shadow = [2][2]f32{ .{ 12, 16 }, .{ 20, 26 } };
pub const stem = 4;
+ /// One hung from the band's view: its stem down the gutter's right lane, this far left of the state column.
+ pub const lane = 14;
};
/// A lens's lanes: projections 4 under its tag, links 8 above its bottom edge.
@@ -964,6 +968,9 @@ pub const time = struct {
pub const run_max_steps = 24;
/// What moves at a run (the mark, a card, an arrow) takes this long.
pub const run_ease = 8.0 / 60.0;
+ /// The minimap follows the frame this far behind: secondary action, it
+ /// never starts on a primary onset's frame.
+ pub const minimap_lag = 6.0 / 60.0;
/// A hurried step with this long or more is still a whole sentence,
/// said faster; with less, it is a run.
pub const walk_least = 0.70;
diff --git a/anim/src/ui.zig b/anim/src/ui.zig
index cf12914..d770e05 100644
--- a/anim/src/ui.zig
+++ b/anim/src/ui.zig
@@ -247,6 +247,13 @@ pub const Ui = struct {
return u.panelChrome(w, h, title, options.focus, options.note, options.legend);
}
+ /// A tag's `note`, ranged right, drawn apart from its panel: for one
+ /// that crossfades with another.
+ pub fn tagNote(u: Ui, w: f32, note: []const u8) void {
+ const micro = theme.size.sans.micro;
+ u.text(.sans, micro, w - 10 - u.width(.sans, micro, note), theme.metric.context.tag - 6, note, theme.color.text.faint);
+ }
+
fn panelChrome(u: Ui, w: f32, h: f32, title: []const u8, focus: bool, note: []const u8, legend: []const Legend) Rect {
const options = .{ .focus = focus, .note = note, .legend = legend };
const m = theme.metric.context;
diff --git a/anim/src/words.zig b/anim/src/words.zig
index 134b42f..280abbc 100644
--- a/anim/src/words.zig
+++ b/anim/src/words.zig
@@ -68,7 +68,10 @@ pub const Clock = struct {
const steps = if (now.of > 0) u.print("step {d} of {d}", .{ now.count, now.of }) else u.print("step {d}", .{now.count});
u.faded(now.hurried).text(.mono, size, count_x - u.width(.mono, size, steps) - 3 * ui.advance(size), base, steps, t.dim);
}
- if (k.map) |m| if (m.settled(at)) @import("map.zig").minimap(m, f, at);
+ if (k.map) |m| {
+ m.fallingOver(f, at);
+ @import("map.zig").minimap(m, f, at);
+ }
}
};
diff --git a/anim/test/gallery/atoms.png b/anim/test/gallery/atoms.png
index 796c202..e18052b 100644
--- a/anim/test/gallery/atoms.png
+++ b/anim/test/gallery/atoms.png
Binary files differ
diff --git a/anim/test/gallery/loupe.png b/anim/test/gallery/loupe.png
index 750c6fd..8b63c1d 100644
--- a/anim/test/gallery/loupe.png
+++ b/anim/test/gallery/loupe.png
Binary files differ
diff --git a/anim/test/gallery/none.png b/anim/test/gallery/none.png
index 5fed856..b850f99 100644
--- a/anim/test/gallery/none.png
+++ b/anim/test/gallery/none.png
Binary files differ
diff --git a/anim/test/gallery/rest.png b/anim/test/gallery/rest.png
index abe30f0..f2869e4 100644
--- a/anim/test/gallery/rest.png
+++ b/anim/test/gallery/rest.png
Binary files differ
diff --git a/anim/test/gallery/rows.png b/anim/test/gallery/rows.png
index e32d4b4..de8580b 100644
--- a/anim/test/gallery/rows.png
+++ b/anim/test/gallery/rows.png
Binary files differ
diff --git a/anim/test/gallery/step.png b/anim/test/gallery/step.png
index ea3c6f1..8f80f5f 100644
--- a/anim/test/gallery/step.png
+++ b/anim/test/gallery/step.png
Binary files differ
diff --git a/anim/test/gallery/subject.png b/anim/test/gallery/subject.png
index 4524a25..b779060 100644
--- a/anim/test/gallery/subject.png
+++ b/anim/test/gallery/subject.png
Binary files differ
diff --git a/anim/test/recordings.zig b/anim/test/recordings.zig
index 3634ee9..38798af 100644
--- a/anim/test/recordings.zig
+++ b/anim/test/recordings.zig
@@ -90,12 +90,14 @@ test "a walked step is as long as what it changed: fire, a slot a level, the hol
var frame: anim.Frame = .{ .t = 0, .clock = 0, .in = undefined, .pointer = .{ 0, 0 }, .arena = arena.allocator() };
scene.frame(&frame);
const t = canim.theme.time;
- // main's line calls fib(5): registers, the stack, the call, 0.30 s
- // apart; the call's node when the projection from its way back arrives.
+ // main's line calls fib(5): its two registers (rdi, rsp) 6 f apart,
+ // the stack 0.30 s after the second, the call's node when the
+ // projection from its way back arrives.
const from = rec.lineMoment(10, rec.call("main", 0).enter);
const call = scene.at.reading(from, rec.next(.line, from));
- try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade), call.at[1], 1e-4);
- try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade + t.project.bracket + t.project.far), call.at[2], 1e-4);
+ const second: f32 = 6.0 / 60.0;
+ try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade + second), call.at[1], 1e-4);
+ try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade + second + t.project.bracket + t.project.far), call.at[2], 1e-4);
try expect(call.total > 2.0 and call.total < 3.5);
// A line that changes nothing shown: fire, advance, rest.
var quiet = scene.at;
diff --git a/anim/tools/chart.py b/anim/tools/chart.py
index 998e704..720e356 100644
--- a/anim/tools/chart.py
+++ b/anim/tools/chart.py
@@ -1,13 +1,19 @@
#!/usr/bin/env python3
"""The designer's motion instrument (design/motion/motion.py: timing chart,
-five rule checks, contact sheets), told where canim's panels are now.
+rule checks, contact sheets), told where canim's panels are now and what
+each scene's captions say.
chart.py chart|auto|sheet|onion|track VIDEO ... as motion.py takes them
-The video's file name (fib-1080.mp4 -> fib) picks its regions.
+The video's file name (fib-1080.mp4 -> fib) picks its regions, and its
+captions: the strings `scenes/NAME.zig` says (`says.line`), in order. The
+CAPTION check (motion.py's) gets one more line here: a caption up for less
+than its reading time, 90 f and 3.6 f a character as shown.
"""
-import os, sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "design", "motion"))
+import os, re, sys
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.join(HERE, "..", "..", "design", "motion"))
+import numpy as np
import motion
W = motion.W
@@ -33,11 +39,11 @@ def split(drawing, view, source, disasm, slots, backtrace=0):
out["backtrace"] = (976, right + ph(17) + 12 + ph(slots) + 12, 880, ph(backtrace))
return out
-# The clock is under the name the instrument gives to words that are not panels ("head"):
-# its progress line moves with every step and must not count as a panel starting. The
-# minimap (1664 to 1856 by 912 to 1020) is in no region: it mirrors the panels' changes,
-# and the instrument has no name for a secondary region.
-words = {"head": (0, 888, 1656, 46), "caption": (0, 934, 1656, 146)}
+# The words that are not panels (motion.WORDS): the clock (its count, ranged right at 1648,
+# changes in a frame by design), the caption (its 1400 from the margin), and the minimap at
+# the caption band's right end, secondary action. The caption's box starts under the clock's count
+# and the run's step counter (912 to 934).
+words = {"clock": (0, 888, 1656, 46), "caption": (0, 940, 1464, 140), "minimap": (1664, 912, 192, 108)}
none, beside, subject = split(0, 0, 14, 17, 8, 4), split(152, 152, 8, 17, 8), split(296, 200, 10, 9, 6)
motion.REGIONS.update({
"fib": {**subject, **words},
@@ -52,7 +58,54 @@ motion.REGIONS.update({
"gallery": {**beside, **words},
})
_regions_for = motion.regions_for
-motion.regions_for = lambda video, name: _regions_for(video, name or os.path.basename(video).split("-")[0].split(".")[0])
+scene = lambda video: os.path.basename(video).split("-")[0].split(".")[0]
+motion.regions_for = lambda video, name: _regions_for(video, name or scene(video))
+
+STRING = r'"((?:[^"\\]|\\.)*)"'
+
+def captions(name):
+ """The scene's captions in the order it says them: each `says.line(s, "...")`, and each
+ string of an array a `for` loop says."""
+ path = os.path.join(HERE, "..", "scenes", name + ".zig")
+ if not os.path.exists(path):
+ return None
+ src = open(path).read()
+ arrays = {m.group(1): re.findall(STRING, m.group(2), re.S) for m in re.finditer(r"const (\w+) = \[_\]\[\]const u8\{(.*?)\};", src, re.S)}
+ out = []
+ for m in re.finditer(r"says\.line\(s, " + STRING + r"\)|for \((\w+)\)", src):
+ if m.group(1) is not None:
+ out.append(m.group(1))
+ elif m.group(2) in arrays:
+ out.extend(arrays[m.group(2)])
+ return out
+
+def shown(text):
+ """Characters as the caption shows them: no backticks, no line break, an escape one."""
+ text = re.sub(r"\\(.)", r"\1", text.replace("\\n", ""))
+ return len(text.replace("`", ""))
+
+_lint = motion.lint
+def lint(names, counts, soft, sizes, fps, ev):
+ out = [line for line in _lint(names, counts, soft, sizes, fps, ev) if line != " none"]
+ said = captions(lint.scene) if lint.scene else None
+ cap = names.index("caption") if "caption" in names else None
+ if said is not None and cap is not None:
+ on = motion.busy(counts, soft)
+ changes = [(a, b) for a, b in motion.runs(on[:, cap]) if b - a >= 3]
+ ends = [c[0] for c in changes[1:]] + [len(on)]
+ # An arrival is a change after which the caption is up longer than the gap between leaving and arriving.
+ arrivals = [(b, nxt - b - 1) for (a, b), nxt in zip(changes, ends) if nxt - b - 1 > 6]
+ if len(arrivals) != len(said):
+ out.append(f" CAPTION ? {len(arrivals)} captions arrive in the video, the scene says {len(said)}: reading times not checked")
+ else:
+ short = [f"{b / fps:.2f} ({up} f of {90 + 3.6 * shown(t):.0f})" for (b, up), t in zip(arrivals, said) if up < 90 + 3.6 * shown(t)]
+ if short:
+ out.append(f" CAPTION {len(short):3d} up under its reading time, 90 f + 3.6 f a character: " + ", ".join(short[:4]) + (" ..." if len(short) > 4 else ""))
+ return out or [" none"]
+motion.lint = lint
+lint.scene = None
if __name__ == "__main__":
+ video = next((a for a in sys.argv[2:] if a.endswith(".mp4")), None)
+ lint.scene = scene(video) if video else None
motion.main() if hasattr(motion, "main") else sys.exit("design/motion/motion.py has no main()")