diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-12 03:17:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 04:45:57 -0300 |
| commit | ebdebe04a76f0302aeb24c1ac08fa9217b1a8257 (patch) | |
| tree | 81a915bc8cc2b6c63dbe765e9ee196a9e7c6d22f /anim | |
| parent | bf0dfa135319f8c7ca49eace4d1f81152ebfd23e (diff) | |
| download | computeranim-ebdebe04a76f0302aeb24c1ac08fa9217b1a8257.tar.gz computeranim-ebdebe04a76f0302aeb24c1ac08fa9217b1a8257.zip | |
canim: the ASan pair finished; a run's crossfade lasts its step
The ASan run is recorded --until __asan_report_store1 and the scene
finds its moments by what they are, not by count. The pair's tags name
their run, ASan's stopped call reads never returned, and both
disassemblies start level on their line. At a run a row's crossfade now
lasts the whole advance and a chain crossfades when its memory changed:
the pair's fast pass had thirteen one-frame changes and has none. Stale
videos re-exported.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim')
| -rw-r--r-- | anim/README.md | 126 | ||||
| -rw-r--r-- | anim/build.zig | 6 | ||||
| -rw-r--r-- | anim/scenes/asan.zig | 28 | ||||
| -rw-r--r-- | anim/src/context.zig | 7 | ||||
| -rw-r--r-- | anim/src/cursor.zig | 21 | ||||
| -rw-r--r-- | anim/src/disasm.zig | 93 | ||||
| -rw-r--r-- | anim/test/recordings.zig | 5 |
7 files changed, 201 insertions, 85 deletions
diff --git a/anim/README.md b/anim/README.md index 14e39cf..7f963fe 100644 --- a/anim/README.md +++ b/anim/README.md @@ -199,7 +199,7 @@ every state the code has in the `gallery` scene. | | `byte` | `src/rows.zig` `bytes` | `number`, `pointer`, `text` (a string's ink), `loose` (a byte of no field: the allocator's, padding, past what a dump is of), `unread`; `pad`; `bytesAt` moves the bytes right of a long (stack) address, by the dump's widest; a write's arm, strike and held corner cover the bytes whose value changed, first to last (`Run.changed`, `Now.changedBytes`), struck a byte a frame from the low address (what a read fills, 2 f apart); until its strike lands (s+3) a run keeps its old bytes and their reading, through the arm, read by its old field where the step retypes it (`hexdump.keepOld`, `Fields.was`) | | 2 row | `chain`, `reg` (and `rip` with the flags), `slot`, `line`, `bytes`, `call` (`span`, `callRow`) | `src/rows.zig` | `chain` follows `zt.telescope.chase`; cut at its far end, `more`; a register's reads memory as the panels show it, the step's bytes from their strike (s+3): its later hops fade out from the strike and are followed again 4 f after the bytes land (`Now.following`, `Marks.hops`). `slot`: pins from 16, the offset ranged right to 172 (under `tied` from the frame's base, the call frame information's CFA register: `context.frameBase`; under `whole` from rsp; a `free` word's crossfading), the address at 184, the chain, its role ranged right where the room ends (48 sooner in a pane: its strip), 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`; `i, n` where locals share a word (`Slot.also`); the stack protector's copy `canary`; nothing for a return address or `.none`). `bytes`: the bracket at 24, the address at 34, the bytes 12 after it and at 132 at least | | | `arc` | `src/rows.zig` (`Arcs`), `src/hexdump.zig` (`pointerArcs`) | a pointer to a row of its own panel: lanes at 4, 10, 16 in a dump or a loupe, 4 and 10 on the stack; longest outermost, a chain in one lane; standing at 60% toward the page, full in the step that writes or reads it and always in a loupe; rewritten: the old dashed with the arm, fading from 6 f after the strike as the new draws (12 f), quieting with the cool; a lane change glides while the arc that causes it draws or fades (`Arcs.assign`, with and without the arcs on their way); a stub to the rule for a target in the region past the window, only in its step; a saved rbp's only in its step, going with its advance (18 f); a dump withholds the arcs an open loupe carries | -| | `insn` | `src/disasm.zig` | columns at 2, 31, 40, 134, 180, 264, 564 (540 in a pane, whose strip takes 48 of the row; `map.content`); 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`). The annotation's form is the scene's knob (`Levels.annotation`, above): under `tied` a word the stack shows by its role and one hop (`tiedWord`; a local's name, the one of a shared word that holds the bytes accessed; an unnamed word, a spill, by its address and one hop; a store's value cut with `…`, never dropped), a heap word with a view on screen by its address and one hop, a word no pane shows its whole chain with its data name in place of the address (`head → 407050 ← 9`); a register set its first value; a move of rsp or rbp first (`stackMove`: `rsp -8 · saved rbp`, the role from the push's own stop, `rsp -0x20 4 words`, `rbp = rsp`, `leave`'s, `fib(4) · rsp -8`, `→ 4011ad main+45 · rsp +8`), the amount struck as rsp's pin lands; the row publishes where the touch leaves it (`ties.touch_row`); under `whole` the row as before. What the step leaves on its own row (`lea`'s `=`, a register's first value, a compare's flags, the canary's word, `rbp = rsp`'s value) fades in from its strike (12 f; at a run the run's ease); a row the advance changes (its state, its trail, its line number) is drawn as before and as after the advance and crossfades over its middle | +| | `insn` | `src/disasm.zig` | columns at 2, 31, 40, 134, 180, 264, 564 (540 in a pane, whose strip takes 48 of the row; `map.content`); 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`). The annotation's form is the scene's knob (`Levels.annotation`, above): under `tied` a word the stack shows by its role and one hop (`tiedWord`; a local's name, the one of a shared word that holds the bytes accessed; an unnamed word, a spill, by its address and one hop; a store's value cut with `…`, never dropped), a heap word with a view on screen by its address and one hop, a word no pane shows its whole chain with its data name in place of the address (`head → 407050 ← 9`); a register set its first value; a move of rsp or rbp first (`stackMove`: `rsp -8 · saved rbp`, the role from the push's own stop, `rsp -0x20 4 words`, `rbp = rsp`, `leave`'s, `fib(4) · rsp -8`, `→ 4011ad main+45 · rsp +8`), the amount struck as rsp's pin lands; the row publishes where the touch leaves it (`ties.touch_row`); under `whole` the row as before. What the step leaves on its own row (`lea`'s `=`, a register's first value, a compare's flags, the canary's word, `rbp = rsp`'s value) fades in from its strike (12 f; at a run the run's ease); a row the advance changes (its state, its trail, its line number, the moment its annotation reads: the pc's row back on itself, a loop's turn at a run) is drawn as before and as after the advance and crossfades over its middle, at a run over the whole advance (8 f, the run's ease). A `pair`'s (`Disasm.run`, `.aligned`, `.stopped`): its run's name on the tag (`plain · fill`); the pc's line's first row at the window's top while the pc is in its upper half; a stopped run's call `4e8450 __asan_report_store1 never returned`, its plaque gone, the tag `· stopped` | | | `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 · open64.c` (the file of its function's entry, where the build has the source), `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 a change of the panel's height at rest the rows both heights' layouts have, `Stage.resizing`; a row's shared digits are of its own window's rows that show) 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` where the pc is in code without source (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); where the build has the library's source the panel goes on with the pc into it. Its strip is the deepest window's function's linear column (a `Disasm` drawn for the strip alone, `Map.In.strips`), that window framed on it; going down or up it fades through as the mark lands (`map.through`) | | 3 panel | `registers`, `stack`, `backtrace` | `src/context.zig` | the registers `quiet` (`Registers.moves`, `movedBy`, `registerRows`): the scene's set chosen once, from its clock's way (`Cursor.journey`: the registers any of its steps of that kind changes, net, with rsp, rbp and rip), each a row with its chain; the rest folded three to a row on a pitch of 285 under a 2-unit rule, in pwndbg's order (`rows.quiet`: the name faint at 12, the value at 60, a pointer cut to `more` at once, a code address alone; framed as read while it carries a system call), rip last; the panel as tall as its rows and the stack the rest (`layout.fit`); in a `dive` it arrives whole from the map and folds as it lands (`Zoom.fold`: each quiet row gliding into its cell, the chain past its first hop gone over the first 40% of the move, a rule fading in); rip's value crossfading over the advance, a flag set or cleared over the 6 f it lands in (`rows.RipWas`); the backtrace newest at the bottom, `#0` last, the oldest dropped from the top (`newest at the bottom · 2 more above`), as a panel, the calls lens's view, the backtrace lens and on the map, all one block (`backtraceRows`: frames leave, slide and arrive; what a kept row says that changes, its depth, its pc's offset, its line, and the tag's count, crossfades, 12 f before the advance); the stack's window on `[rsp, rbp+16)` keeping the touched word in view, its tag the first and last word shown (`rsp+20 to rsp+48`), a word's role and offset, and the tag, crossfading (12 f from memory's strike) where the step changes them, rsp and rbp's pins travelling 18 f after rsp's strike (`time.pin`, keeping their place among the names they leave and join), at rest only where the register points; a window that moves farther than its own height (six or eight slots) fades out and in round memory's strike (12 f each; at a run half its step each), and what it brings, and what changed before it, is plain; while rows slide they keep their roles (those of both windows are read), and a word becoming a saved rbp, or no longer one, has its arc go or come with its role; a frame's name longer than the spans' room shortens the chains beside it; `call` spans and the backtrace (`#n`, name, arguments at 384, file and line) from `zt.telescope.frames`, the frames two stops share sliding to their new depth; the backtrace as a lens's drawing with `Context.Options.backtrace`. Under `tied` the window has two `free` words of headroom over rsp (a leaf's locals under rsp are the frame's), the tag says the base (`· offsets from rbp`, crossfading as it changes), and when rsp or rbp moves the rows hold while the pin travels (`Plan.pins`: the amount on it, `rsp -18`, counting row by row, a vermilion bracket over the rows crossed, each row gained or released as it passes, the newest frame's span riding it, the register struck as it lands; rbp's pin flies to rsp's, `pop rbp` moves rbp first), and only then the window follows (`Plan.follow`); under `whole` as before | | | `source` | `src/source.zig` | fourteen lines alone, eight with a lens, six with `blocks`; the file the pc is on a line of, of the recording's sources (`Recording.sources`, `shown`: the program's own, or a library's the build gave; else the last such line, a frame up, where the pc waits), whole in a window, its middle third; its lines cut at 63 characters in a pane (67 on the map); the trail's bars (of that file's lines) crossfading with the advance; numbers as wide as the widest file's largest line (SQLite's six digits), the text moved right by as much; another file: the panel fades through (12 f out, 12 f in), its tag's title and note crossfading with it, its strip with it (`map.through`); a window going farther than its own height in one file: the advance is 48 f, the window gliding on the strip for the first 24 (the gold lit on its new row there), then the pane out and in | @@ -281,7 +281,7 @@ before. The source panel follows the pc into any file it has | `sqlite` | `sqlite.c` (three rows into a table, committed) with SQLite 3.50.4's amalgamation, system clang `-O2 -g -fno-omit-frame-pointer -no-pie -fno-stack-protector -Wl,-z,now`, glibc | `--by break`: `sqlite3_step`, `sqlite3BtreeInsert`, `unixWrite`, and the instruction after its `pwrite64` (found by objdump); every syscall recorded, `-s 4096` | 181 (42 stops, 138 syscalls), 494 KB | made only with `-Dsqlite=DIR` (default `~/05-genizah/sqlite/sqlite-amalgamation-3500400`), in a new temporary directory each time; `sqlite3.c` is embedded as the source | | `intro` | `list.c` again, as `list` is built | every instruction, `--from list.c:41` (main's call of reverse), `--until list.c:22` (past the load); run as `./list` | 588 (70 of them the loader's and the agent's syscalls before main), 187 KB | as `list`: `--alloc --preload`, `--ring` | | `overflow` | `overflow.c` (design/mock/overflow.c: a loop writing 32 bytes into `char buf[16]`), the system's clang `-O0 -g -fno-omit-frame-pointer -no-pie -fno-stack-protector`, glibc | every instruction, `--from main`, to the fault | 298, 60 KB | the recorder says `exit 139`; the SIGSEGV on the moment after `ret`, rip unchanged | -| `overflow_asan` | the same with `-fsanitize=address`, `ASAN_OPTIONS=detect_leaks=0` | every instruction, `--from main`, `--steps 582` (to `__asan_report_store1`'s first instruction) | 785, 257 KB | `--asan` (the shadow); the fake frame's header parsed by the scene from memory | +| `overflow_asan` | the same with `-fsanitize=address`, `ASAN_OPTIONS=detect_leaks=0` | every instruction, `--from main`, `--until __asan_report_store1` (its first stop there: past its `endbr64; push rbp; mov rbp, rsp`, as `-b` places a function's breakpoint) | 788, 257 KB | `--asan` (the shadow); the fake frame's header parsed by the scene from memory; the scene finds its moments by what the instructions are (the parting turn's load, `je`, the partial check's `cmp` and branch, the call), none by a count | | `overflow_report` | the same run | `--by syscall --stack 0 --telescope 0 -s 4096` | 707, 401 KB | the report: its `write(2, …)`s, shown from their capture; `exit 1` | What builds each program: `fib.c` (`steps`) and `hello.c` for `musl`, @@ -354,22 +354,22 @@ list's dive (150 to 300 f) as a caption's change. | | fib | list | sort | syscalls | musl | zoom | sqlite | heap | gallery | title | column | column_sort | asan | intro_memory | intro_stack | intro_code | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| POP, before / after | 10 / 3 | 13 / 10 | 3 / 4 | 21 / 14 | 16 / 7 | 5 / 2 | 7 / 6 | 17 / 15 | 9 / 9 | 0 / 0 | 9 / 4 | 6 / 6 | – / 29 | – / 1 | – / 0 | – / 0 | -| of them the strips', before / after | 1 / 1 | 4 / 4 | 2 / 3 | 8 / 9 | 1 / 1 | 2 / 1 | 0 / 0 | 6 / 5 | 3 / 3 | 0 / 0 | 4 / 2 | 3 / 3 | – / 0 | – | – | – | -| POP exempt, before / after | | – / keyframe 1 | | | | | | | cut 5 / cut 5 | | | | | | | | -| CROWD, before / after | 3 / 3 | 8 / 7 | 6 / 8 | 4 / 4 | 8 / 6 | 4 / 3 | 2 / 2 | 18 / 17 | 6 / 5 | 0 / 0 | 0 / 0 | 0 / 0 | – / 15 | – / 0 | – / 0 | – / 0 | -| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | – / 0 | – / 0 | – / 0 | – / 0 | -| CAPTION up over 720 f, before / after | 1 / 0 | 2 / 0 | 1 / 0 | 0 / 0 | 0 / 0 | 1 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | 0 / 0 | 1 / 1 | – / 1 | – / 1 | – / 0 | – / 0 | +| POP, before / after | 3 / 3 | 10 / 10 | 4 / 4 | 14 / 13 | 7 / 7 | 2 / 2 | 6 / 6 | 15 / 15 | 9 / 9 | 0 / 0 | 4 / 4 | 6 / 6 | 29 / 16 | 1 / 1 | 0 / 0 | 0 / 0 | +| of them the strips', before / after | 1 / 1 | 4 / 4 | 3 / 3 | 9 / 9 | 1 / 1 | 1 / 1 | 0 / 0 | 5 / 4 | 3 / 3 | 0 / 0 | 2 / 2 | 3 / 3 | 0 / 0 | – | – | – | +| POP exempt, before / after | | keyframe 1 / keyframe 1 | | | | | | | cut 5 / cut 5 | | | | | | | | +| CROWD, before / after | 3 / 3 | 7 / 7 | 8 / 8 | 4 / 4 | 6 / 6 | 3 / 3 | 2 / 2 | 17 / 16 | 5 / 5 | 0 / 0 | 0 / 0 | 0 / 0 | 15 / 15 | 0 / 0 | 0 / 0 | 0 / 0 | +| METRONOME, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | +| CAPTION up over 720 f, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | 0 / 0 | 1 / 1 | 1 / 1 | 1 / 1 | 0 / 0 | 0 / 0 | | CAPTION under its reading time, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | | not checked | not checked | not checked | not checked | not checked | not checked | -| CAPTION picture moving within 60 f, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | not checked | 1 / 1 | not checked | – / 1 | – / 0 | – / 1 | -| AIR, before / after | 0 / 0 | 0 / 0 | 1 / 1 | 0 / 0 | 0 / 0 | 1 / 1 | 1 / 1 | 0 / 0 | 1 / 1 | 1 / 1 | 1 / 0 | 0 / 0 | – / 1 | – / 0 | – / 1 | – / 1 | -| seconds, before / after | 50.2 / 48.2 | 88.0 / 83.9 | 72.9 / 74.5 | 85.4 / 85.4 | 77.5 / 66.8 | 38.0 / 34.9 | 62.9 / 62.9 | 80.2 / 80.2 | 27.0 / 27.0 | 12.3 / 12.3 | 104.8 / 95.3 | 30.6 / 29.5 | – / 120.0 | – / 67.2 | – / 31.8 | – / 40.8 | +| CAPTION picture moving within 60 f, before / after | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | 0 / 0 | | not checked | 1 / 1 | not checked | 1 / 1 | 0 / 0 | 1 / 1 | +| AIR, before / after | 0 / 0 | 0 / 0 | 1 / 1 | 0 / 0 | 0 / 0 | 1 / 1 | 1 / 1 | 0 / 0 | 1 / 1 | 1 / 1 | 0 / 0 | 0 / 0 | 1 / 1 | 0 / 0 | 1 / 1 | 1 / 1 | +| seconds, before / after | 48.2 / 48.2 | 83.9 / 83.9 | 74.5 / 74.5 | 85.4 / 85.4 | 66.8 / 66.8 | 34.9 / 34.9 | 62.9 / 62.9 | 80.2 / 80.2 | 27.0 / 27.0 | 12.3 / 12.3 | 95.3 / 95.3 | 29.5 / 29.5 | 120.0 / 120.0 | 67.2 / 67.2 | 31.8 / 31.8 | 40.8 / 40.8 | -"Before" is the last pass's "after" (its gallery and title were the pass -before's: this pass exports every scene again). `asan` is new; the -introduction's three scenes (`intro_memory`, `intro_stack`, `intro_code`) -are this pass's, exported alone (the other scenes' columns are the last -pass's). The column's, column_sort's and asan's "caption" regions are not a +"Before" is the last pass's "after". This pass exported again (at 1080, +and at 2160 where a scene has one) asan, fib, zoom, syscalls, the column, +musl, list, sort, heap, the gallery and the title; sqlite, column_sort and +the introduction's three (`intro_memory`, `intro_stack`, `intro_code`) +were not, and their cells repeat the last pass's. The column's, column_sort's and asan's "caption" regions are not a caption's (the text column, a drawing's band), so their CAPTION lines are not a caption's; the column's own check is the renderer's (`column: bubble N is still read …`): C2's bubble (74 characters) 1.8 s past its three steps. @@ -384,14 +384,48 @@ by frame: it comes in over the 6 f; the instrument counts 75 pixels, then 36). The two AIRs are the chapters' last pictures, II4's and III5's texts read and the 2 s before the cut. -This pass (the introduction) changed, outside its three scenes: a pin +This pass changed: + +- The ASan run is recorded `--until __asan_report_store1` (no count), and + the scene finds its moments by what the instructions are; the pair's + disassemblies name their run, ASan's stopped call reads `never + returned`, and the two are aligned by line (`Disasm.run`, `.stopped`, + `.aligned`; "What is not done", the ASan pair). +- A run's crossfade, at its blocks: a disassembly row the advance changes + crossfades over the whole advance at a run (8 f, the run's ease, as a + dump's values; it was the advance's middle, 4 f), and the pc's row too + where the moment its annotation reads changes (a loop's turn coming back + to its row at a run changed it in the advance's middle frame: + `disasm.zig`); a register's chain crossfades with its value at a run + where what it reads changed under the same value (`context.zig`, + `cursor.chainMoved`: ASan's rbx `→ 7bfff58f0020` at A6's first turn). + asan's A6 had 13 of its 29 POPs (36.57 to 41.08, 12 to 108 pixels): + none now. list's 50.22 (the disassembly, 18 pixels) is gone. +- What else moved in the counts is not this pass's code: syscalls' 67.30 + (90 pixels, looked at frame by frame) is a free word over rsp taking the + next call's return address (`4011ad` to `4011c5`) in one frame, as it did + before; the steps round it no longer move there, since the `hello` + recording the build makes now (today's tracer) has 0 in `n`'s high half + where the last export had `0xf00000000`, and its 4.07 and 49.80 are gone. + list's new 50.25 (caption, 13 pixels) is the encoder: the rendered frames + 3014 to 3017 are identical in the caption band. heap's 23.77 (drawing, 14 + pixels) is the same change at the same frames as the last export's, now + after 12 still frames at the instrument's size; its 37.17 is gone. +- `mov rbp, rsp`, looked at in consecutive frames: in zoom (its own step, at + a run, 20.0 s) rbp's pin rises to rsp's row, rsp makes room, rbp's head + fades as it lands (f1200 to f1212), and at `sub rsp` rsp leaves and rbp's + head comes back (f1229 to f1242), every frame a part of the move; in fib + it is inside a step by line, so rbp lands on the saved rbp's row, not + rsp's (f586 to f623, smooth). fib's and zoom's counts are unchanged. + +The pass before (the introduction) changed, outside its three scenes: a pin joining another's row in front of its names (`mov rbp, rsp`: rbp onto rsp) lets its own head go as it lands, not in the advance's frame (`Stack`); the pc's triangle on `aligned`'s plaque is drawn where it is (it was transformed twice, off the stage); `segments` leaves the tracer's own mappings out, inks an edge by the band that starts there and cuts a long file name; the -build records `intro` (`Recording.until`, `.program`). The last pass -changed, a kind of one-frame change at a time, each at its block (the +build records `intro` (`Recording.until`, `.program`). The pass before +that changed, a kind of one-frame change at a time, each at its block (the catalogue's rule: nothing changes in one frame): - An instruction's in-step annotation (`lea`'s `= 402004 ← "note"`, a @@ -452,24 +486,26 @@ cheap; the tables' gain is the map's size and the frame owning them. What fires still (the finals; located where it says so): -- asan, 29: A6's run, 14 in ASan's disassembly (12 to 29 pixels, 0.3 s - apart: the advance's crossfade at a run is 4 f, small text); plain's - registers' chain string growing at each store of A15 (80 pixels, every - 0.8 s, its rbp and rsp hops reading the letters); 100 pixels at 66.6 s in - plain's disassembly (into the column); the rest single. Its CAPTION over +- asan, 16: plain's registers' chain string growing at each store of A15 + (80 pixels, every 0.8 s, its rbp and rsp hops reading the letters) and + plain's disassembly at each (14 pixels, not looked at); 100 pixels at + 66.6 s in plain's disassembly (into the column), 702 at 83.68 (the + descent's main window going over); 16.68 the source (95), 47.58 and 60.15 + the disassemblies (14, 38), not looked at. Its CAPTION over 720 f is the column part (no caption band there), its AIR the poster's held rest (meant). -- syscalls 14, 9 of them in the strips: six the disassembly's strip region +- syscalls 13, 9 of them in the strips: six the disassembly's strip region crossed by a touch's head (12 to 15 pixels, looked at: the touch leaving the row's rule over the strip), three the stack's and the source's strips - (38 pixels, not looked at); 4.07, 59.48, 81.70 the stack (23 to 25 pixels, - not looked at); 44.88 and 49.80 registers (12, 19, not looked at). The - read's first byte landing in one frame (65.85) is gone. + (38 pixels, not looked at); 67.30 the stack (90 pixels, looked at: a free + word over rsp, which takes no place, given the next call's return address + in one frame, above); 59.48, 81.70 the stack (24, 25 pixels, not looked + at); 44.88 registers (12, not looked at). - column 4: 28.53 the source's strip as the pane shrinks to two lines at rest (its strip is drawn at the pane's height, not lagged: looked at); 52.92 and 82.77 the shelf (106 pixels, not looked at); 60.98 a strip. - fib 3, list 10, musl 7, sort 4, zoom 2, sqlite 6, heap 15, column_sort 6: - list's 13.62, 42.52 and 71.55 the nodes (120 to 280 pixels: 71.55 a pin's + list's 50.25 the encoder (above); list's 13.62, 42.52 and 71.55 the nodes (120 to 280 pixels: 71.55 a pin's names, now crossfaded, the others not looked at); musl's 55.68 and 64.28 in the descent (112 pixels, not looked at); heap's drawing (88 to 197) and its stack strip (68 to 71) not looked at; zoom's 17.40 registers (12 @@ -503,22 +539,27 @@ What fires still (the finals; located where it says so): instrument still cannot pair the column's texts with what it sees (its "caption" region is the text column, where texts dim and glide). C2's bubble (74 characters) is flagged: 1.8 s past its three steps. -- The ASan pair (`asan`): `never returned` on ASan's stopped call is not - drawn (its row keeps the plaque and its call); the disassemblies' tags say - `fill`, not `plain · fill`; plain's registers read rbp's and rsp's chain as +- The ASan pair (`asan`): the disassemblies' tags name their run (`plain · + fill`, `asan · fill`; `Disasm.run`); ASan's stopped call reads `4e8450 + __asan_report_store1 never returned`, its plaque gone, the tag `asan · fill + · stopped` (`Disasm.stopped`, 12 f as its registers give way, mock 38); the + two disassemblies are aligned by line (`Disasm.aligned`: the pc's line's + first row at the window's top while the pc is in the window's upper half, + the window filled from above where the code ends under the pc), so the two + runs' rows of one line start level at a line's start (A3, A4); a line + longer than the window's upper half (ASan's line 4, thirty rows) scrolls + with its pc, as before. Plain's registers read rbp's and rsp's chain as a string of A's (the mock's `← 0x4141414141414141` is not `rows.chain`'s); - a field keeps one held corner (the newest write's), not one a byte; the two - disassemblies keep their own windows round their pcs, not aligned by line; + a field keeps one held corner (the newest write's), not one a byte; the clock says `i 27 · plain moment N · asan moment M`. In the column, plain's descent follows the frame chain, which the overwritten return address ends in `fill` from i = 24: main's window goes over 82.4 to 83 s, after the aim has glided to `fill+1`. The scene is 120 s against the storyboard's 112: - the two-line captions' reading times and the column's changes. A6's run - and A15's stores leave one-frame changes (above). The recorder cannot stop - a run by instruction at a function: ASan's is cut by a count (`--steps - 582`), which moves with the compiler; the fake frame's header is parsed by - the scene from memory, plain's fields from the instructions' rbp offsets, - and the two runs' stops are matched by pc. + the two-line captions' reading times and the column's changes. A15's + stores leave one-frame changes (above); the renderer says A12's bubble + (`column: bubble 3`) is read 1.5 s past its beat's steps. The fake frame's + header is parsed by the scene from memory, plain's fields from the + instructions' rbp offsets, and the two runs' stops are matched by pc. - The introduction (`intro_memory`, `intro_stack`, `intro_code`), exported: where it differs from its storyboard and mocks. The recording is `intro` (main's call of reverse to past the load), so the push II walks is @@ -706,8 +747,9 @@ What fires still (the finals; located where it says so): 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. -- At a run a dump's values, a register's and a stack word's crossfade - (8 f); a node's value in `nodes` and a cell's in `array` still change +- At a run a dump's values, a register's (and its chain, where what it + reads changed under the same value), a stack word's and a disassembly + row's annotation crossfade (8 f); a node's value in `nodes` and a cell's in `array` still change in a frame (the heap's drawing crossfades its own). - The gallery keeps the old recording of the list (`test/gallery/list.ztrace`): on the build's list (by instruction) its diff --git a/anim/build.zig b/anim/build.zig index 63d962e..7022caa 100644 --- a/anim/build.zig +++ b/anim/build.zig @@ -239,12 +239,12 @@ pub fn build(b: *std.Build) void { // no environment but ASan's leak check off (it fails under a tracer): // plain by instruction from main to its fault at `ret` (the recorder // says `exit 139`, SIGSEGV); ASan by instruction from main to the first - // instruction of `__asan_report_store1` (582 stops: the report itself is - // a million more), and the same run again by syscall alone, for the + // stop in `__asan_report_store1` (`--until`: the report itself is a + // million more), and the same run again by syscall alone, for the // report's `write`s to fd 2 as written. for ([_]struct { name: []const u8, asan: bool, args: []const []const u8, exit: []const u8 }{ .{ .name = "overflow", .asan = false, .args = &.{ "--by", "insn", "--stack", "1024", "--around", "256", "--disasm", "69", "-s", "64", "--from", "main" }, .exit = "exit 139" }, - .{ .name = "overflow_asan", .asan = true, .args = &.{ "--asan", "--by", "insn", "--stack", "1024", "--around", "256", "--disasm", "69", "-s", "64", "--from", "main", "--steps", "582" }, .exit = "exit 0" }, + .{ .name = "overflow_asan", .asan = true, .args = &.{ "--asan", "--by", "insn", "--stack", "1024", "--around", "256", "--disasm", "69", "-s", "64", "--from", "main", "--until", "__asan_report_store1" }, .exit = "exit 0" }, .{ .name = "overflow_report", .asan = true, .args = &.{ "--by", "syscall", "--stack", "0", "--telescope", "0", "-s", "4096" }, .exit = "exit 1" }, }) |r| { const cc = b.addSystemCommand(&.{ "clang", "-O0", "-g", "-fno-omit-frame-pointer", "-no-pie", "-fno-stack-protector" }); diff --git a/anim/scenes/asan.zig b/anim/scenes/asan.zig index 2fe743f..a68a40a 100644 --- a/anim/scenes/asan.zig +++ b/anim/scenes/asan.zig @@ -184,6 +184,7 @@ fn frame(s: *anim.Frame) void { const q_head = asan.register(on(asan, q_line4, "cmp dword ptr"), "rip"); var q_turn: [17]u64 = undefined; for (&q_turn, 0..) |*m, i| m.* = nth(asan, q_line4, q_head, i); + // The first moment from `from` whose instruction is at the shadow: a check's load, or the prologue's poisoning store. const q_load = struct { fn of(rec: *canim.Recording, from: u64) u64 { var buf: [256]u8 = undefined; @@ -192,7 +193,13 @@ fn frame(s: *anim.Frame) void { return rec.end(); } }.of; - const report_call = on(asan, q_load(asan, q_turn[16]), "call"); + // The parting turn's check, by what each instruction is: the load, its `je` (not taken), the partial check's + // compare and its branch, the call (the recording ends in it: `--until __asan_report_store1`). + const q_check16 = q_load(asan, q_turn[16]); + const q_je16 = on(asan, q_check16, "je"); + const q_partial = on(asan, q_je16 + 1, "cmp"); + const q_branch = on(asan, q_partial, "j"); + const report_call = on(asan, q_branch, "call"); // The frames: plain's from rbp at line 4 (`i` at rbp-0x14, `buf` at rbp-0x10, then the saved rbp and the // return address); ASan's fake frame, where `__asan_stack_malloc_0` put it, by its descriptor. @@ -229,11 +236,13 @@ fn frame(s: *anim.Frame) void { const framed = s.value(0); const source = canim.add(s, canim.Source{ .cursor = at, .stage = left, .tag = "both builds" }); - const dis_l = canim.add(s, canim.Disasm{ .cursor = at, .stage = left }); + // Each run's disassembly by its name, aligned by line; ASan's stopped on its report's call once its run stops (A9). + const dis_l = canim.add(s, canim.Disasm{ .cursor = at, .stage = left, .run = "plain", .aligned = true }); + const stopped_r = s.value(0); // In the column (A10 to A13) plain's disassembly is a descent: main's window, the row // its return address names among them, over fill's whole (motion.md, the column's panes). const desc_l = canim.add(s, canim.Descent{ .cursor = at, .stage = left }); - const dis_r = canim.add(s, canim.Disasm{ .cursor = as, .stage = right, .rows = 9 }); + const dis_r = canim.add(s, canim.Disasm{ .cursor = as, .stage = right, .rows = 9, .run = "asan", .aligned = true, .stopped = stopped_r }); const reg_moves = struct { fn of(names: []const []const u8) u32 { var mask: u32 = 0; @@ -361,7 +370,7 @@ fn frame(s: *anim.Frame) void { const made = s.cursor; s.play(.{fake_in.to(1)}, .{ .seconds = t.quick }); s.cursor = made; - runTo(s, as, q_line3 - 1, 5, &.{ 0.3, 0.36, 0.5 }); + runTo(s, as, q_load(asan, q_back), 5, &.{ 0.3, 0.36, 0.5 }); s.play(.{ as.veil.to(0), as.hurried.to(0) }, .{ .seconds = t.veil }); s.wait(t.beat); walk(s, as, q_line3, null); @@ -383,7 +392,7 @@ fn frame(s: *anim.Frame) void { runTo(s, as, q_turn[0] + 2, 1, &.{ 0.4, 0.3, 0.3 }); walk(s, as, q_check0, 0.5); walk(s, as, q_check0 + 1, 0.9); - walk(s, as, q_check0 + 3, 0.5); + walk(s, as, on(asan, q_check0, "je"), 0.5); tg.done(s); // A5: i = 0, the stores: ASan's rows after the check, then both stores, plain first, and each side's i++. @@ -445,7 +454,6 @@ fn frame(s: *anim.Frame) void { // to reach its check; the two first different rows framed `attention`; plain's store into the saved // rbp, its `differs` bar 12 f after; ASan's load reads f3, its compare, its `je` not taken. says.line(s, "i = 16, one past `buf`: plain writes an A into the saved rbp;\nASan reads `f3`, a redzone."); - const q_check16 = q_load(asan, q_turn[16]); tg = Together.begin(s); runTo(s, at, p_store[16], 1, &.{ 0.4, 0.4, 0.4 }); tg.next(s); @@ -464,7 +472,7 @@ fn frame(s: *anim.Frame) void { } tg.next(s); s.wait(30.0 / 60.0); - for (q_check16..q_check16 + 3) |m| { + for (q_check16..q_je16) |m| { const plan = as.reading(m, m + 1); as.step(s, m + 1, plan, plan.total * 0.75); } @@ -474,11 +482,11 @@ fn frame(s: *anim.Frame) void { // A9: ASan's partial check and its call walked; its run stops: its registers give way to its stderr. says.line(s, "ASan does not store: it calls its report,\nwhich names `buf` and the write."); // The partial check's compare and branch walked; the loads round them at a run. - runTo(s, as, q_check16 + 7, 1, &.{0.3}); - walk(s, as, q_check16 + 9, 0.9); + runTo(s, as, q_partial, 1, &.{0.3}); + walk(s, as, q_branch + 1, 0.9); runTo(s, as, report_call, 1, &.{0.3}); s.wait(t.beat); - s.play(.{regs_r.fadeOut()}, .{ .seconds = t.quick, .ease = anim.ease.linear }); + s.play(.{ regs_r.fadeOut(), stopped_r.to(1) }, .{ .seconds = t.quick, .ease = anim.ease.linear }); right.glide(s, pair.split(.right, true), 0.4); s.play(.{stderr.fadeIn()}, .{ .seconds = t.quick, .ease = anim.ease.linear }); s.play(.{framed.to(3)}, .{ .seconds = 18.0 / 60.0, .ease = anim.ease.linear }); diff --git a/anim/src/context.zig b/anim/src/context.zig index 8e0156d..7d56c62 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -262,9 +262,10 @@ pub const Registers = struct { const since = now.since(.cpu, delay); if (age == 0 and now.walking() and since >= 0) marks.extend = since; } - // At a run a value changes in place under an 8 f crossfade, unmarked, never in a frame. + // At a run a value changes in place under an 8 f crossfade, unmarked, never in a frame; so does its chain where what it reads changed. const ran = runFade(now, .cpu); - if (ran < 1 and value_was != value_now) _ = rows.reg(u.faded(1 - ran), y, w, name, was.moment, value_was, marks); + const fades = ran < 1 and (value_was != value_now or cursors.chainMoved(was.moment, is.moment, value_now)); + if (fades) _ = rows.reg(u.faded(1 - ran), y, w, name, was.moment, value_was, marks); // Its chain reads memory as the panels show it: what the step writes // there is followed again (`extend`) once the bytes have landed, never before. var memory = if (landed or ran < 1) is.moment else was.moment; @@ -272,7 +273,7 @@ pub const Registers = struct { memory, const again, marks.hops = now.following(value_now); if (again) |ago| marks.extend = @min(marks.extend orelse ago, ago); } - const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, memory, if (landed or ran < 1) value_now else value_was, marks); + const hops = rows.reg(if (fades) u.faded(ran) else u, y, w, name, memory, if (landed or ran < 1) value_now else value_was, marks); fdNote(u.faded(note_shows), hops, y, note); anchor(u, i, hops, y, if (landed or ran < 1) value_now else value_was, w); } diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig index e9aab67..b09db8d 100644 --- a/anim/src/cursor.zig +++ b/anim/src/cursor.zig @@ -866,6 +866,18 @@ pub fn jumps(rec: *const Recording, from: u64, to: u64) bool { return a.src != b.src or rec.depths[from] != rec.depths[to] or rows > time.current_jump_rows; } +/// Whether the chain from `value` reads otherwise at `is` than at `was` (the +/// values and texts of its hops). +pub fn chainMoved(was: Recording.Moment, is: Recording.Moment, value: u64) bool { + var bufs: [2][6]zt.telescope.Link = undefined; + var texts: [2][48]u8 = undefined; + const a = zt.telescope.chase(was, value, &bufs[0], &texts[0]) catch return false; + const b = zt.telescope.chase(is, value, &bufs[1], &texts[1]) catch return false; + if (a.len != b.len) return true; + for (a, b) |x, y| if (x.value != y.value or !std.mem.eql(u8, x.text, y.text)) return true; + return false; +} + /// The cursor at one instant. pub const Now = struct { rec: *const Recording, @@ -1188,14 +1200,7 @@ pub const Now = struct { const land = time.strike.in / 2.0; // Followed again only while that shows (its hops 4 f apart, 6 f each). if (struck < 0 or struck > land + 0.5) return .{ memory, null, 1 }; - var bufs: [2][6]zt.telescope.Link = undefined; - var texts: [2][48]u8 = undefined; - const was = zt.telescope.chase(n.before(), value, &bufs[0], &texts[0]) catch return .{ memory, null, 1 }; - const is = zt.telescope.chase(n.moment(), value, &bufs[1], &texts[1]) catch return .{ memory, null, 1 }; - const same = was.len == is.len and for (was, is) |a, b| { - if (a.value != b.value or !std.mem.eql(u8, a.text, b.text)) break false; - } else true; - if (same) return .{ memory, null, 1 }; + if (!chainMoved(n.before(), n.moment(), value)) return .{ memory, null, 1 }; if (!n.landedAt(value, 8)) return .{ memory, null, 1 - std.math.clamp(struck / land, 0, 1) }; return .{ memory, struck - 4.0 / 60.0, 1 }; } diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig index 6c9e2dc..f61c721 100644 --- a/anim/src/disasm.zig +++ b/anim/src/disasm.zig @@ -77,6 +77,14 @@ pub const Disasm = struct { measures: bool = true, /// Its window this many rows whatever its box (a `pair`'s stopped run: the box shortens over its lower rows). rows: ?usize = null, + /// A `pair`'s: its run's name before the function's on the tag (`plain · fill`). + run: []const u8 = "", + /// A `pair`'s alignment: the pc's line's first row at the window's top while + /// the pc is in its upper half, so that two runs' rows of one line start level. + aligned: bool = false, + /// A `pair`'s stopped run, 0 to 1: the call at the pc never returned. Its + /// row reads so, the plaque goes, the tag says `stopped`. + stopped: ?anim.Value = null, pub fn draw(d: *const Disasm, f: *sk.Frame, placed: anim.Placed) void { const box = d.stage.box(placed, .disasm); @@ -84,13 +92,14 @@ pub const Disasm = struct { const now = d.cursor.now(placed); const rec = d.cursor.rec; const room = d.rows orelse theme.layout.rowsIn(box.h); + const stop = if (d.stopped) |v| placed.value(v) else 0; // The mark: it moves last, with the source's and rip. const going = now.advancing(); - const from = listing(u, rec, now.marks[0], room); - const to = listing(u, rec, now.marks[1], room); + const from = listing(u, rec, now.marks[0], room, d.aligned); + const to = listing(u, rec, now.marks[1], room, d.aligned); // On the map its box is as long as the instructions the recording has round the pc. // (Of the moment the pane shows: a continue's destination repacks the map as the pane goes there, not as it sets off.) - if (ui.mapping and d.measures) map.measure(.disasm, listing(u, rec, now.marks[if (going >= 0.5) 1 else 0], theme.map.disasm_rows).rows.len); + if (ui.mapping and d.measures) map.measure(.disasm, listing(u, rec, now.marks[if (going >= 0.5) 1 else 0], theme.map.disasm_rows, false).rows.len); const pc = [2]u64{ rec.register(now.marks[0], "rip"), rec.register(now.marks[1], "rip") }; // The function's name: one that changes with the advance crossfades over it. @@ -98,12 +107,16 @@ pub const Disasm = struct { for (pc, &names) |at_pc, *name| { const sym = rec.strings.get(at_pc) orelse ""; name.* = sym[0 .. std.mem.lastIndexOfScalar(u8, sym, '+') orelse sym.len]; + if (d.run.len > 0) name.* = u.print("{s} \u{00b7} {s}", .{ d.run, name.* }); } const renamed = !std.mem.eql(u8, names[0], names[1]); - const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (renamed) "" else names[1] }); + const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (renamed or stop > 0) "" else names[1] }); if (renamed) { u.faded(1 - going).tagNote(box.w, names[0]); u.faded(going).tagNote(box.w, names[1]); + } else if (stop > 0) { + u.faded(1 - stop).tagNote(box.w, names[1]); + u.faded(stop).tagNote(box.w, u.print("{s} \u{00b7} stopped", .{names[1]})); } const top = body.y + m.pad; // The rows' own room: a row going out of the window passes under the padding, its block's rule too. @@ -161,8 +174,8 @@ pub const Disasm = struct { // The pc's row: gold ember across, a plaque with an ink triangle. const gold = theme.mark(.current); const out = now.fires(.disasm); - if (mark_shows > 0) { - const v = u.faded(mark_shows); + if (mark_shows * (1 - stop) > 0) { + const v = u.faded(mark_shows * (1 - stop)); v.current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.pc, out); sk.draw.polygon(u.f, &.{ .{ 20, mark_y + m.row / 2 }, .{ 10, mark_y + 6 }, .{ 10, mark_y + m.row - 6 } }, v.at.pen(.{ .fill = ui.rgb(gold.on_solid) })); ties.anchor(u, .pc, .{ .x = 0, .y = mark_y, .w = theme.metric.plaque.pc, .h = m.row }); @@ -233,9 +246,10 @@ pub const Disasm = struct { ties.anchor(u, .{ .row = row.addr }, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); const is_pc = row.addr == pc[if (going >= 0.5) 1 else 0]; // The row as before the advance and as after it (its state, its trail, its - // line number): where they differ, the one crossfades to the other over the - // advance's middle, never in a frame. - const across: f32 = if (now.resting()) 1 else std.math.clamp((going - 0.25) * 2, 0, 1); + // line number, the moment its annotation reads): where they differ, the one + // crossfades to the other over the advance's middle, at a run over the whole + // advance (the run's ease, 8 f, as a dump's values), never in a frame. + const across: f32 = if (now.resting()) 1 else if (now.plan.gait == .run) going else std.math.clamp((going - 0.25) * 2, 0, 1); var hangs: usize = 0; for ([2]usize{ 1, 0 }) |b| { const cur_s = rec.shown[now.marks[1 - b]]; @@ -248,10 +262,17 @@ pub const Disasm = struct { const cur_o = rec.shown[now.marks[1 - o]]; const line_o = if (row.outside or row.src != cur_o.src) null else row.line; const pc_o = row.addr == pc[1 - o]; - const same = pc_s == pc_o and std.meta.eql(line_s, line_o) and cur_s.line == cur_o.line and std.meta.eql(was_s, if (pc_o) null else rans[1 - o][j]); + const same = pc_s == pc_o and (!pc_s or now.marks[1 - b] == now.marks[1 - o]) and std.meta.eql(line_s, line_o) and cur_s.line == cur_o.line and std.meta.eql(was_s, if (pc_o) null else rans[1 - o][j]); const alpha: f32 = if (same) (if (main) 1 else 0) else if (b == 0) across else 1 - across; if (alpha <= 0) continue; - const v = lit.faded(alpha); + // A stopped run's call (`stopped`): the row as run, `never returned`, crossfading from the pc's. + const gone: f32 = if (pc_s) stop else 0; + if (gone > 0) { + const ran: Ran = .{ .k = 0, .at = now.marks[1 - b] }; + lit.faded(alpha * gone).trail(c.mark, y, ran.k); + _ = d.insn(lit.faded(alpha * gone), now, row, y, map.content(box.w), widen, line_s, line_s != last_line, cur_s.line, lead, .{ .ran = ran }, b, covered > 0, window, echo); + } + const v = lit.faded(alpha * (1 - gone)); if (was_s) |r| v.trail(c.mark, y, r.k); const h = d.insn(v, now, row, y, map.content(box.w), widen, line_s, line_s != last_line, cur_s.line, lead, state, b, covered > 0, window, echo); if (main) hangs = h; @@ -332,7 +353,7 @@ pub const Disasm = struct { // When the operands and the annotation do not both fit: the // annotation moves left (never past its column), then the operands give way. const ops = shorn(u, row); - const stub = if (target(row)) |to| pltName(u, rec, to) else ""; + const stub = if (target(row)) |to| (if (d.never(now, row, state, base)) bareName(u, rec, to) else pltName(u, rec, to)) else ""; var x = room + gap; if (need.drawn) x = annotationX(operandsWidth(u, row, ops, stub), room, need.end - annotationColumn()); operands(u, row, ops, stub, base_y, (if (covered) @min(x, annotationColumn()) else x) - gap - c.operands, if (pad) t.faint else theme.color.code.plain); @@ -340,6 +361,12 @@ pub const Disasm = struct { return if (need.drawn and !covered) d.annotation(u, now, row, y, x, room, state, base, window, echo).hangs else 0; } + /// A stopped run's call that has run and not come back (`stopped`, mock 38). + fn never(d: *const Disasm, now: cursors.Now, row: Insn, state: State, base: usize) bool { + if (d.stopped == null or state != .ran or !std.mem.eql(u8, row.mnemonic(), "call")) return false; + return returned(d.cursor.rec, row, state.ran.at, now.stops[base]) == null; + } + /// Whether `row` has an annotation: where it has none, its block's visits may be ranged right. pub fn noted(d: *const Disasm, u: ui.Ui, now: cursors.Now, row: Insn, y: f32, state: State, base: usize, window: [2]u64, echo: ?Echo) bool { return d.annotation(u.faded(0), now, row, y, annotationColumn(), std.math.inf(f32), state, base, window, echo).drawn; @@ -397,6 +424,8 @@ pub const Disasm = struct { if (stub) note.hangs = a.arguments(row, b.to, moment); return note; } + // A stopped run's call (`stopped`): its callee named on its address, and it never came back. + if (d.never(now, row, state, base)) return a.said("never returned", t.dim); var note = a.callee(b.to, moment); // Its arguments hang under it, a small `reg` a row, as many as the prototype has. if (state == .current) note.hangs = a.arguments(row, b.to, moment); @@ -1225,11 +1254,16 @@ fn cells(u: ui.Ui, x: f32, base_y: f32, bytes: u8) void { /// A PLT stub's name, for a call or a jump to one: `open@plt`; "" otherwise. fn pltName(u: ui.Ui, rec: *const Recording, to: u64) []const u8 { - const name = ui.symbol(u, rec.strings.get(to) orelse return ""); - const stub = name[0 .. std.mem.lastIndexOfScalar(u8, name, '+') orelse name.len]; + const stub = bareName(u, rec, to); return if (std.mem.endsWith(u8, stub, "@plt")) stub else ""; } +/// The function at `to`, by name ("" where it has none). +fn bareName(u: ui.Ui, rec: *const Recording, to: u64) []const u8 { + const name = ui.symbol(u, rec.strings.get(to) orelse return ""); + return name[0 .. std.mem.lastIndexOfScalar(u8, name, '+') orelse name.len]; +} + /// How wide operands `ops` of `row` are, whole (a target with its stub's name `stub`). fn operandsWidth(u: ui.Ui, row: Insn, ops: Operands, stub: []const u8) f32 { if (target(row)) |to| return @as(f32, @floatFromInt(ui.digits(to) + if (stub.len > 0) stub.len + 1 else 0)) * adv; @@ -1307,14 +1341,39 @@ fn full(name: []const u8) ?[]const u8 { /// `room` rows round the pc at moment `i`: in a pane, as many above as /// below; on the map, the function from its start where the pc is in its /// first three quarters of the rows (a strip's column stays still while -/// the pc walks it), else round the pc. -fn listing(u: ui.Ui, rec: *const Recording, i: u64, room: usize) Listing { +/// the pc walks it), else round the pc. `aligned` (a `pair`'s): no more +/// rows over the pc than its line has before it, so that the line's first +/// row is the window's top while the pc is in the window's upper half. +fn listing(u: ui.Ui, rec: *const Recording, i: u64, room: usize, aligned: bool) Listing { const pc = rec.register(i, "rip"); if (ui.mapping) { const whole = listingAt(u, rec, i, pc, room, room * 3 / 4); if (whole.pc < room * 3 / 4) return whole; } - return listingAt(u, rec, i, pc, room, (room -| 1) / 2); + const above = (room -| 1) / 2; + if (!aligned) return listingAt(u, rec, i, pc, room, above); + const l = listingAt(u, rec, i, pc, room, ofLine(rec, i, pc, above)); + // Where the code ends under the pc, the window is filled from above (as far as it would be unaligned). + if (l.rows.len < room and l.pc < above) return listingAt(u, rec, i, pc, room, @min(above, l.pc + room - l.rows.len)); + return l; +} + +/// How many of the `most` instructions just before `pc` are of its line (`most` where it has none). +fn ofLine(rec: *const Recording, i: u64, pc: u64, most: usize) usize { + var buf: [256]u8 = undefined; + const here = rec.instruction(i, pc, &buf) orelse return most; + const line = here.line orelse return most; + const src = here.src; + var back = here.back; + var addr = pc; + var n: usize = 0; + while (n < most and back != 0) : (n += 1) { + addr -= back; + const one = rec.instruction(i, addr, &buf) orelse break; + if (one.line == null or one.line.? != line or one.src != src) break; + back = one.back; + } + return n; } /// The same round the instruction at `pc` (in the window, `Listing.pc`). diff --git a/anim/test/recordings.zig b/anim/test/recordings.zig index 31cefdb..dea5b65 100644 --- a/anim/test/recordings.zig +++ b/anim/test/recordings.zig @@ -354,8 +354,9 @@ test "the pair's runs: plain faults at its ret on the letters; ASan stops at the if (std.mem.eql(u8, here.text, "ret")) break; } try expectEqual(@as(?u64, 0x4141414141414141), try canim.Recording.word(plain.moment(last), plain.register(last, "rsp"), 8)); - // ASan: its last moment is the report's first instruction, rdi the byte past buf: f3; buf's last byte addressable. - const at = asan.end() - 1; + // ASan: its last moment is in the report (`--until`, past its prologue), rdi the byte past buf: f3; buf's last byte addressable. + const at = asan.end(); + try expect(std.mem.startsWith(u8, asan.strings.get(asan.register(at, "rip")) orelse "", "__asan_report_store1")); const past = asan.register(at, "rdi"); try expectEqual(@as(?u8, 0xf3), (try canim.ztrace.telescope.shadow(asan.moment(at), past)).?.value); try expectEqual(@as(?u8, 0), (try canim.ztrace.telescope.shadow(asan.moment(at), past - 1)).?.value); |
