From bbabc78dcfd00a98abb5ececae6761bccc496eb8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 22:16:50 -0300 Subject: design: four times the context on a 4K stage; the loupe; quieter marks From the user, after the second videos. The stage is 3840 by 2160 at the same type size: four columns (source, disassembly, state, stack), 69 lines, rows and slots with no lens, 43 with a lens as subject, dumps of 32 rows. Code reads at 1440p and up; the caption, the clock and a lens's drawing are doubled, and the camera at x2 is the old frame. The stack's rows carry their offset from rsp and a role. A loupe is the telescope as a floating panel: the memory round what a pointer leads to, lifted over the context, a pointer inside it opening the next. The current row is a white wash, a strike a softened vermilion, held a turned corner; sheet 15 sets the alternatives side by side. Co-Authored-By: Claude Fable 5.2 --- design/README.md | 607 ++++++---- design/mock/09-context-480.png | Bin 36556 -> 36505 bytes design/mock/09-context.png | Bin 242644 -> 242320 bytes design/mock/09-context.svg | 30 +- design/mock/10-context-step-480.png | Bin 38234 -> 38234 bytes design/mock/10-context-step.png | Bin 247333 -> 246875 bytes design/mock/10-context-step.svg | 32 +- design/mock/11-context-lens-480.png | Bin 38429 -> 38599 bytes design/mock/11-context-lens.png | Bin 236071 -> 235747 bytes design/mock/11-context-lens.svg | 32 +- design/mock/12-calls-subject-480.png | Bin 32964 -> 32952 bytes design/mock/12-calls-subject.png | Bin 197962 -> 197829 bytes design/mock/12-calls-subject.svg | 34 +- design/mock/13-sqlite-row-480.png | Bin 32674 -> 33001 bytes design/mock/13-sqlite-row.png | Bin 229211 -> 229299 bytes design/mock/13-sqlite-row.svg | 56 +- design/mock/14-sqlite-page-480.png | Bin 37842 -> 37787 bytes design/mock/14-sqlite-page.png | Bin 234953 -> 235073 bytes design/mock/14-sqlite-page.svg | 58 +- design/mock/15-marks-480.png | Bin 0 -> 18542 bytes design/mock/15-marks.png | Bin 0 -> 264805 bytes design/mock/15-marks.svg | 1027 +++++++++++++++++ design/mock/16-none-480.png | Bin 0 -> 33091 bytes design/mock/16-none.png | Bin 0 -> 750420 bytes design/mock/16-none.svg | 1641 ++++++++++++++++++++++++++ design/mock/17-subject-480.png | Bin 0 -> 35404 bytes design/mock/17-subject.png | Bin 0 -> 714590 bytes design/mock/17-subject.svg | 1562 +++++++++++++++++++++++++ design/mock/18-loupes-480.png | Bin 0 -> 37782 bytes design/mock/18-loupes.png | Bin 0 -> 780782 bytes design/mock/18-loupes.svg | 2110 ++++++++++++++++++++++++++++++++++ design/mock/context.py | 218 ++-- design/mock/dense.py | 441 +++++++ design/mock/list-dbg.txt | 178 +++ design/mock/list.dis | 263 +++++ design/motion.md | 60 +- 36 files changed, 7910 insertions(+), 439 deletions(-) create mode 100644 design/mock/15-marks-480.png create mode 100644 design/mock/15-marks.png create mode 100644 design/mock/15-marks.svg create mode 100644 design/mock/16-none-480.png create mode 100644 design/mock/16-none.png create mode 100644 design/mock/16-none.svg create mode 100644 design/mock/17-subject-480.png create mode 100644 design/mock/17-subject.png create mode 100644 design/mock/17-subject.svg create mode 100644 design/mock/18-loupes-480.png create mode 100644 design/mock/18-loupes.png create mode 100644 design/mock/18-loupes.svg create mode 100644 design/mock/dense.py create mode 100644 design/mock/list-dbg.txt create mode 100644 design/mock/list.dis diff --git a/design/README.md b/design/README.md index 71c1b81..c58dae2 100644 --- a/design/README.md +++ b/design/README.md @@ -11,7 +11,7 @@ scene that draws every block in every state is the test of this page. - The numbers are tokens in `anim/src/theme.zig`: [what to change there](#token-changes). -![the frame, mid-step](mock/10-context-step.png) +![the frame on the 4K stage, mid-step](mock/17-subject.png) ## The rules @@ -19,7 +19,7 @@ scene that draws every block in every state is the test of this page. execution is, vermilion for what just changed. 2. **Ink says what a thing is; paper says what happened to it.** The colour of a value's digits is where it points, or that it is a keyword or a - string. A fill, a frame, a tick beside it is an event. The two never + string. A fill, a frame, a turned corner is an event. The two never share a channel. 3. **Every mark has its own form.** Written is filled, read is framed, changed is ticked, freed is hollow, unknown is two dots. Nothing is told @@ -28,7 +28,7 @@ scene that draws every block in every state is the test of this page. 5. **Panels are acme windows.** A tag, a 2-unit rule, a body. Square corners, no shadows, no gradients, no glow. 6. **The whole context, always.** Every register followed as far as it - points, seventeen instructions round the pc, the source, the stack: in + points, the instructions round the pc, the source, the stack: in the same place in every frame, as pwndbg shows them. A lens (a list, a tree, an array) is drawn over that state and never instead of it. 7. **Panes are views of one machine, and the ties are drawn.** A source @@ -55,7 +55,7 @@ this table. | | [`pin`](#pin) | a register's or a variable's name at the thing it points to | `row`, `under` | | | [`bracket`](#bracket) | a span marked at its edge | `quiet`, `tie` | | | [`tag`](#tag) | a panel's title bar | `focus`; `note` or `legend` | -| 2 row | [`chain`](#chain) | a telescope: this, which points to that, which holds this | `room`, marks per hop | +| 2 row | [`chain`](#chain) | a telescope: this, which points to that, which holds this | `room`, marks per hop; opens a `loupe` | | | [`reg`](#reg) | a register and its chain | `rip` (with `flags`) | | | [`slot`](#slot) | a word of the stack and its chain | pins; `free` | | | [`insn`](#insn) | an instruction and its annotation | `current`, `ran`, `ahead`, `outside` | @@ -67,34 +67,49 @@ this table. | | [`backtrace`](#backtrace) | the call chain as rows | in the `none` split; the view of `calls`; a lens's drawing | | | [`source`](#source) | a window on the file | 14, 8 or 10 lines | | | [`disasm`](#disasm) | the instructions round the pc | 17 or 9 rows | -| | [`lens`](#lenses) | a drawing of some state over the program column, and over the state column the pane it is a view of | `beside`, `subject` | -| | [`hexdump`](#hexdump) | memory, a `bytes` row a line | typed or by `fields`; `more` rows; `seen`; `given` | +| | [`lens`](#lenses) | a drawing of some state over the program's two columns, and in the third the pane it is a view of | `beside`, `subject` | +| | [`hexdump`](#hexdump) | memory, a `bytes` row a line | typed or by `fields`; `more` rows; `seen`; `given`; `memory` | +| | [`loupe`](#loupe) | the memory round a pointer's target, floating over the context | two at most, in depth | | | [`nodes`](#nodes) [`array`](#array) [`calls`](#calls) `heap` `syscalls` `pages` | the drawings a lens can hold | | | 4 tie | [`thread`](#4-ties) | the current line is these instructions | standing | | | [`link`](#4-ties) | this register points at that | for a step; rests as a `pin`; a stub when that is out of view | | | [`projection`](#4-ties) | these bytes are that part of the drawing | for a step | | | [`echo`](#4-ties) | the same mark in two panels at once | for a step | -| 5 frame | [`stage`](#5-the-frame) | the band and the two columns | split `none`, `beside`, `subject` | +| 5 frame | [`stage`](#5-the-frame) | 3840 by 2160: the lens and four columns | split `none`, `beside`, `subject` | | | [`clock`](#clock-and-caption) | where in the recording | | | | [`caption`](#clock-and-caption) | the narrator | | | | [`veil`](#clock-and-caption) | page over what a beat does not touch, or a pace cannot show | | | | [`card`](#clock-and-caption) | a title, the legend: no program running | | | 6 verb | [`fire` `arm` `strike` `cool` `read` `extend` `link` `project` `travel` `advance`](#6-verbs) | what one block does | | +| | [`open` `close`](#6-verbs) | what a loupe does | | | | [`cascade` `continue` `run` `sprint` `establish` `scroll` `relayout` `visit` `say`](#6-verbs) | what a frame does | | ## 0. Tokens ### Grid -1920 by 1080 units; a 4K master is two pixels a unit, at 60 frames a second. +3840 by 2160 units, at 60 frames a second: the 4K master is a pixel a +unit, and 1440p and 1080p are its downscales. The context keeps its type +size (mono 20, rows of 24) and so holds four times what a 1920 stage held: +see [the frame](#5-the-frame). | Token | Value | | --- | --- | | context mono | 20: an advance of 12, rows of 24 | -| panel | a tag of 24, 4 of padding, rows, 4 of padding: `32 + 24 n`; 12 at the sides | +| panel | a tag of 24, 4 of padding, rows, 4 of padding: `32 + 24 n`; 12 at the sides. The last panel of a column runs to the stage's foot, less than a row of padding under its rows | | between panels | 12 | -| columns | two of 880, at x 64 and 976; the gutter between them, 944 to 976, belongs to the ties | -| strokes | 2: rules, frames, chain arrows, a projection. 3: a link, the thread, a lens's frames. 4: a tick | +| columns | four of 880, at x 112, 1024, 1936 and 2848; the gutters between them, 32 each, belong to the ties | +| strokes | 2: rules, frames, chain arrows. 3: a projection, a lens's frames at 1920 scale. 4: a link, the thread, a loupe's stem | + +**What reads where.** Mono 20 is 20 pixels at 4K, 13 at 1440p, 10 at +1080p. The context's code and digits read on a monitor from 1440p up, full +screen; at 1080p they are sharp on a still but not after a stream's +compression, and count as texture. So at 1080p the layout, the marks, the +ties, the lens's drawing and the caption carry the story, and anything the +narration needs read in the context is in the caption or under the camera +at x2, which shows a quarter of the stage at 1080p exactly as the 1920 +stage drew it. The caption, the clock's count and a lens's drawing are +drawn at twice the 1920 sizes for that reason. ### Colour @@ -109,6 +124,9 @@ this table. | dim | `9aa6d9` | 7.8 | register names, `loose` bytes, notes | | faint | `6a7ab8` | 4.5 | chain arrows, line numbers, a decimal beside its hex | | ink | `050a24` | | letters on a solid mark | +| wash | `212644` | 1.2 | the current row's band: bright a tenth of the way over the page, opaque | +| lift | `121c52` | 1.2 | a loupe's surface; its tag `22317a` | +| shade | `02061a` | | a loupe's shadow, the one shadow there is | **Regions: the ink of an address**, as pwndbg colours them. The legend is the registers' tag, always on screen. @@ -131,8 +149,8 @@ name; heap and data have only their digits. | Role | Solid | Ember | | --- | --- | --- | -| current | gold `e8c46a` | `4a3d1c`; trail `ae9350`, `746235`, `463b20` | -| write | vermilion `ff6a4a` | `5a2218` | +| current | gold `e8c46a`, on the plaque only; the row's band is `wash` | trail `ae9350`, `746235`, `463b20` | +| write | vermilion `ff6a4a`, for the arm, the turned corner, a projection; a strike's paper `b54f42` (vermilion 70% over the page), its digits bright | `5a2218` | | read | `6fd6e6` | `1c4652` | | allocated | `7fdc9a` | `1f4a33` | | kernel | vellum `eee6d2` | | @@ -159,17 +177,19 @@ stream. OFL and BSD; `/usr/share/fonts/TTF/`, `/usr/share/fonts/go/`. | Mono | Advance | For | | --- | --- | --- | -| **20** | 12 | the context, the dump, a lens beside | -| 25 | 15 | a lens's values; its labels and pins as subject | -| 30 | 18 | the context under the camera at x1.5 | -| 35 | 21 | code inside a caption | -| 45 | 27 | a subject lens's values; a value in flight | -| 60 | 36 | a title card | - -Sans: 18 notes and legends, 20 tags, 40 on 54 the caption, 44 and 116 a -card. **Floor: mono 20, sans 18.** At 480p no digit at 20 can be trusted, -so: **nothing the narration depends on is only at 20.** It is also in the -caption at 35, or the camera goes to it. +| **20** | 12 | the context, the dumps, a loupe | +| 40 | 24 | the clock's count; a lens's labels and pins beside | +| 50 | 30 | a lens's values beside; its labels and pins as subject | +| 70 | 42 | code inside a caption | +| 90 | 54 | a subject lens's values; a value in flight | +| 120 | 72 | a title card | + +A lens's drawing is specified below at the 1920 sizes (`nodes` 124 by 72, +values 45) and drawn twice that on the 4K stage; so are its strokes, lanes +and flights. Sans: 18 notes and legends, 20 tags, 80 on 108 the caption, 88 +and 232 a card. **Floor: mono 20, sans 18,** in 4K units: 10 and 9 pixels +at 1080p. **Nothing the narration depends on is only at 20:** it is also in +the caption at 70, or the camera goes to it. ## 1. Atoms @@ -185,7 +205,7 @@ Lower-case hex, **unbroken**, as long as it is, no `0x`, no leading zeros: | `rwx` | a 2-unit underline | States: plain; `struck` (bold, in ink, on solid vermilion 5 wider each -side); `read` (a 2-unit frame, 6 out); `held` (a tick at its left). Data: +side); `read` (a 2-unit frame, 6 out); `held` (a turned corner at its top left). Data: a word and the mapping it lies in. Mocks 9 to 11, everywhere. ### value @@ -252,10 +272,10 @@ What happened, on paper and never in the letters. | State | In the context (mono 20) | In a lens's cell | | --- | --- | --- | -| `current` | a gold plaque on the label, gold ember across the row | the same | +| `current` | a gold plaque on the label, and across the row a white wash (`wash`) | the same | | `armed` | a 2-unit vermilion frame, the old value still in it | 3 units | -| `struck` | solid vermilion behind the value; digits bold, in ink | solid fill | -| `held` | a vermilion tick, 4 wide, the row less 6 tall, at the value's left, for three steps | a vermilion bar, 4 high, along the cell's bottom edge | +| `struck` | the softened vermilion (`b54f42`) behind the value, 5 out each side; digits bold, bright | the same, the cell's fill | +| `held` | a turned corner: a vermilion triangle 9 on its sides at the value's top left, for three steps | the same at the cell's top left, 12 (24 on the 4K stage) | | `read` | a 2-unit frame in read's colour, no fill | 2 units, 2 out | | `trail` | a 4-unit bar at the row's left edge: three tones, newest first | | | `allocated` | | ember block in a solid frame | @@ -265,8 +285,18 @@ What happened, on paper and never in the letters. | `unknown` | two dots | two dots | | `kernel` | the ground is solid vellum | the same | -One gold mark a panel. One step's writes in vermilion at a time. Mocks 9 -and 10 show current, struck, held, read, trail, unknown; 1 to 8 the rest. +One gold mark a panel. One step's writes in vermilion at a time. Gold is +kept for the plaque, the pc's marker, rip's name, the thread and the +trail: where execution is, as a sign and not as a band. + +The first videos drew `current` as a gold ember across the row, `struck` +as solid vermilion with ink digits, and `held` as a tick left of the +value: the band was the strongest thing in a dense frame, the solid strike +glared, and the tick read as a text cursor. [Mock 15](mock/15-marks.png) +sets those (A) beside these (B) and a whiter reading (C: a white plaque, a +white strike framed in vermilion, a bar under the held value) on the same +rows. Mocks 9 to 18 show current, struck, held, read, trail, unknown; 1 to +8 the rest. ### plaque @@ -339,7 +369,7 @@ its far end and says so. is taken from the middle. - **Marks** are per hop. If the first is struck the register was written and the rest are followed again ([`extend`](#6-verbs)); if a later one, - memory changed under a pointer that did not, and the tick sits before + memory changed under a pointer that did not, and the turned corner sits on that hop alone. - No lines to targets. Thirty chains would be a net; a chain is tied to its target by ink, by digits, and by the target's pin. @@ -348,21 +378,29 @@ its far end and says so. A name (dim) 12 in; its chain from 72; room to 12 from the edge. -`rip`: gold plaque on the name, ember across, the address in code's ink +`rip`: gold plaque on the name, the wash across, the address in code's ink and its name. Never struck. Its row carries **flags** at the right end: eight names on a pitch of 42. Set: upper case on a chip. Clear: lower -case, dim. Changed: a tick. (The value `0x206` is not drawn: the names are +case, dim. Changed: a turned corner. (The value `0x206` is not drawn: the names are the value.) ### slot -A lane 112 wide for a `row` pin; the chain from 122, beginning with the -slot's own address in stack ink with `lead`; room to 136 from the right -edge, which belongs to the [`call`](#call) spans. A span's name is never -cut for a chain: on the rows its name sits on (one, or the two it -straddles), the chain's room ends 12 before the name begins, and the -chain is cut there by its own rule (`sqlite3BtreeInsert` beside -`7fffffffe980 → 7fffffffeb90 → 7fffffffec60 → …`). +A word of the stack, pwndbg's way and a little more. + +| x | Column | | +| --- | --- | --- | +| 10 | pins | the `row` pin's lane, to 112: every register whose value is this word's address | +| 172 | offset | from rsp, hex, `+18`, faint, ranged right in four characters (`-8` above rsp) | +| 184 | address | stack ink, `lead`; then the chain, its first hop the word's content | +| right | role | what the word is, where the recording knows it, ranged right where the chain's room ends: `saved rbp`, `saved rbx` (dim); a local's name (primary); at the process's start `argc`, `argv[0]`, `argv end`, `envp end`, `auxv` (dim) | +| 14 from the right | span | the [`call`](#call) bracket, its name left of it | + +A return address needs no word: its chain is code, named (`10018b0 +main+80`), and its frame's bracket ends on it. Room runs out from the +right: a span's name is never cut, a role is never cut, and the chain on +the rows they sit on ends 12 before them, cut by its own rule +(`sqlite3BtreeInsert` beside `7fffffffe980 → 7fffffffeb90 → …`). `free`: a word above rsp, which the stack has not reached. Shown only while the window is held still for the camera ([`visit`](#6-verbs)): its @@ -396,10 +434,10 @@ whole annotation do not fit, in this order: | State | Draws | | --- | --- | -| `current` | plaque, ember across; annotation in full ink | +| `current` | plaque, the wash across; annotation in full ink | | `ran` | trail bar, newest of three brightest; keeps the annotation of what it did | | `ahead` | plain; only static annotation (a callee's name) | -| `outside` | past the function's end: a rule above the row, everything faint, the next symbol's name in the annotation column | +| `outside` | another function's: plain, as `ahead`; over its first row a rule, and its name in that row's annotation column, dim. Past the program's text (padding, a section's end): faint | **The annotation**, by what the instruction does: @@ -422,7 +460,7 @@ syscall annotations are not drawn. The number ranged right in three characters, faint; the text from 64, in the four code inks; 67 characters, then a faint `…`. `current`: gold -plaque on the number, ember across. `trail`: the bar, for the last three +plaque on the number, the wash across. `trail`: the bar, for the last three other lines run. **Wide numbers.** The number column is as wide as the program's largest @@ -466,7 +504,7 @@ from the first that changed to the last: a pointer whose low byte alone moved is struck on that byte, and two `int`s swapped are struck as two runs of 4. A byte stored with its own value is not marked: the recording sees values, not stores. `read` (a 2-unit frame 3 out) frames the run -read. `held` is a tick in the gap left of what was struck. A struct wider +read. `held` is a turned corner at the top left of what was struck. A struct wider than a row spans rows, and its bracket spans them. ### call @@ -500,38 +538,40 @@ moment's registers and mappings. ### stack -`slot`s, low addresses on top: eight; six when the lens is the subject. -`call` spans down its right edge: the backtrace, drawn on the words that -are each frame. rsp and rbp are pins in its lane. Reads the stack words, -and each frame's extent (the frame-pointer chain, or the unwinder's CFA). - -**The window** is on the newest frame: the words from rsp to its return -address, `[rsp, rbp+16)`, its locals, saved rbp and return address. - -- Where the frame is no longer than the window, the window's top is rsp - and the caller's words fill the rest. -- Where it is longer, the window scrolls down it by whole slots - ([`scroll`](#6-verbs)) to keep the slot a step touches in its middle - rows (the third and fourth of six; third to sixth of eight), and stays - there until a step touches a slot outside them. Its top never passes - above rsp. +`slot`s, low addresses on top, a column of its own the stage's height: +69 words, 552 bytes, in every split. `call` spans down its right edge for +every frame in view: the backtrace, drawn on the words that are each +frame. rsp and rbp are pins in its lane. Reads the stack words, each +frame's extent (the frame-pointer chain, or the unwinder's CFA), and for +the roles the saved registers (the frame-pointer chain; the call frame +information for the prologue's pushes), the locals' names and places (the +debug info at the pc), and the first stack pointer (argc, argv, envp, +auxv). + +**The window** begins at rsp, and a small program's whole stack is in it: +its frames, main's, libc's, and the process's start. Where the newest +frame `[rsp, rbp+16)` is longer than the window, it scrolls down it by +whole slots ([`scroll`](#6-verbs)) to keep the slot a step touches in its +middle third, and stays there until a step touches a slot outside it; its +top never passes above rsp. + - A push or a call moves the top with rsp: the rows slide one slot (18 f, as rows making room), at the memory level, before the new word is - armed. A window going farther than six slots (eight beside) fades - through instead ([`scroll`](#6-verbs)). + armed. A window going farther than its height fades through instead + ([`scroll`](#6-verbs)). - While the camera is on the stack the window holds still ([`visit`](#6-verbs)): pushes fill `free` slots in the middle of the frame, and rsp's pin climbs to them. -Tag: `six words from rsp`, or the range when scrolled (`rsp+20 to -rsp+48`), and `· the frames they belong to`. +Tag: `69 words from rsp`, or the range when scrolled (`rsp+20 to +rsp+240`), and `· the frames they belong to`. ### backtrace -`call` rows, newest on top. A panel of its own in the `none` split, four -and then a count, under the stack; the view panel of a [`calls`](#calls) -lens, seven; the drawing of a [`backtrace` lens](#lenses), eleven as -subject and five beside; in the other splits the stack's spans carry it. +`call` rows, newest on top: sixteen, under the registers, in every split; +the view of a [`calls`](#calls) lens (32, and the panel under the +registers is then `memory`); the drawing of a [`backtrace` +lens](#lenses), as long as the drawing is high. More frames than rows: the oldest go, and the tag's note counts them, `newest on top · 2 more`. @@ -545,33 +585,38 @@ identity: the slide is what says it is the same frame. ### source A window on the whole file, scrolled by whole lines to keep the current -line in its middle third. Fourteen lines; eight beside a lens (the loop -in hand); ten when the lens is the subject. Tag: the file, and `lines 19 -to 26 of 42`. A line farther than a window away (another function in a +line in its middle third: 69 lines in `none`, 56 beside a lens, 43 as its +subject; a file shorter than that is whole, the rows under its end empty. +Tag: the file, and `lines 19 to 61 of 262899`, or `lines 1 to 42 of 42`. A line farther than a window away (another function in a file of 262 899 lines) is not scrolled to: the window fades through ([`scroll`](#6-verbs)). Line numbers are as wide as the program's largest ([`line`](#line)). ### disasm -Seventeen `insn`s in address order: the pc's, eight above, eight below. -Nine (four, the pc, four) when the lens is the subject. - -- Rows above the pc are the function's own instructions. Near its start - there are fewer, and the pc's row sits higher; the window stays full - from below. -- Past the function's end the rows are `outside`. +`insn`s in address order, a column's height: 69 rows in `none`, 56 +beside a lens, 43 as its subject. + +- The pc's row is in the window's middle third; the window is the + function's and as much of its neighbours as fits, above and below. At + this length a small function is whole, and its callers and callees + around it are context, not noise: they are `outside`, plain, each under + a rule and its name. +- The window moves only when the pc leaves its middle third, by whole + rows ([`scroll`](#6-verbs)), or fades through when the new pc is + farther than the window's height. - The rows that ran in the last three steps are `ran`, above or below the pc: with the jump lane they show how control came here. - Tag: the function's name. ### lenses -A lens is the band across the top of the stage: **a drawing, over the -program column, and over the state column the pane the drawing is a view -of**, each a panel with its own tag. The gutter between them is the ties', -as it is below. Beside the context both are 152 high; as the subject the -drawing is 296 and its view 200 ([the frame](#5-the-frame)). +A lens is **a drawing, over the program's two columns, and in the third +column, beside it, the pane the drawing is a view of**, each a panel with +its own tag. The gutter between them is the ties', as it is below. The +drawing is 300 high beside the context and 604 as its subject, and drawn +at twice the 1920 sizes given here; the view is 32 rows in both ([the +frame](#5-the-frame)). | Lens | Drawing | Its view | Mock | | --- | --- | --- | --- | @@ -584,6 +629,11 @@ drawing is 296 and its view 200 ([the frame](#5-the-frame)). | `pages` | the far view: pages, system calls over time | the mappings, a row each | 8 | | `hexdump` alone | bytes and their text | itself | 5, in its first-pass form | +`memory`, in the `none` split, is the third panel of the third column (32 +rows): a `hexdump` of the region the step touches, kept round what it +reads or writes, typed where the recording types it; with a lens, the +lens's view is this. + A scene may change its lens where it stands: the drawing fades out (12 f), then the next fades in (12 f) and its elements come in as at `establish`; a view the two share stays. The split does not move, so this @@ -592,10 +642,10 @@ row reaches `pwrite64`. **What a new lens must provide** to fit the frame: -1. A drawing that fits 856 by 116 (`beside`) and by 260 (`subject`). -2. Its view, a pane of rows that fits the state column (five beside, - seven as subject), and for every element the bytes, slot or register - it is drawn from. +1. A drawing that fits 880 by 132 (`beside`) and by 284 (`subject`) at + the 1920 sizes, to be drawn twice that over the program's columns. +2. Its view, a pane of 32 rows that fits a column, and for every element + the bytes, slot or register it is drawn from. 3. A `place` for every element, so ties can land. A 12-unit lane clear at the top of the drawing and one at the bottom: **bytes from its view arrive from above; pointers, and a frame from the stack, from below.** @@ -616,7 +666,8 @@ digits as its row in the dump. **Under** it, its pins. Marks on a half: ### hexdump `bytes` rows, sixteen a row, a window of the region kept round the rows -the step touches: five beside, seven as subject. Rows in address order. +the step touches: 32, 512 bytes, as a lens's view and as `memory`; nine in +a [`loupe`](#loupe). Rows in address order. Tag: `its bytes`, then what the bytes are and where (`the heap, 28b41050 to 28b410bf`; `pBuf: page 2 of t.db, at rsi`), and the legend of runs: each field's name in its bytes' ink, `malloc's`, `never read`. @@ -692,7 +743,8 @@ Its view is the [`backtrace`](#backtrace): the waiting path read as rows, `#0` the gold node. Each node is also the `call` span of its frame on the stack, and the two are tied twice: by digits (`fib(4)` beside the span, `4` on the node) and, on the step that makes or ends the call, by a -[`projection`](#4-ties) from the frame's return address to the node. +[`projection`](#4-ties) from the frame's row in the backtrace, the view, +to the node. **A larger tree.** The leaves share the drawing's width less the caller's box: about 680 units between the first leaf's centre and the last's. A @@ -742,6 +794,45 @@ A **crossing** is a step that makes one system call; its timetable is a crossing: the list takes them, oldest first, 2 f apart, each fading in; the newest is decoded; no arrow, no bytes. +### loupe + +The telescope's other form. A `chain` on a row says, flat, `rdi → +1004070 ◂ 9`; a **loupe** opens the place it points to: a panel floating +over the context with the memory round the target, the pointed thing +framed, read by its type where the recording has one. A pointer in it can +open the next, and a chain becomes panels in depth. + +| Part | Drawn | +| --- | --- | +| panel | 880 wide, a tag and nine `bytes` rows: the target's row in the middle, four before and four after (144 bytes), its runs typed (a node's value and next, malloc's words) or by `fields` | +| tag | `rdi → 1004070`, mono 20, the pointer it opens from and the target in its region's ink; ranged right, the region and the type, `heap · struct node, 16 bytes`, Go 18 dim | +| target | its run or its struct framed as `attention`: 2 units, bright | +| lift | its surface `lift` (`121c52`), its tag `22317a`, a 2-unit `dim` frame, and under it a solid shadow (`shade`) 12 right and 16 down; a loupe opened from a loupe, 20 and 26. This is the one place in canim with elevation: a loupe is not a panel of the frame but held over it | +| stem | the tie from the pointer to the loupe: a `link` (4 units, the target's region ink, head 12 on the loupe's tag), leaving the pointer where its row has room after the chain, or from a 3-unit bracket under a pointer inside a loupe | + +**Where it floats.** Beside what it opens from, its tag level with the +pointer's row: from the registers over the stack's column, from the stack +over the registers', from the disassembly or a dump over the column on its +right; a loupe opened from a loupe 120 to the right and just under the +pointer it opens from, over the older loupe's lower rows. It never covers +its own pointer, the current marks (the pc's row, the current line, +rip's row), the ends of a drawn tie, or a row the step changes; where the +first place would, it takes the other side, then the place under its +pointer; and it stays inside the stage. + +**How many.** Two at most. A third, followed from the second, closes the +first as it opens, so a chain of any length is walked two loupes at a +time. While two are open their stems are two of the frame's three lines +(the thread is the third): that step draws no other link and no +projection. + +**When the flat chain is right.** Always, as the standing form: every +register, slot and annotation keeps its chain, and a loupe never replaces +one. A loupe opens on a beat the narration names (a pointer followed, a +struct handed to a call) for a step or two; not at a run or a sprint; not +where the recording holds less than its nine rows round the target. It +opens and closes by its verbs ([`open`, `close`](#6-verbs)). Mock 18. + ## 4. Ties The panes are one machine at different levels. A tie says which thing in @@ -749,9 +840,9 @@ one pane a thing in another is. | Tie | Says | Between | When | Form | | --- | --- | --- | --- | --- | -| `thread` | this line is these instructions, and the machine is here | the source's current line; every run of its instructions in the disassembly | standing; moves with the current mark | gold, 3 units: a `tie` bracket on the line, one on each run, a line in the left margin (x 54) between them | +| `thread` | this line is these instructions, and the machine is here | the source's current line; every run of its instructions in the disassembly | standing; moves with the current mark | gold, 4 units: a `tie` bracket on the line at the source's right edge, one on each run at the disassembly's left, and between them a line down the gutter (x 1008), the two side by side | | `link` | this register now points at that | the `reg` just struck; the row or node whose address it holds | for the step that set it | 3 units, in the ink of the region pointed into, head on the target; ends in the target's `pin` and leaves it behind | -| `projection` | these bytes are that part of the drawing | a run a step read or wrote, in the dump; or the return address of a frame made or ended, on the stack; the part of the drawing made of them (a node's address, a cell, a call's node) | for that step | 2 units in the mark's colour (read, write): a `tie` bracket on the row, a line, a bracket at the part (over a node's address; under a call's node); and the mark itself on the run and on the part | +| `projection` | these bytes are that part of the drawing | a run a step read or wrote, in the dump; or the backtrace row of a frame made or ended (a `calls` lens's view); the part of the drawing made of them (a node's address, a cell, a call's node) | for that step | 2 units in the mark's colour (read, write): a `tie` bracket on the row, a line, a bracket at the part (over a node's address; under a call's node); and the mark itself on the run and on the part | | `echo` | these are one event | the same mark at the same instant in two panels: the annotation's address and the dump's run | for that step | no line | | ink, digits | these are one thing | an address anywhere and its row, node or name; a call's arguments on its span, its backtrace row and its node | always | no line | @@ -764,9 +855,10 @@ made of them, which is what a projection says. A node and its frame are also tied by digits, standing, through the arguments on the span. **Budget.** One `thread`, always. For a step, one `link` and one -`projection`. Never more than three drawn lines in the frame; a second -pointer or a second run in the same step gets `echo` and pins. rsp never -takes a link: its pin is on the window's top row by construction. +`projection`, or the stems of two [`loupe`s](#loupe) (a stem is a link). +Never more than three drawn lines in the frame; a second pointer or a +second run in the same step gets `echo` and pins. rsp never takes a link: +its pin is on the window's top row by construction. [`establish`](#6-verbs) draws no lines. **Off the window.** A link whose target is outside its panel's window (a @@ -777,85 +869,87 @@ how far the target is, `12 rows`. The pin is drawn when the window reaches it. **Routes.** A tie runs only in channels, with corners of radius 8 (6 for a -projection): +projection). On the 4K stage the four columns leave three gutters: | Channel | Carries | | --- | --- | -| the left margin, x 54 | the thread | -| the gutter's left lane, x 950 | what climbs into the band from the state column: a link from a register to a pin under a node; a projection from a frame's return address to its call node | -| the gutter's right lane, x 962 | what keeps to its own height or goes down: a projection from the band's view to the drawing; a link from a register down to a slot | +| the gutter between source and disassembly, x 1008 | the thread | +| the gutter between the program and the third column, left lane x 1912 | a link from a register up to the pin under a node: it leaves the register's row at its left, climbs, and turns into the drawing's bottom lane | +| the same gutter, right lane x 1924 | a projection from the view to the drawing: it leaves the view's row at its left and climbs to the drawing's top lane, or for a call's node goes down to its bottom lane | +| the gutter between the third column and the stack, x 2832 | a link from a register to a slot: it leaves the register's row at its right edge and enters the slot's pin lane | | a lens's bottom lane, 8 above its edge | what arrives from below: a link to the pin under its node; a projection to a call node | | a lens's top lane, 4 under its tag | a projection from the view, to the bracket over its node's address | | a panel's pin lane | a link's last leg to a `row` pin, or its stub | - -Ties that climb from the state column take the left lane and arrive from -below; the view's projections keep to the band in the right lane and -arrive from above. A link down to a slot takes the right lane under the -band and ends above the frame's return address, where a calls -projection leaves for the left lane: so the ties of one step cannot -cross. A tie may cross a panel's rule; it never crosses a letter, a digit +| none | a loupe's stem: from its pointer straight to the loupe, over the row's empty end or the gap between a loupe's row and the loupe it opens | + +Ties into the drawing keep to the gutter beside it, links in the left lane +arriving from below, projections in the right lane; links to the stack +keep to the gutter beside the stack: so the ties of one step cannot cross. +A calls lens's projection leaves the frame's row in the backtrace, its +view (the frame the return address made), not the stack's slot, which is +two columns away. A tie may cross a panel's rule; it never crosses a letter, a digit or another tie. A projection climbing to a call node crosses no edge: under a node that has just been made there is only room for its own children. **Order.** A tie arrives before the thing it points to reacts: see -[`link` and `project`](#6-verbs). Mock 9 shows the standing ties; 10 and -11 all four; 12 the projection to a call. +[`link` and `project`](#6-verbs). Mocks 16 to 18 show the ties on the 4K +stage: the thread across its gutter, a link and a projection, two stems. ## 5. The frame +The stage is 3840 by 2160 units, the 4K master's pixels. + | Band | y | | | --- | --- | --- | -| margin | 0 to 48 | page | -| stage | 48 to 888 | 840: the lens band and the two columns | -| clock | 898 to 902 | | -| caption | 912 to 1032 | | -| margin | 1032 to 1080 | page | - -No data below 888: a player's controls cover it. - -**The program column** (left): source over disassembly: what was written, -what runs. **The state column** (right): registers over stack: what they -act on. **The lens band** (top): what it means, over the program column, -and the pane that means it, over the state column. The split is the one -thing about the layout a scene chooses. - -| Split | Drawing | Its view | Source | Disassembly | Registers | Stack | Backtrace | -| --- | --- | --- | --- | --- | --- | --- | --- | -| `none` | | | 14 lines, 48 to 416 | 17, 428 to 868 | 48 to 488 | 8, 500 to 724 | 4, 736 to 864 | -| `beside` | 152, 48 to 200 | 152, 48 to 200: 5 rows | 8 lines, 212 to 436 | 17, 448 to 888 | 212 to 652 | 8, 664 to 888 | in the stack | -| `subject` | 296, 48 to 344 | 200, 48 to 248: 7 rows | 10 lines, 356 to 628 | 9, 640 to 888 | 260 to 700 | 6, 712 to 888 | in the stack; the view of `calls` | - -**What gave** for seventeen instructions: a lens, the whole of a function -and seventeen instructions do not fit one column of 840. So the lens left -the program column for a band of its own; the backtrace became spans on -the stack; the flags moved into rip's row; a panel's padding went from 6 -to 4; and beside a lens the source shows eight lines. As the subject the -drawing takes eight rows from the disassembly (seventeen to nine), the -source gets two back, and the view stops two rows short of the drawing so -that the stack keeps six slots: a small frame's locals, saved rbp and -return address together. With a lens open the source is a window of -eight or ten lines on the file, not all of it: the drawing's height is -bought with the source's lines, and whether that is the trade rule 6 -allows is open. +| margin | 0 to 96 | page | +| stage | 96 to 1784 | 1688, a panel of 69 rows: the lens and four columns | +| clock | 1796 to 1804 | | +| caption | 1824 to 2064 | | +| margin | 2064 to 2160 | page | + +No data below 1784: a player's controls cover it. Sides: 112. + +**Four columns of 880**, at x 112, 1024, 1936 and 2848, 32 apart. **A**, +the source, and **B**, the disassembly, side by side: what was written, +what runs, the thread between them in their gutter. **C**: the registers, +the backtrace, and `memory` (or a lens's view). **D**: the stack, the +stage's height. **The lens**: its drawing over A and B, its view in C. The +split is the one thing about the layout a scene chooses, and it changes +only how high the drawing is. + +| Split | Drawing (A and B) | Source (A) | Disassembly (B) | C | Stack (D) | +| --- | --- | --- | --- | --- | --- | +| `none` | | 69 lines, 96 to 1784 | 69 rows | registers 96 to 536; backtrace 16, 548 to 964; `memory` 32, 976 to 1784 | 69 slots, 96 to 1784 | +| `beside` | 1792 by 300, 96 to 396 | 56 lines, 408 to 1784 | 56 rows | the view 32, 96 to 896; registers 908 to 1348; backtrace 16, 1360 to 1784 | 69 slots | +| `subject` | 1792 by 604, 96 to 700 | 43 lines, 712 to 1784 | 43 rows | as `beside` | 69 slots | + +Against the 1920 stage: source 14, 8, 10 lines became 69, 56, 43; +instructions 17, 17, 9 became 69, 56, 43; the stack's 8, 8, 6 slots 69; +a dump's 5 or 7 rows 32. **What it costs**: the context's text is 10 +pixels at 1080p, where it is texture (see [the grid](#grid)); the camera +at x2 is how a 1080p viewer reads it, and the caption, the clock and the +lens's drawing are twice their 1920 sizes so that they read anywhere. A +file of more than 69 lines, and with a lens open any file, is still a +window: the trade with rule 6 stands, at four times the window. | Of the frame | `none` | `beside` | `subject` | | --- | --- | --- | --- | -| context | 68% | 56% | 48% | -| lens band (the drawing and its view) | | 13% | 21% | +| context | 72% | 56% | 50% | +| lens (the drawing and its view) | | 15% | 22% | | caption band | 10% | 10% | 10% | ### clock and caption -- **`clock`**: a 2-unit rule the width of the stage at y 900; gold, 4 +- **`clock`**: a 4-unit rule the width of the stage at y 1798; gold, 8 high, along it as far as the recording has run; `moment 72 of 95` in - mono 20, faint, under its right end. It says where the recording is, so + mono 40, faint, under its right end. It says where the recording is, so at a walk and a run it is still while a step plays: when the step's mark has landed, the step's piece of gold fades in (12 f; 8 f at a run) and the count changes as the fade starts. At a sprint the gold grows with the recording, linearly, and is the one thing that says "fast". -- **`caption`**: one or two lines of at most 64 characters, Go 40 on 54, - ranged left on the margin; code in it is mono 35. Hex in it is unbroken +- **`caption`**: one or two lines of at most 64 characters, Go 80 on 108, + ranged left on the margin; code in it is mono 70. Hex in it is unbroken too. What a scene author checks, characters counted as shown: | Rule | Number | @@ -873,9 +967,11 @@ allows is open. at 65% under the camera. In over 18 f, out over 18 f. - **`card`**: a title or the legend ([mock 6](mock/06-title-legend.png)). The only frames with no context. -- **Camera rests**: x1 (the frame), x1.5 (1195 by 560: a column, or the - band), x2 (896 by 420: sixteen rows), x4 (448 by 210: one chain). It is - for reading, and always comes back. +- **Camera rests**: x1 (the frame), x1.5 (2560 by 1440: three columns' + upper half, or the lens), x2 (1920 by 1080: two columns, 45 rows, at + 1080p exactly the 1920 stage's density), x4 (960 by 540: one column's 20 + rows). It is for reading, and always comes back: on the 4K stage it is + also how a small screen reads the context. ## 6. Verbs @@ -888,12 +984,14 @@ Frames at 60 a second. `s` is the frame a strike lands. Curves: | `fire` | the current plaque | 0 to 12: it pulses once. Nothing else moves | | `arm` | a value about to be written | s-12 to s: the `armed` frame, in over 2 f; the old value still in it | | `strike` | a value written | s to s+6 the fill comes in, linear; the new digits at s+3; s to s+12 its edges go out 3 units (4 in a lens's cell) and back, sine; solid until the advance | -| `cool` | a struck value | starts with the advance: 24 f, `glide`, in the context to nothing, leaving `held` for three steps (then out over 36 f); in a lens's cell to its bar. The digits go to their ordinary face at its middle | +| `cool` | a struck value | starts with the advance: 24 f, `glide`, the paper to nothing, and the turned corner of `held` fades in over its last 6 f, for three steps (then out over 36 f); the same in a lens's cell. The digits go to their ordinary face at its middle | | `read` | a value read | in over 6 f; held to the advance; out over 18 f. No arm, no pulse | | `extend` | a chain whose first hop was struck | each later hop is followed again, 4 f apart, fading in over 6 f | | `link` | a `reg` just struck, and its target | s+6: the old pin fades (12 f) and the line draws from the register's row, head first, 24 f (36 f over 400 units), `standard`, the pin riding its head; the pin lands with the head and settles (12 f); held; at the advance the line draws back into the pin over 18 f. A target out of the window: the line ends in its stub, and the pin waits for the window | | `project` | a run read or struck, and its part of the drawing | on the run's mark: the bracket on the row (6 f), the line draws from the bytes to the drawing (18 f; 30 f over 600 units; `standard`); only when it arrives does the part react (its own `read`, or `arm` and `strike`; a new call's node fades in, 6 f); out with the advance, 18 f | | `travel` | a value, a card or a pin going from one place to another | `glide`. A value or card: 30 f to 200 units, 36 f to 400, 48 f beyond. A pin goes along its lane, 18 f after the strike that moved it: in a drawing 30 f to the next node or cell, 36 f to one farther; in the stack's lane 24 f to the next row and 2 f a further row, 36 f at most. A pin that comes fades in over 12 f rising 8 units; one that goes fades out over 12 f; a name joining or leaving a pin cross-fades over 12 f. On a `link` the pin rides the line's head instead. 8 f at a run; at a sprint only at a phrase's end | +| `open` | a loupe, from a pointer | the pointer's hop framed `read` (6 f); the stem draws from it to the loupe's place, head first, 18 f (30 f over 600 units), `standard`; the loupe rises with the stem's head: it fades in over 12 f from 8 units lower, its shadow growing from nothing to its offset (18 f, `standard`); the target's bright frame lands 6 f after. From a pointer inside a loupe the same, over it, and a third closes the first as it starts. In the slot of the level that read the pointer, or on a beat the caption names | +| `close` | a loupe | the deepest first: its stem draws back into its pointer (12 f) and the loupe sinks, fading out over 12 f as it falls 8 units and its shadow shrinks; with the advance of the step after the one it opened in, unless the narration holds it; 120 f at most without a change | | `advance` | the current marks | last. The thread, the plaques and rip move together: 12 f to an adjacent row, 24 f up to eight rows, `standard`; farther, out and in over 6 f. A taken jump's line draws in the jump lane with it | | `cascade` | a step | `fire` (12); then its effects a level at a time, 18 f apart: CPU (`reg`s, the pc's annotation), memory (`slot`s, `bytes`), the idea (the drawing, by `project`); each armed, then struck; hold 36 f after the last strike and 12 f a further value, 84 at most; `advance`; rest 24 f. A level with nothing on screen to change gives up its slot | | `continue` | a stop far from the last: a breakpoint, not a step | `fire` on the line it leaves from; then the levels as in a `cascade`, but CPU is a wave: every register that changed is struck 2 f after the one above it, in pwndbg's order, the fill in over 6 f, no arm and no pulse (a dozen pulses at once are a flash, and a dozen arms a crowd); memory: the stack's window scrolls or fades to its new place, and the [backtrace](#backtrace)'s frames leave, slide and arrive; the idea; hold 36 f after the last strike; `advance`, the source and disassembly fading through if far; rest. Its marks are only on what was on screen to change | @@ -913,8 +1011,9 @@ for a return across three levels, 2.7 s for a swap. **What may contain what.** -- The stage holds the band and two columns; the band is two panels, one - over each column. A column holds panels. A panel holds a tag and rows, +- The stage holds the lens and four columns; the lens is two panels, its + drawing over the first two columns and its view in the third. A column + holds panels. A panel holds a tag and rows, or (a lens) a tag and a drawing. A row holds atoms. Nothing nests deeper. - Every panel shows the same moment. A register from one stop beside a @@ -971,13 +1070,19 @@ for a return across three levels, 2.7 s for a swap. ## The mocks `mock/context.py` draws 9 to 14, one function a block under the block's -name; `mock/gen.py` draws 1 to 8. Each has a `-480.png` beside it. +name; `mock/dense.py` places those blocks on the 4K stage and draws 15 to +18; `mock/gen.py` draws 1 to 8. Look at 15 to 18 at full size: they are the +4K master's pixels. 9 to 14 were drawn on the 1920 stage, before the 4K +one: their blocks and marks are the catalogue's, their layout is not (two +columns; the calls tie from the stack), and the camera at x2 is the +nearest thing to them now. ```sh cd design/mock python3 -B context.py && for n in 09-context 10-context-step 11-context-lens 12-calls-subject \ 13-sqlite-row 14-sqlite-page; do resvg $n.svg $n.png && resvg -w 480 $n.svg $n-480.png; done +python3 -B dense.py && for n in 15-marks 16-none 17-subject 18-loupes; do resvg $n.svg $n.png; done python3 -B gen.py # 1 to 8, then resvg the same way ``` @@ -989,6 +1094,10 @@ python3 -B gen.py # 1 to 8, then resvg the same way | [12](mock/12-calls-subject.png) | `calls` as subject, mid-step: moments 752 to 753 of the fib scene, `fib(4)` calling `fib(2)` | `calls`: nodes current, waiting, done, the caller, results on the shoulder; the `backtrace` as its view, with arguments; `call` spans with arguments; the stack's window from rsp, six slots; a `projection` from the return address to the new node; `insn` with a call and its argument, a write, and operands of 27 characters whole | | [13](mock/13-sqlite-row.png) | the `backtrace` lens, at rest after a `continue`: stop 120 of the sqlite scene, at `sqlite3BtreeInsert+4` | the backtrace as the band's drawing; a `hexdump` by `fields` of a struct on the stack: twelve-digit addresses, pointer fields and `NULL`, `loose` padding and the bytes past the struct, `pad`, two fields framed as the caption names them, the reading as a list; wide line numbers in the source and the disassembly; frame names whole, shortening the chains beside them; `held` on every register the continue changed, none on the stack's window, which faded in | | [14](mock/14-sqlite-page.png) | `syscalls` as subject, at rest after the crossing: stop 169, `pwrite64` back in `unixWrite` | the kernel's side in the band; a page by `fields` as the kernel took it (`given`): big-endian numbers, bytes left to the eye, text, a `more` row of 253; the stack's window scrolled into the frame (`rsp+20 to rsp+48`), its span open above; flags and registers the crossing changed | +| [15](mock/15-marks.png) | the marks sheet: `current`, `struck`, `held` as A (the first videos), B (the catalogue's) and C (a whiter reading), on rows of the list at the load and the store after it | the source's current line; the pc's row; rip; a struck and two held registers; a dump row struck on the one byte that changed and one held; a lens's cell held and struck; the same rows at 1.35 times | +| [16](mock/16-none.png) | `none` on the 4K stage, at rest: `targets/list` stopped at the load in `reverse` (a fresh recording, `mock/list-dbg.txt`) | four columns: 69 lines of source (the file whole), 69 instructions (`reverse` and its neighbours `outside`, under rules and names), the registers, the backtrace, `memory` of the heap by its words, the stack's 69 slots with offsets, roles and the spans of five frames down to the process's start; the thread across its gutter | +| [17](mock/17-subject.png) | `subject` on the 4K stage, mid-step: the load done | the list drawn twice the size over A and B; its view of 32 rows with the fieldless rows folded into `more`; 43 lines and 43 instructions; a link from rdi to its pin and a projection from the view; struck, held and current as B | +| [18](mock/18-loupes.png) | `none` on the 4K stage, mid-step, two loupes open | a `loupe` from rdi floating over the stack's column, its node framed; a second from that node's `next`, deeper, over the first's lower rows; their stems; the read in `memory` by `echo` | | [1](mock/01-fib-recursion.png) | first pass | `calls` at camera scale | | [2](mock/02-list-insert.png) | first pass | `nodes` at camera scale; `allocated` | | [3](mock/03-syscall-write.png) | first pass | `syscalls`; `kernel` | @@ -1016,6 +1125,9 @@ the band. at stop 167, before the kernel took it). - A calls tree small or folded. - `array`, `heap`, `pages` in the band. +- A loupe opened from the stack, the disassembly or a dump; a loupe typed + by `fields`; a third closing the first. +- A local's name as a slot's role (the recording has none at these pcs). - `pin` with a count; `rwx`. - Every verb: the mocks are stills. `establish`, `link` and `project` have no chart from a render yet. @@ -1041,102 +1153,120 @@ still read. ## What this asks of the renderer What the documents say and `anim/src` does not do, as read on 10 November -after the sqlite scene (`theme.zig` as of 18:00, the views as of 20:18); -the tokens are under [Token changes](#token-changes). The first five are -wrong by the language, not merely unnamed. - -1. **A continue's registers strike in a wave** ([`continue`](#6-verbs)): - 2 f apart in pwndbg's order, the fill in over 6 f, no arm, no pulse. - Now every changed register arms on one frame and strikes on one frame - (sqlite, 0 to 8 s and each continue after): fourteen strikes at once. -2. **No marks on what arrived**: a window that faded to a new place, and - a dump that comes in after the step that changed it, show their values - plain. Now the stack's new window comes in struck at each continue, and - the row's dump arrives with a tick on every run. -3. **Far is a window's height**, for every window ([`scroll`](#6-verbs)): - the source (14, 8 or 10 lines), the disassembly (17 or 9), the stack (8 - or 6 slots) scroll when the new place is within their own height and - fade through (12 f out, 12 f in) beyond. Now the stack fades only - beyond 16 words (`context.zig`, `> 16`) and the source beyond two - windows (`source.zig`, `2 * fit`): sixteen rows in 24 f is a blur. -4. **The last stop's rsp pin** (sqlite at 64.6 s, stop 169): the stack's - lane has `rbp rsp` on `7fffffffe7e0`; rsp is `7fffffffe7a0`, above the - window. Only `rbp` is pinned there, and rsp, out of the window, has no - pin. -5. **The crossing's order** (`syscalls.zig` `Plan`): `returns` takes the - value 6 f before the arrow back leaves (`returns = back - 0.10`), rax is - armed while the arrow travels and struck as it lands (`struck = back + - cross`). Now `returns` fills as the arrow lands and rax strikes 0.20 s - after: the answer appears on the kernel's side after it has travelled. -6. **Names the code then follows**: - - `rows.Run.kind.allocator` and `hexdump.Kind.allocator` are `loose`: - any byte of no field (padding, past the struct), the allocator's - words among them; the chunk-size note stays. - - The scene's `split.backtrace = split.band` is the `backtrace` lens: - let the context place it (a lens choice, not a patched split), eleven - rows as subject, five beside. - - `hexdump.Dump`'s `of: Fields` is a dump by `fields`; `seen` and - `given` keep their names. -7. **Measures that change**: - - line numbers' width from the program's largest line - (`rows.numberRoom(rec.line_count)` in `source.zig` and `disasm.zig`), - not the window's; - - a dump's address room once per dump, from the widest address in its - window (`rows.addressRoom` is per row now); - - one reading for every dump, the list a character apart - (`hexdump.reading`, the typed dump's, still ranges numbers in three - characters; let `fieldReading` serve both); - - `fielded` keeps at most 16 rows and draws past the panel when the - rows holding fields outnumber the view's: keep the window round the - rows the step or a mark is on, and fold the others into `more` rows - with their counts; - - the stack's tag names the first and the last word shown, `rsp+20 to - rsp+48`, not the end past them (`rsp+50`); - - a frame's name is cut at 300 units with `…` (now never). -8. **The calls tree** past ten leaves: the small size, and folding past - thirteen leaves or six levels ([`calls`](#calls)). `calls.zig` has the - full size only. -9. **A visit and its ties**: a visit waits for a drawn tie to draw back, - or frames both its ends, before veiling a panel the tie starts or ends - in. `sort` no longer visits; this is the rule for the next scene that - does. +(`theme.zig` as of 21:15); the tokens are under [Token changes](#token-changes). +Last round's `continue` and crossing stand as specified. + +1. **The 4K stage.** The design unit becomes the 4K master's pixel: + `canvas` 3840 by 2160, the stage 3616 by 1688 at (112, 96), the clock at + 1798, the caption band 1824 to 2064. Export at 3840 by 2160 natively + (`ui.scale` maps 1920 units to the scene now); 1440p and 1080p are + downscales of it (lanczos), never renders of their own. +2. **Four columns** (`layout`): source, disassembly, a third column + (registers, backtrace, `memory` or a lens's view), the stack; the + splits as [the frame's table](#5-the-frame): `Split` gains `memory`, + the view moves into the third column, the stack runs the stage's height + (69), `dump_rows` 32. The test "the splits fill the stage" changes with + it; a column's last panel runs to the stage's foot. +3. **The thread across a gutter**: the source and the disassembly are side + by side; the thread's brackets at the source's right edge and the + disassembly's left, its line down x 1008. +4. **Ties in three gutters** ([Routes](#4-ties)): links into the drawing at + 1912, projections from the view at 1924, links to the stack at 2832; a + calls lens's projection leaves the backtrace row (its view), not the + stack's slot. +5. **A lens's drawing twice the size**: nodes, cells, the calls tree, the + kernel's side, their labels, strokes, lanes and flights at twice the + 1920 numbers (`drawing_scale` 2), over the program's two columns. +6. **The slot's columns** ([`slot`](#slot)): pins 10 to 112, the offset + from rsp ranged right to 172, the address from 184, the role ranged + right where the chain's room ends; spans for every frame in view. +7. **The disassembly's window**: 69, 56 or 43 rows with the pc in its middle + third and the neighbouring functions `outside`, plain, under a rule and + their name; fade through beyond the window's height. +8. **`memory`** in `none`, and every dump 32 rows, its rows that hold no + field always folded into `more` (now only when the region is longer + than the window). +9. **Marks** ([`mark`](#mark)): `current` a white wash across the row + (`212644`) and the gold plaque; `struck` on `b54f42` with bright bold + digits (the arm, a projection and the corner stay full vermilion); + `held` a turned corner, a vermilion right triangle 9 on its sides at + the value's top left (12, at the drawing's scale, on a cell). The tick + and the bar go. +10. **`loupe`** ([`loupe`](#loupe)): the block, its placement and its + stems; `open` and `close` ([verbs](#6-verbs)); at most two; the one + elevation in the frame (`lift`, `shade`). +11. **Still from the last round**: the calls tree's small size and folds, + a frame name's 300 units, `time.caption_max` and `time.first_step`. + +**What the recordings must hold** for these, which they do not now: + +- **Code round the pc**: 69 instructions with the pc in the middle third + means about 300 bytes of code before the pc and 300 after; simplest is + the program's text, symbols and line table once per recording, and for + a library 512 bytes either side of each pc in it, with its symbols. +- **The stack**: 69 words from rsp, 552 bytes, at every stop; with the + window's scroll down a long frame and `free` slots under the camera, + from rsp − 128 to rsp + 1024 (or the stack's top). The sqlite scene + records 512, `ztrace record`'s default is 128. +- **Round a loupe's target**: 80 bytes before and 80 after every chased + target the recording does not already watch (the recorded stack, the + tracked heap), clipped to its mapping: 160 where 32 are recorded today. +- **For the slot's roles**: the call frame information at each frame's pc + (which registers its prologue saved, where); the debug info's locals at + each frame's pc (name, and where: a frame offset or a location list); + the process's first stack pointer (argc, argv, envp, auxv sit at it). + Saved rbp and return addresses come from the frame chain, which the + recording has. +- **`memory`**: the 512 bytes round what a step reads or writes; the heap + is watched already, unwatched memory needs the 160 above at least. ## Token changes -Against `anim/src/theme.zig` as it is now (18:00): "In theme.zig" is what -is in the file, "Is" what the documents say. Numbers a view keeps for -itself (`calls.zig`'s `metric`, `stage.zig`'s fade) belong here too. +Against `anim/src/theme.zig` as it is now (21:15): "In theme.zig" is what +is in the file, "Is" what the documents say. | Token | In theme.zig | Is | | --- | --- | --- | -| `metric.insn.operand_chars`, `annotation_chars` | 24, 25 | removed: operands whole, the row 50 characters from 264 | -| `metric.bytes.first` | 132 | 132 at least, and 12 after the address's end (`address_gap` 12): 174 for twelve digits | -| `metric.bytes.reading` | 640 | 508 after the first byte: 640, or 682 for twelve digits | -| `metric.context.line_number_end`, `line_text`, `metric.plaque.line` | 46, 64, 50 | each plus 12 a digit past three, by the program's largest line number | -| `metric.calls` | none (`calls.zig`: radius 24, level 46, badge 30, caller 64 by 28) | full: disc 48, level 46, badge 30 at 12 right and 42 up, mono 25, a leaf 72; small: disc 36, level 38, root 60 under the tag, badge 24 at 6 right and 32 up, mono 20, a leaf 54; small past 10 leaves or 5 levels, folding past 13 or 6; a fold's count in faint mono 20 | -| `metric.span.name_max` | none | 300 | -| `time.continue_wave` | none | 2 f (`stagger`) between registers; fill 0.10; no arm, no pulse | -| `time.far` | none (16 words; two windows) | a window's own height; out 0.20, in 0.20 | -| `time.relayout_fade` | none (`stage.zig`: 12 f) | 0.20 before the move and after | -| `time.pin` | none | `after` 0.30; `node` 0.50, `nodes` 0.60; `row` 0.40 and `step_per_row` a further row, 0.60 at most; `in`, `out`, `names` 0.20 | -| syscalls `Plan.returns`, `struck` | `back + cross`, `returns + strike.arm` | `back - 0.10`, `back + cross` | -| `time.caption_max` | none | 12.00 | -| `time.first_step` | none | 4.00 at the latest | - -Unchanged and already there: the palette, region inks, the type sizes, -`layout.split` (the band as drawing and view; subject 296 and 200, nine -instructions, six slots), `metric.slot`, `metric.pin`, `metric.node`, -`metric.tie`, `stroke.tie`, `color.veil_alpha`, `time.veil`, -`time.strike`, `time.link`, `time.project` (with `far` 0.50), -`time.flight`, `time.caption`, `caption_lead`, `caption_lead_first`, -`time.establish` (the first caption at 1.0 s), `establish_rise`, -`time.run`, `sprint`, `ramp`, the camera's scales. +| `canvas.width`, `height` | 1920, 1080 | 3840, 2160 | +| `canvas.margin_x`, `margin_y` | 64, 48 | 112, 96 | +| `canvas.columns`, `column`, `gutter` | 12 of 120, gutters 32 | 4 of 880, gutters 32 | +| `canvas.stage` | 64, 48, 1792 by 840 | 112, 96, 3616 by 1688 | +| `canvas.clock_y` | 900 | 1798 (the rule 4, the gold 8) | +| `canvas.caption`, `caption_baseline`, `caption_max_width` | 64, 912, 1792 by 120; 990, 964, 1018; 1400 | 112, 1824, 3616 by 240; 1980, 1928, 2036; 2800 | +| `layout.program`, `state` | two columns of 880 | four: `source` 112, `disasm` 1024, `third` 1936, `stack` 2848 | +| `layout.Split` | band, view, source, disasm, registers, stack, backtrace, `dump_rows` | the same and `memory`; the view in the third column; `dump_rows` 32 | +| `layout.split.none` | source 14, disasm 17; registers, stack 8, backtrace 4 | source 69, disasm 69; registers, backtrace 16, `memory` 32; stack 69 | +| `layout.split.beside` | drawing 152 by 880, view 152 (5); source 8, disasm 17; registers at 212, stack 8 | drawing 300 by 1792; view 32 at 96; source 56, disasm 56; registers at 908, backtrace 16; stack 69 | +| `layout.split.subject` | drawing 296, view 200 (7); source 10, disasm 9; registers at 260, stack 6 | drawing 604 by 1792; view 32; source 43, disasm 43; registers at 908, backtrace 16; stack 69 | +| `size.sans.caption`, `caption_leading` | 40, 54 | 80, 108 | +| `size.mono.value` (code in a caption) | 35 | 70 | +| a lens's drawing | `metric.node`, `calls`, the array's cells at their sizes | the same numbers, drawn at `drawing_scale` 2 | +| the clock's count | mono 20 | mono 40 | +| `stroke.tie` | thread 3, link 3, projection 2 | 4, 4, 3 | +| `metric.tie` | `thread_x` 54, lanes 950 and 962 | `thread_x` 1008; lanes 1912 (link), 1924 (projection), 2832 (to the stack) | +| `metric.slot` | lane 10 to 112, chain 122, room 136 | lane 10 to 112, `offset` ranged right to 172, `address` 184, the role ranged right at the room's end | +| `mark(.current)` | ember `4a3d1c` across the row | `color.wash` `212644` across the row; the plaque stays gold | +| `mark(.write)`, a strike's paper | `ff6a4a`, digits in ink | `b54f42`, digits bright; `ff6a4a` stays for the arm, a projection and the corner | +| `held` | a tick 4 wide (`metric.context.tick`); a bar 4 high (`metric.ember_bar`) | a turned corner, 9; on a cell 12 | +| `color.lift`, `lift_tag`, `shade` | none | `121c52`, `22317a`, `02061a` | +| `metric.loupe` | none | 880 wide, 9 rows; shadow 12 right and 16 down, 20 and 26 for a deeper one; a deeper one 120 to the right; stem 4, head 12 | +| `time.loupe` | none | `read` 0.10; `stem` 0.30 (0.50 over 600 units); `rise` 0.20, shadow 0.30; `frame` after 0.10; `close` 0.20 | +| `camera.scales` | 1, 1.5, 2, 4 | the same; at x2 the frame is 1920 by 1080 of the 4K stage | +| from the last round | | `metric.calls` small (36, 38, badge 24) and folds; `metric.span.name_max` 300; `time.caption_max` 12.00; `time.first_step` 4.00 | + +Unchanged and already there: the palette but for the marks above, region +inks, the context's type sizes (mono 20, rows 24, tags 24, padding 4), +`metric.bytes`, `metric.pin`, `metric.node` and `metric.calls` (drawn +twice), `color.veil_alpha`, `time.veil`, `time.strike`, `time.link`, +`time.project`, `time.pin`, `time.continue_wave`, `time.relayout_fade`, +`time.flight`, `time.caption`, `caption_lead`, `time.run`, `sprint`, +`ramp`. ## Building it 1. Atoms: `address` (unbroken, `lead`), `arrow`, `value`, `mark`, `pin`, `bracket`. The gallery starts here. -2. `chain`, then `reg` and `slot`: the state column at rest. +2. `chain`, then `reg` and `slot`: the registers and the stack at rest. 3. `insn` with its columns and annotations; `line`; `thread`. 4. `bytes` and `hexdump`; `nodes` in the band; quiet brackets. 5. `strike`, `cool`, `read`, `extend` at density; the `cascade`. @@ -1147,8 +1277,11 @@ instructions, six slots), `metric.slot`, `metric.pin`, `metric.node`, Export: ```sh -canim --export - --size 3840x2160 --fps 60 --frames N | +canim --export - --size 3840x2160 --fps 60 --frames N | # the 4K stage's own pixels ffmpeg -f rawvideo -pix_fmt rgba -s 3840x2160 -r 60 -i - \ -c:v libx264 -crf 14 -preset slow -pix_fmt yuv420p \ -g 600 -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range tv out.mp4 ``` + +1440p and 1080p are the master downscaled, never rendered at their own +size: `ffmpeg -i out.mp4 -vf scale=2560:1440:flags=lanczos …`. diff --git a/design/mock/09-context-480.png b/design/mock/09-context-480.png index 3d4975a..099116b 100644 Binary files a/design/mock/09-context-480.png and b/design/mock/09-context-480.png differ diff --git a/design/mock/09-context.png b/design/mock/09-context.png index 6be6c29..b1f6003 100644 Binary files a/design/mock/09-context.png and b/design/mock/09-context.png differ diff --git a/design/mock/09-context.svg b/design/mock/09-context.svg index a175fcc..828a9ce 100644 --- a/design/mock/09-context.svg +++ b/design/mock/09-context.svg @@ -21,7 +21,7 @@ head ) { - + 21 struct @@ -109,7 +109,7 @@ 4 - + 10019 @@ -180,7 +180,7 @@ read-only rax - + 28b41090 @@ -188,7 +188,7 @@ rbx 0 rcx - + 28b410b0 @@ -201,7 +201,7 @@ 0 rdi - + 28b41090 @@ -276,22 +276,22 @@ 1 - + rip 1001926 reverse+22 -cf +cf PF -af - -zf -sf +af + +zf +sf IF -df -of +df +of @@ -514,7 +514,7 @@ 00 00 - + 00 00 00 @@ -532,7 +532,7 @@ 1 - + diff --git a/design/mock/10-context-step-480.png b/design/mock/10-context-step-480.png index 7bbfa65..4a9c7e1 100644 Binary files a/design/mock/10-context-step-480.png and b/design/mock/10-context-step-480.png differ diff --git a/design/mock/10-context-step.png b/design/mock/10-context-step.png index fa9086b..244c65b 100644 Binary files a/design/mock/10-context-step.png and b/design/mock/10-context-step.png differ diff --git a/design/mock/10-context-step.svg b/design/mock/10-context-step.svg index 3cd8c76..09baba3 100644 --- a/design/mock/10-context-step.svg +++ b/design/mock/10-context-step.svg @@ -21,7 +21,7 @@ head ) { - + 21 struct @@ -109,7 +109,7 @@ 4 - + 10019 @@ -181,7 +181,7 @@ read-only rax - + 28b41090 @@ -189,7 +189,7 @@ rbx 0 rcx - + 28b410b0 @@ -202,8 +202,8 @@ 0 rdi - -28b41070 + +28b41070 9 @@ -277,22 +277,22 @@ 1 - + rip 1001926 reverse+22 -cf +cf PF -af - -zf -sf +af + +zf +sf IF -df -of +df +of @@ -513,7 +513,7 @@ 00 00 - + 00 00 00 @@ -531,7 +531,7 @@ 1 - + diff --git a/design/mock/11-context-lens-480.png b/design/mock/11-context-lens-480.png index 318735d..9e76b53 100644 Binary files a/design/mock/11-context-lens-480.png and b/design/mock/11-context-lens-480.png differ diff --git a/design/mock/11-context-lens.png b/design/mock/11-context-lens.png index 78d0779..6e5e6fe 100644 Binary files a/design/mock/11-context-lens.png and b/design/mock/11-context-lens.png differ diff --git a/design/mock/11-context-lens.svg b/design/mock/11-context-lens.svg index f5582e3..a7dcea0 100644 --- a/design/mock/11-context-lens.svg +++ b/design/mock/11-context-lens.svg @@ -37,7 +37,7 @@ head ) { - + 21 struct @@ -111,7 +111,7 @@ 4 - + 10019 @@ -168,7 +168,7 @@ read-only rax - + 28b41090 @@ -176,7 +176,7 @@ rbx 0 rcx - + 28b410b0 @@ -189,8 +189,8 @@ 0 rdi - -28b41070 + +28b41070 9 @@ -264,22 +264,22 @@ 1 - + rip 1001926 reverse+22 -cf +cf PF -af - -zf -sf +af + +zf +sf IF -df -of +df +of @@ -534,7 +534,7 @@ 00 00 - + 00 00 00 @@ -552,7 +552,7 @@ 1 - + diff --git a/design/mock/12-calls-subject-480.png b/design/mock/12-calls-subject-480.png index d53389e..0cde337 100644 Binary files a/design/mock/12-calls-subject-480.png and b/design/mock/12-calls-subject-480.png differ diff --git a/design/mock/12-calls-subject.png b/design/mock/12-calls-subject.png index 5ce57a1..7ab5d52 100644 Binary files a/design/mock/12-calls-subject.png and b/design/mock/12-calls-subject.png differ diff --git a/design/mock/12-calls-subject.svg b/design/mock/12-calls-subject.svg index 36d11c1..6dd15d6 100644 --- a/design/mock/12-calls-subject.svg +++ b/design/mock/12-calls-subject.svg @@ -27,7 +27,7 @@ return n ; - + 6 return @@ -109,7 +109,7 @@ rdi, 2 rdi 2 - + 10133 @@ -180,7 +180,7 @@ "./steps" rdi 2 - + rbp 7fffffffeda0 @@ -196,8 +196,8 @@ 0 rsp - -7fffffffed78 + +7fffffffed78 10133ab @@ -223,20 +223,20 @@ main+0 r15 1 - + rip 10133a6 fib+54 -cf -pf -af -zf -sf +cf +pf +af +zf +sf IF -df -of +df +of @@ -248,8 +248,8 @@ 78 - -10133ab + +10133ab fib+59 7fffffffed 80 @@ -260,7 +260,7 @@ 88 - + 2 7fffffffed 90 @@ -300,7 +300,7 @@ backtrace the calls waiting · newest on top - + #0 fib+0 diff --git a/design/mock/13-sqlite-row-480.png b/design/mock/13-sqlite-row-480.png index 33f2486..db957cc 100644 Binary files a/design/mock/13-sqlite-row-480.png and b/design/mock/13-sqlite-row-480.png differ diff --git a/design/mock/13-sqlite-row.png b/design/mock/13-sqlite-row.png index 4d6a377..e372f2f 100644 Binary files a/design/mock/13-sqlite-row.png and b/design/mock/13-sqlite-row.png differ diff --git a/design/mock/13-sqlite-row.svg b/design/mock/13-sqlite-row.svg index 7161b31..92d1ec0 100644 --- a/design/mock/13-sqlite-row.svg +++ b/design/mock/13-sqlite-row.svg @@ -37,7 +37,7 @@ seekResult /* Result of prior IndexMoveto … - + 80895 ) @@ -78,7 +78,7 @@ 81 mov rbp, rsp - + 448d @@ -121,35 +121,35 @@ read-only rax - + 5226d0 0 rbx 1 - + rcx 0 - + rdx 8 - + rsi - + 7fffffffea60 0 rdi - + 521978 0x101 257 rbp - + 7fffffffe980 @@ -166,7 +166,7 @@ rsp - + 7fffffffe980 @@ -185,49 +185,49 @@ r8 0x38 56 - + r9 0 - + r10 7 - + r11 0xffffffff - + r12 0 r13 - + 5222d0 0x39fb80 r14 - + 5218f8 0x40100010000 r15 0 - - + + rip 448d84 sqlite3BtreeInsert+4 -cf - -pf -af - -zf -sf +cf + +pf +af + +zf +sf IF -df -of +df +of @@ -314,7 +314,7 @@ backtrace newest on top - + #0 sqlite3BtreeInsert+4 diff --git a/design/mock/14-sqlite-page-480.png b/design/mock/14-sqlite-page-480.png index 9024f82..35a7d2f 100644 Binary files a/design/mock/14-sqlite-page-480.png and b/design/mock/14-sqlite-page-480.png differ diff --git a/design/mock/14-sqlite-page.png b/design/mock/14-sqlite-page.png index c014899..695138d 100644 Binary files a/design/mock/14-sqlite-page.png and b/design/mock/14-sqlite-page.png differ diff --git a/design/mock/14-sqlite-page.svg b/design/mock/14-sqlite-page.svg index 7bcee25..d67cbac 100644 --- a/design/mock/14-sqlite-page.svg +++ b/design/mock/14-sqlite-page.svg @@ -22,7 +22,7 @@ ( USE_PREAD ) - + 42290 do @@ -125,7 +125,7 @@ 4b call qword ptr [rip + 0xf1567] - + 4220 @@ -162,29 +162,29 @@ rax 0x1000 4096 - + rbx 3 - + rcx - + 7ffff7cf1a7d __pwrite64+173 rdx 0x1000 4096 - + rsi - + 538b28 0xe60f030000000d rdi 3 - + rbp - + 7fffffffe7e0 @@ -201,30 +201,30 @@ rsp - + 7fffffffe7a0 0 r8 0 - + r9 0 r10 0x1000 4096 - + r11 0x246 582 - + r12 0x1000 4096 - + r13 - + 538b28 @@ -232,31 +232,31 @@ r14 0x1000 4096 - + r15 - + 538b28 0xe60f030000000d - + rip 422051 unixWrite+65 - + CF - + PF -af -zf -sf +af +zf +sf IF -df -of +df +of @@ -266,13 +266,13 @@ c0 - + 0 7fffffffe7 c8 - + 538b28 @@ -281,7 +281,7 @@ d0 - + 517e38 @@ -293,7 +293,7 @@ d8 - + 2 rbp diff --git a/design/mock/15-marks-480.png b/design/mock/15-marks-480.png new file mode 100644 index 0000000..ad7f92c Binary files /dev/null and b/design/mock/15-marks-480.png differ diff --git a/design/mock/15-marks.png b/design/mock/15-marks.png new file mode 100644 index 0000000..a295ec1 Binary files /dev/null and b/design/mock/15-marks.png differ diff --git a/design/mock/15-marks.svg b/design/mock/15-marks.svg new file mode 100644 index 0000000..32d55db --- /dev/null +++ b/design/mock/15-marks.svg @@ -0,0 +1,1027 @@ + + + +current, struck, held +Rows of targets/list at the load in reverse (moment 3) and the store after it (moment 4), at the 4K stage's density: mono 20, rows of 24. Look at it at full size. +A +the first videos: gold band, solid vermilion, a tick + + + +list.c +lines 18 to 23 of 42 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; + + + +disassembly +reverse +10019 +19 +20 +xor +eax, eax +10019 +1b +nop +dword ptr [rax + rax] +10019 +20 +mov +rcx, rax + +10019 +23 +mov +rax, rdi + + + +10019 +26 +21 +mov +rdi, qword ptr [rdi + 8] + +1004098 + + +1004070 + + +9 +10019 +2a +22 +mov +qword ptr [rax + 8], rcx +10019 +2e +20 +test +rdi, rdi + + + +registers +rax + +1004090 + + +4 +rcx + +10040b0 + + +1 +rsi +10040c0 + + +0 +rdi + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 + + +rip +1001926 +reverse+22 + + + +its bytes +moment 4: the store, struck; 10040b8, held + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +b0 +40 +00 +01 +00 +00 +00 +00 + + +10040b0 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + +b0 + +in a lens's cell, twice the size + + + +4 + +held + + + +4 + +struck +the same, 1.35 times + + + + +list.c +lines 19 to 21 of 42 +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; + + + +registers +rax + +1004090 + + +4 +rdi + +1004070 + + +9 + + +rip +1001926 +reverse+22 +rcx + +10040b0 + + +1 + +B +recommended: a white wash, a softened strike, a turned corner + + + +list.c +lines 18 to 23 of 42 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; + + + +disassembly +reverse +10019 +19 +20 +xor +eax, eax +10019 +1b +nop +dword ptr [rax + rax] +10019 +20 +mov +rcx, rax + +10019 +23 +mov +rax, rdi + + + +10019 +26 +21 +mov +rdi, qword ptr [rdi + 8] + +1004098 + + +1004070 + + +9 +10019 +2a +22 +mov +qword ptr [rax + 8], rcx +10019 +2e +20 +test +rdi, rdi + + + +registers +rax + +1004090 + + +4 +rcx + +10040b0 + + +1 +rsi +10040c0 + + +0 +rdi + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 + + +rip +1001926 +reverse+22 + + + +its bytes +moment 4: the store, struck; 10040b8, held + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +b0 +40 +00 +01 +00 +00 +00 +00 + + +10040b0 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + +b0 + +in a lens's cell, twice the size + + + +4 + +held + + + +4 + +struck +the same, 1.35 times + + + + +list.c +lines 19 to 21 of 42 +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; + + + +registers +rax + +1004090 + + +4 +rdi + +1004070 + + +9 + + +rip +1001926 +reverse+22 +rcx + +10040b0 + + +1 + +C +white: a white plaque, a white strike framed in vermilion, a bar under + + + +list.c +lines 18 to 23 of 42 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; + + + +disassembly +reverse +10019 +19 +20 +xor +eax, eax +10019 +1b +nop +dword ptr [rax + rax] +10019 +20 +mov +rcx, rax + +10019 +23 +mov +rax, rdi + + + +10019 +26 +21 +mov +rdi, qword ptr [rdi + 8] + +1004098 + + +1004070 + + +9 +10019 +2a +22 +mov +qword ptr [rax + 8], rcx +10019 +2e +20 +test +rdi, rdi + + + +registers +rax + +1004090 + + +4 +rcx + +10040b0 + + +1 +rsi +10040c0 + + +0 +rdi + + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 + + +rip +1001926 +reverse+22 + + + +its bytes +moment 4: the store, struck; 10040b8, held + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +b0 +40 +00 +01 +00 +00 +00 +00 + + +10040b0 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + +b0 + +in a lens's cell, twice the size + + + +4 + +held + + + + +4 + +struck +the same, 1.35 times + + + + +list.c +lines 19 to 21 of 42 +19 +struct +node +* +prev += +NULL +; + +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; + + + +registers +rax + +1004090 + + +4 +rdi + + +1004070 + + +9 + + +rip +1001926 +reverse+22 +rcx + +10040b0 + + +1 + + diff --git a/design/mock/16-none-480.png b/design/mock/16-none-480.png new file mode 100644 index 0000000..e85cc62 Binary files /dev/null and b/design/mock/16-none-480.png differ diff --git a/design/mock/16-none.png b/design/mock/16-none.png new file mode 100644 index 0000000..68b7049 Binary files /dev/null and b/design/mock/16-none.png differ diff --git a/design/mock/16-none.svg b/design/mock/16-none.svg new file mode 100644 index 0000000..4b89733 --- /dev/null +++ b/design/mock/16-none.svg @@ -0,0 +1,1641 @@ + + + + + + +list.c +lines 1 to 42 of 42 +1 +// A linked list on the heap: built, reversed, summed. `list_done` +2 +// finished list, the place for a tracer to look at it. +3 +#include +<stdio.h> +4 +#include +<stdlib.h> +5 +6 +struct +node +{ +7 +long +value +; +8 +struct +node +* +next +; +9 +} +; +10 +11 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +push +( +struct +node +* +he +… +12 +struct +node +* +n += +malloc +( +sizeof +* +n +) +; +13 +n +- +> +value += +value +; +14 +n +- +> +next += +head +; +15 +return +n +; +16 +} +17 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; +24 +head += +next +; +25 +} +26 +return +prev +; +27 +} +28 +29 +__attribute__ +( +( +noinline +) +) +long +list_done +( +struct +node +* +head +) +{ +30 +long +sum += +0 +; +31 +for +( +; +head +; +head += +head +- +> +next +) +sum ++ += +head +- +> +value +; +32 +return +sum +; +33 +} +34 +35 +int +main +( +int +argc +, +char +* +* +argv +) +{ +36 +int +n += +argc +> +1 +? +atoi +( +argv +[ +1 +] +) +: +6 +; +37 +struct +node +* +head += +NULL +; +38 +for +( +int +i += +n +; +i +> += +1 +; +i +- +- +) +head += +push +( +head +, +i +* +i +) +; +39 +head += +reverse +( +head +) +; +40 +printf +( +"sum = %ld\n" +, +list_done +( +head +) +) +; +41 +return +0 +; +42 +} +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 + + + +disassembly +reverse + +1001 +8a8 +39 +mov +rdi, rax +main +1001 +8ab +call +1001910 +1001 +8b0 +40 +mov +rdi, rax +1001 +8b3 +call +1001830 +1001 +8b8 +lea +rdi, [rip - 0x12cb] +1001 +8bf +mov +rsi, rax +1001 +8c2 +xor +eax, eax +1001 +8c4 +call +1001990 +printf +1001 +8c9 +41 +xor +eax, eax +1001 +8cb +add +rsp, 8 +1001 +8cf +pop +rbx +1001 +8d0 +pop +rbp +1001 +8d1 +ret +1001 +8d2 +nop +word ptr cs:[rax + rax] + +1001 +8e0 +11 +push +rbp +push +1001 +8e1 +mov +rbp, rsp +1001 +8e4 +push +r14 +1001 +8e6 +push +rbx +1001 +8e7 +mov +rbx, rsi +1001 +8ea +mov +r14, rdi +1001 +8ed +12 +mov +edi, 0x10 +1001 +8f2 +call +10019a0 +malloc +1001 +8f7 +13 +mov +qword ptr [rax], rbx +1001 +8fa +14 +mov +qword ptr [rax + 8], r14 +1001 +8fe +15 +pop +rbx +1001 +8ff +pop +r14 +1001 +901 +pop +rbp +1001 +902 +ret +1001 +903 +nop +word ptr cs:[rax + rax] +1001 +910 +20 +test +rdi, rdi +1001 +913 +je +1001935 +1001 +915 +push +rbp +1001 +916 +mov +rbp, rsp +1001 +919 +xor +eax, eax +1001 +91b +nop +dword ptr [rax + rax] +1001 +920 +mov +rcx, rax +1001 +923 +mov +rax, rdi + + + +1001 +926 +21 +mov +rdi, qword ptr [rdi + 8] +1004098 + + +1004070 + + +9 +1001 +92a +22 +mov +qword ptr [rax + 8], rcx +1001 +92e +20 +test +rdi, rdi +1001 +931 +jne +1001920 +1001 +933 +pop +rbp +1001 +934 +26 +ret +1001 +935 +xor +eax, eax +1001 +937 +ret + +1001 +938 +endbr64 +_init +1001 +93c +sub +rsp, 8 +1001 +940 +mov +rax, qword ptr [rip + 0x1231] +1001 +947 +test +rax, rax +1001 +94a +je +100194e +1001 +94c +call +rax +1001 +94e +add +rsp, 8 +1001 +952 +ret + +1001 +954 +endbr64 +_fini +1001 +958 +sub +rsp, 8 +1001 +95c +add +rsp, 8 +1001 +960 +ret + +1001 +970 +push +qword ptr [rip + 0x1222] +strtol@plt-0x10 +1001 +976 +jmp +qword ptr [rip + 0x1224] +1001 +97c +nop +dword ptr [rax] + +1001 +980 +jmp +qword ptr [rip + 0x1222] +strtol@plt +1001 +986 +push +0 +1001 +98b +jmp +1001970 + +1001 +990 +jmp +qword ptr [rip + 0x121a] +printf@plt +1001 +996 +push +1 +1001 +99b +jmp +1001970 + +1001 +9a0 +jmp +qword ptr [rip + 0x1212] +malloc@plt +1001 +9a6 +push +2 +1001 +9ab +jmp +1001970 + + + + + + + + + + + + +registers +stack +heap +code +data +rwx + +read-only +rax + +1004090 + + +4 +rbx +0 +rcx + +10040b0 + + +1 +rdx +0 +rsi +10040c0 + + +0 +rdi + +1004090 + + +4 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +r8 +7ffff7e19ac0 +r9 +0x20 +32 +r10 +0x10 +16 +r11 +7ffff7e19ac8 +r12 +7fffffffee38 + + +7fffffffefea + + +"./list" +r13 +1 +r14 +7ffff7ffd000 + + +7ffff7ffe3c0 + + +0 +r15 +10029c0 + + +1 + + +rip +1001926 +reverse+22 +cf + +PF +af +zf +sf + +IF +df +of + + + +backtrace +newest on top + + +#0 +reverse+22 +list.c:21 +#1 +main+80 +list.c:40 +#2 +libc+27781 +#3 +__libc_start_main+137 +#4 +_start+37 + + + +memory +the heap, round what the step reads + + + +10040 +00 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +10 + +24 +00 +00 +00 +00 +00 +00 +00 +36 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +20 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +30 + +19 +00 +00 +00 +00 +00 +00 +00 +25 + +10 +40 +00 +01 +00 +00 +00 +00 + + +1004010 + + + +10040 +40 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +50 + +10 +00 +00 +00 +00 +00 +00 +00 +16 + +30 +40 +00 +01 +00 +00 +00 +00 + + +1004030 + + + +10040 +60 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +70 + +09 +00 +00 +00 +00 +00 +00 +00 +9 + +50 +40 +00 +01 +00 +00 +00 +00 + + +1004050 + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +70 +40 +00 +01 +00 +00 +00 +00 + + +1004070 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +c0 +00 +00 +00 +00 +00 +00 +00 +00 +41 +0f +02 +00 +00 +00 +00 +00 +malloc's: the top chunk + + + + + +19 rows + + + +stack +69 words from rsp · the frames they belong to +rbp rsp + ++0 +saved rbp +7fffffffe +ce0 + + +7fffffffed00 + + + + + ++8 +7fffffffe +ce8 + + +10018b0 +main+80 ++10 +7fffffffe +cf0 + + +7ffff7e20de8 ++18 +saved rbx +7fffffffe +cf8 + + +0 ++20 +saved rbp +7fffffffe +d00 + + +7fffffffedb0 + + + + + ++28 +7fffffffe +d08 + + +7ffff7c27781 +libc+27781 ++30 +7fffffffe +d10 + + +7ffff7fe0c60 +ld.so+22c60 ++38 +7fffffffe +d18 + + +7fffffffee38 + + +7fffffffefea + + +".… ++40 +7fffffffe +d20 + + +0x1f7fbe000 ++48 +7fffffffe +d28 + + +1001860 +main+0 ++50 +7fffffffe +d30 + + +7fffffffed70 + + + + + ++58 +7fffffffe +d38 + + + + + ++60 +7fffffffe +d40 + + +0 ++68 +7fffffffe +d48 + + +0x1fe335fc95a5781c ++70 +7fffffffe +d50 + + +7fffffffee38 + + +7fffffffefea + + +".… ++78 +7fffffffe +d58 + + +1 ++80 +7fffffffe +d60 + + +7ffff7ffd000 ++88 +7fffffffe +d68 + + +10029c0 ++90 +7fffffffe +d70 + + +0x1fe335fc94e5781c ++98 +7fffffffe +d78 + + +0x1fe32587a0af781c ++a0 +7fffffffe +d80 + + +0x7fff00000000 ++a8 +7fffffffe +d88 + + +0 ++b0 +7fffffffe +d90 + + +0 ++b8 +7fffffffe +d98 + + +0 ++c0 +7fffffffe +da0 + + +7fffffffee38 + + +7fffffffefea + + +".… ++c8 +7fffffffe +da8 + + +0x15f6f7c6b8dafb00 ++d0 +saved rbp +7fffffffe +db0 + + +7fffffffee10 + + +0 ++d8 +7fffffffe +db8 + + + + + ++e0 +7fffffffe +dc0 + + +7fffffffee48 + + +0 ++e8 +7fffffffe +dc8 + + +10029c0 ++f0 +7fffffffe +dd0 + + +1001860 +main+0 ++f8 +7fffffffe +dd8 + + +7fffffffee48 + + +0 ++100 +7fffffffe +de0 + + +0 ++108 +7fffffffe +de8 + + +0 ++110 +7fffffffe +df0 + + +1001730 +_start+0 ++118 +7fffffffe +df8 + + +7fffffffee30 + + +1 ++120 +7fffffffe +e00 + + +0 ++128 +7fffffffe +e08 + + +0 ++130 +saved rbp +7fffffffe +e10 + + +0 ++138 +7fffffffe +e18 + + +1001755 +_start+37 ++140 +7fffffffe +e20 + + +7fffffffee28 + + +0x38 +56 ++148 +7fffffffe +e28 + + +0x38 +56 ++150 +argc +7fffffffe +e30 + + +1 ++158 +argv[0] +7fffffffe +e38 + + +7fffffffefea + + +"./list" ++160 +argv end +7fffffffe +e40 + + +0 ++168 +envp end +7fffffffe +e48 + + +0 ++170 +auxv +7fffffffe +e50 + + +0x21 +33 ++178 +7fffffffe +e58 + + +7ffff7fbc000 +vdso+0 ++180 +7fffffffe +e60 + + +0x33 +51 ++188 +7fffffffe +e68 + + +0xe30 +3632 ++190 +7fffffffe +e70 + + +0x10 +16 ++198 +7fffffffe +e78 + + +0xbfebfbff ++1a0 +7fffffffe +e80 + + +6 ++1a8 +7fffffffe +e88 + + +0x1000 +4096 ++1b0 +7fffffffe +e90 + + +0x11 +17 ++1b8 +7fffffffe +e98 + + +0x64 +100 ++1c0 +7fffffffe +ea0 + + +3 ++1c8 +7fffffffe +ea8 + + +1000040 ++1d0 +7fffffffe +eb0 + + +4 ++1d8 +7fffffffe +eb8 + + +0x38 +56 ++1e0 +7fffffffe +ec0 + + +5 ++1e8 +7fffffffe +ec8 + + +0xb +11 ++1f0 +7fffffffe +ed0 + + +7 ++1f8 +7fffffffe +ed8 + + +0x7ffff7fbe000 ++200 +7fffffffe +ee0 + + +8 ++208 +7fffffffe +ee8 + + +0 ++210 +7fffffffe +ef0 + + +9 ++218 +7fffffffe +ef8 + + +1001730 +_start+0 ++220 +7fffffffe +f00 + + +0xb +11 + + + +reverse + + + +main + + + +libc+27781 + + + +__libc_start_main + + +_start + + +moment 2 of 4 +Stopped in reverse, about to load head->next. +rdi points at a node; the word after its value is the next node. + diff --git a/design/mock/17-subject-480.png b/design/mock/17-subject-480.png new file mode 100644 index 0000000..daca488 Binary files /dev/null and b/design/mock/17-subject-480.png differ diff --git a/design/mock/17-subject.png b/design/mock/17-subject.png new file mode 100644 index 0000000..d1bb0cc Binary files /dev/null and b/design/mock/17-subject.png differ diff --git a/design/mock/17-subject.svg b/design/mock/17-subject.svg new file mode 100644 index 0000000..fd9459e --- /dev/null +++ b/design/mock/17-subject.svg @@ -0,0 +1,1562 @@ + + + + + + +its bytes +the heap, 1004000 to 10041ff + + + +10040 +00 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +10 + +24 +00 +00 +00 +00 +00 +00 +00 +36 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +20 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +30 + +19 +00 +00 +00 +00 +00 +00 +00 +25 + +10 +40 +00 +01 +00 +00 +00 +00 + + +1004010 + + + +10040 +40 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +50 + +10 +00 +00 +00 +00 +00 +00 +00 +16 + +30 +40 +00 +01 +00 +00 +00 +00 + + +1004030 + + + +10040 +60 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +70 + +09 +00 +00 +00 +00 +00 +00 +00 +9 + +50 +40 +00 +01 +00 +00 +00 +00 + + +1004050 + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + + +70 +40 +00 +01 +00 +00 +00 +00 + + +1004070 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +c0 +00 +00 +00 +00 +00 +00 +00 +00 +41 +0f +02 +00 +00 +00 +00 +00 +malloc's: the top chunk + + + + + +19 rows + + + +registers +stack +heap +code +data +rwx + +read-only +rax + +1004090 + + +4 +rbx +0 +rcx + +10040b0 + + +1 +rdx +0 +rsi +10040c0 + + +0 +rdi + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +r8 +7ffff7e19ac0 +r9 +0x20 +32 +r10 +0x10 +16 +r11 +7ffff7e19ac8 +r12 +7fffffffee38 + + +7fffffffefea + + +"./list" +r13 +1 +r14 +7ffff7ffd000 + + +7ffff7ffe3c0 + + +0 +r15 +10029c0 + + +1 + + +rip +1001926 +reverse+22 +cf + +PF +af +zf +sf + +IF +df +of + + + +backtrace +newest on top + + +#0 +reverse+22 +list.c:21 +#1 +main+80 +list.c:40 +#2 +libc+27781 +#3 +__libc_start_main+137 +#4 +_start+37 + + + +the list +10040b0 + +1 + + + + + +rcx +1004090 + +4 + + + + + + + +rax +1004070 + +9 + + + + + + +rdi +1004050 + +16 + + + + +1004030 + +25 + + + + +1004010 + +36 + + + + + + + + + + + + +list.c +lines 1 to 42 of 42 +1 +// A linked list on the heap: built, reversed, summed. `list_done` +2 +// finished list, the place for a tracer to look at it. +3 +#include +<stdio.h> +4 +#include +<stdlib.h> +5 +6 +struct +node +{ +7 +long +value +; +8 +struct +node +* +next +; +9 +} +; +10 +11 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +push +( +struct +node +* +he +… +12 +struct +node +* +n += +malloc +( +sizeof +* +n +) +; +13 +n +- +> +value += +value +; +14 +n +- +> +next += +head +; +15 +return +n +; +16 +} +17 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; +24 +head += +next +; +25 +} +26 +return +prev +; +27 +} +28 +29 +__attribute__ +( +( +noinline +) +) +long +list_done +( +struct +node +* +head +) +{ +30 +long +sum += +0 +; +31 +for +( +; +head +; +head += +head +- +> +next +) +sum ++ += +head +- +> +value +; +32 +return +sum +; +33 +} +34 +35 +int +main +( +int +argc +, +char +* +* +argv +) +{ +36 +int +n += +argc +> +1 +? +atoi +( +argv +[ +1 +] +) +: +6 +; +37 +struct +node +* +head += +NULL +; +38 +for +( +int +i += +n +; +i +> += +1 +; +i +- +- +) +head += +push +( +head +, +i +* +i +) +; +39 +head += +reverse +( +head +) +; +40 +printf +( +"sum = %ld\n" +, +list_done +( +head +) +) +; +41 +return +0 +; +42 +} +43 + + + +disassembly +reverse + +1001 +8e4 +11 +push +r14 +push +1001 +8e6 +push +rbx +1001 +8e7 +mov +rbx, rsi +1001 +8ea +mov +r14, rdi +1001 +8ed +12 +mov +edi, 0x10 +1001 +8f2 +call +10019a0 +malloc +1001 +8f7 +13 +mov +qword ptr [rax], rbx +1001 +8fa +14 +mov +qword ptr [rax + 8], r14 +1001 +8fe +15 +pop +rbx +1001 +8ff +pop +r14 +1001 +901 +pop +rbp +1001 +902 +ret +1001 +903 +nop +word ptr cs:[rax + rax] +1001 +910 +20 +test +rdi, rdi +1001 +913 +je +1001935 +1001 +915 +push +rbp +1001 +916 +mov +rbp, rsp +1001 +919 +xor +eax, eax +1001 +91b +nop +dword ptr [rax + rax] +1001 +920 +mov +rcx, rax +1001 +923 +mov +rax, rdi + + + +1001 +926 +21 +mov +rdi, qword ptr [rdi + 8] + +1004098 + + +1004070 + + +9 +1001 +92a +22 +mov +qword ptr [rax + 8], rcx +1001 +92e +20 +test +rdi, rdi +1001 +931 +jne +1001920 +1001 +933 +pop +rbp +1001 +934 +26 +ret +1001 +935 +xor +eax, eax +1001 +937 +ret + +1001 +938 +endbr64 +_init +1001 +93c +sub +rsp, 8 +1001 +940 +mov +rax, qword ptr [rip + 0x1231] +1001 +947 +test +rax, rax +1001 +94a +je +100194e +1001 +94c +call +rax +1001 +94e +add +rsp, 8 +1001 +952 +ret + +1001 +954 +endbr64 +_fini +1001 +958 +sub +rsp, 8 +1001 +95c +add +rsp, 8 +1001 +960 +ret + +1001 +970 +push +qword ptr [rip + 0x1222] +strtol@plt-0x10 +1001 +976 +jmp +qword ptr [rip + 0x1224] + + + + + + + + + + + + +stack +69 words from rsp · the frames they belong to +rbp rsp + ++0 +saved rbp +7fffffffe +ce0 + + +7fffffffed00 + + + + + ++8 +7fffffffe +ce8 + + +10018b0 +main+80 ++10 +7fffffffe +cf0 + + +7ffff7e20de8 ++18 +saved rbx +7fffffffe +cf8 + + +0 ++20 +saved rbp +7fffffffe +d00 + + +7fffffffedb0 + + + + + ++28 +7fffffffe +d08 + + +7ffff7c27781 +libc+27781 ++30 +7fffffffe +d10 + + +7ffff7fe0c60 +ld.so+22c60 ++38 +7fffffffe +d18 + + +7fffffffee38 + + +7fffffffefea + + +".… ++40 +7fffffffe +d20 + + +0x1f7fbe000 ++48 +7fffffffe +d28 + + +1001860 +main+0 ++50 +7fffffffe +d30 + + +7fffffffed70 + + + + + ++58 +7fffffffe +d38 + + + + + ++60 +7fffffffe +d40 + + +0 ++68 +7fffffffe +d48 + + +0x1fe335fc95a5781c ++70 +7fffffffe +d50 + + +7fffffffee38 + + +7fffffffefea + + +".… ++78 +7fffffffe +d58 + + +1 ++80 +7fffffffe +d60 + + +7ffff7ffd000 ++88 +7fffffffe +d68 + + +10029c0 ++90 +7fffffffe +d70 + + +0x1fe335fc94e5781c ++98 +7fffffffe +d78 + + +0x1fe32587a0af781c ++a0 +7fffffffe +d80 + + +0x7fff00000000 ++a8 +7fffffffe +d88 + + +0 ++b0 +7fffffffe +d90 + + +0 ++b8 +7fffffffe +d98 + + +0 ++c0 +7fffffffe +da0 + + +7fffffffee38 + + +7fffffffefea + + +".… ++c8 +7fffffffe +da8 + + +0x15f6f7c6b8dafb00 ++d0 +saved rbp +7fffffffe +db0 + + +7fffffffee10 + + +0 ++d8 +7fffffffe +db8 + + + + + ++e0 +7fffffffe +dc0 + + +7fffffffee48 + + +0 ++e8 +7fffffffe +dc8 + + +10029c0 ++f0 +7fffffffe +dd0 + + +1001860 +main+0 ++f8 +7fffffffe +dd8 + + +7fffffffee48 + + +0 ++100 +7fffffffe +de0 + + +0 ++108 +7fffffffe +de8 + + +0 ++110 +7fffffffe +df0 + + +1001730 +_start+0 ++118 +7fffffffe +df8 + + +7fffffffee30 + + +1 ++120 +7fffffffe +e00 + + +0 ++128 +7fffffffe +e08 + + +0 ++130 +saved rbp +7fffffffe +e10 + + +0 ++138 +7fffffffe +e18 + + +1001755 +_start+37 ++140 +7fffffffe +e20 + + +7fffffffee28 + + +0x38 +56 ++148 +7fffffffe +e28 + + +0x38 +56 ++150 +argc +7fffffffe +e30 + + +1 ++158 +argv[0] +7fffffffe +e38 + + +7fffffffefea + + +"./list" ++160 +argv end +7fffffffe +e40 + + +0 ++168 +envp end +7fffffffe +e48 + + +0 ++170 +auxv +7fffffffe +e50 + + +0x21 +33 ++178 +7fffffffe +e58 + + +7ffff7fbc000 +vdso+0 ++180 +7fffffffe +e60 + + +0x33 +51 ++188 +7fffffffe +e68 + + +0xe30 +3632 ++190 +7fffffffe +e70 + + +0x10 +16 ++198 +7fffffffe +e78 + + +0xbfebfbff ++1a0 +7fffffffe +e80 + + +6 ++1a8 +7fffffffe +e88 + + +0x1000 +4096 ++1b0 +7fffffffe +e90 + + +0x11 +17 ++1b8 +7fffffffe +e98 + + +0x64 +100 ++1c0 +7fffffffe +ea0 + + +3 ++1c8 +7fffffffe +ea8 + + +1000040 ++1d0 +7fffffffe +eb0 + + +4 ++1d8 +7fffffffe +eb8 + + +0x38 +56 ++1e0 +7fffffffe +ec0 + + +5 ++1e8 +7fffffffe +ec8 + + +0xb +11 ++1f0 +7fffffffe +ed0 + + +7 ++1f8 +7fffffffe +ed8 + + +0x7ffff7fbe000 ++200 +7fffffffe +ee0 + + +8 ++208 +7fffffffe +ee8 + + +0 ++210 +7fffffffe +ef0 + + +9 ++218 +7fffffffe +ef8 + + +1001730 +_start+0 ++220 +7fffffffe +f00 + + +0xb +11 + + + +reverse + + + +main + + + +libc+27781 + + + +__libc_start_main + + +_start + + +moment 2 of 4 +The load read the word at 1004098: the address of the next node. +rdi holds it now, and points at the node whose value is 9. + diff --git a/design/mock/18-loupes-480.png b/design/mock/18-loupes-480.png new file mode 100644 index 0000000..c7b8332 Binary files /dev/null and b/design/mock/18-loupes-480.png differ diff --git a/design/mock/18-loupes.png b/design/mock/18-loupes.png new file mode 100644 index 0000000..cafd759 Binary files /dev/null and b/design/mock/18-loupes.png differ diff --git a/design/mock/18-loupes.svg b/design/mock/18-loupes.svg new file mode 100644 index 0000000..02bff4f --- /dev/null +++ b/design/mock/18-loupes.svg @@ -0,0 +1,2110 @@ + + + + + + +list.c +lines 1 to 42 of 42 +1 +// A linked list on the heap: built, reversed, summed. `list_done` +2 +// finished list, the place for a tracer to look at it. +3 +#include +<stdio.h> +4 +#include +<stdlib.h> +5 +6 +struct +node +{ +7 +long +value +; +8 +struct +node +* +next +; +9 +} +; +10 +11 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +push +( +struct +node +* +he +… +12 +struct +node +* +n += +malloc +( +sizeof +* +n +) +; +13 +n +- +> +value += +value +; +14 +n +- +> +next += +head +; +15 +return +n +; +16 +} +17 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +node +… +19 +struct +node +* +prev += +NULL +; +20 +while +( +head +) +{ + + +21 +struct +node +* +next += +head +- +> +next +; +22 +head +- +> +next += +prev +; +23 +prev += +head +; +24 +head += +next +; +25 +} +26 +return +prev +; +27 +} +28 +29 +__attribute__ +( +( +noinline +) +) +long +list_done +( +struct +node +* +head +) +{ +30 +long +sum += +0 +; +31 +for +( +; +head +; +head += +head +- +> +next +) +sum ++ += +head +- +> +value +; +32 +return +sum +; +33 +} +34 +35 +int +main +( +int +argc +, +char +* +* +argv +) +{ +36 +int +n += +argc +> +1 +? +atoi +( +argv +[ +1 +] +) +: +6 +; +37 +struct +node +* +head += +NULL +; +38 +for +( +int +i += +n +; +i +> += +1 +; +i +- +- +) +head += +push +( +head +, +i +* +i +) +; +39 +head += +reverse +( +head +) +; +40 +printf +( +"sum = %ld\n" +, +list_done +( +head +) +) +; +41 +return +0 +; +42 +} +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 + + + +disassembly +reverse + +1001 +8a8 +39 +mov +rdi, rax +main +1001 +8ab +call +1001910 +1001 +8b0 +40 +mov +rdi, rax +1001 +8b3 +call +1001830 +1001 +8b8 +lea +rdi, [rip - 0x12cb] +1001 +8bf +mov +rsi, rax +1001 +8c2 +xor +eax, eax +1001 +8c4 +call +1001990 +printf +1001 +8c9 +41 +xor +eax, eax +1001 +8cb +add +rsp, 8 +1001 +8cf +pop +rbx +1001 +8d0 +pop +rbp +1001 +8d1 +ret +1001 +8d2 +nop +word ptr cs:[rax + rax] + +1001 +8e0 +11 +push +rbp +push +1001 +8e1 +mov +rbp, rsp +1001 +8e4 +push +r14 +1001 +8e6 +push +rbx +1001 +8e7 +mov +rbx, rsi +1001 +8ea +mov +r14, rdi +1001 +8ed +12 +mov +edi, 0x10 +1001 +8f2 +call +10019a0 +malloc +1001 +8f7 +13 +mov +qword ptr [rax], rbx +1001 +8fa +14 +mov +qword ptr [rax + 8], r14 +1001 +8fe +15 +pop +rbx +1001 +8ff +pop +r14 +1001 +901 +pop +rbp +1001 +902 +ret +1001 +903 +nop +word ptr cs:[rax + rax] +1001 +910 +20 +test +rdi, rdi +1001 +913 +je +1001935 +1001 +915 +push +rbp +1001 +916 +mov +rbp, rsp +1001 +919 +xor +eax, eax +1001 +91b +nop +dword ptr [rax + rax] +1001 +920 +mov +rcx, rax +1001 +923 +mov +rax, rdi + + + +1001 +926 +21 +mov +rdi, qword ptr [rdi + 8] + +1004098 + + +1004070 + + +9 +1001 +92a +22 +mov +qword ptr [rax + 8], rcx +1001 +92e +20 +test +rdi, rdi +1001 +931 +jne +1001920 +1001 +933 +pop +rbp +1001 +934 +26 +ret +1001 +935 +xor +eax, eax +1001 +937 +ret + +1001 +938 +endbr64 +_init +1001 +93c +sub +rsp, 8 +1001 +940 +mov +rax, qword ptr [rip + 0x1231] +1001 +947 +test +rax, rax +1001 +94a +je +100194e +1001 +94c +call +rax +1001 +94e +add +rsp, 8 +1001 +952 +ret + +1001 +954 +endbr64 +_fini +1001 +958 +sub +rsp, 8 +1001 +95c +add +rsp, 8 +1001 +960 +ret + +1001 +970 +push +qword ptr [rip + 0x1222] +strtol@plt-0x10 +1001 +976 +jmp +qword ptr [rip + 0x1224] +1001 +97c +nop +dword ptr [rax] + +1001 +980 +jmp +qword ptr [rip + 0x1222] +strtol@plt +1001 +986 +push +0 +1001 +98b +jmp +1001970 + +1001 +990 +jmp +qword ptr [rip + 0x121a] +printf@plt +1001 +996 +push +1 +1001 +99b +jmp +1001970 + +1001 +9a0 +jmp +qword ptr [rip + 0x1212] +malloc@plt +1001 +9a6 +push +2 +1001 +9ab +jmp +1001970 + + + + + + + + + + + + +registers +stack +heap +code +data +rwx + +read-only +rax + +1004090 + + +4 +rbx +0 +rcx + +10040b0 + + +1 +rdx +0 +rsi +10040c0 + + +0 +rdi + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +r8 +7ffff7e19ac0 +r9 +0x20 +32 +r10 +0x10 +16 +r11 +7ffff7e19ac8 +r12 +7fffffffee38 + + +7fffffffefea + + +"./list" +r13 +1 +r14 +7ffff7ffd000 + + +7ffff7ffe3c0 + + +0 +r15 +10029c0 + + +1 + + +rip +1001926 +reverse+22 +cf + +PF +af +zf +sf + +IF +df +of + + + +backtrace +newest on top + + +#0 +reverse+22 +list.c:21 +#1 +main+80 +list.c:40 +#2 +libc+27781 +#3 +__libc_start_main+137 +#4 +_start+37 + + + +memory +the heap, round what the step reads + + + +10040 +00 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +10 + +24 +00 +00 +00 +00 +00 +00 +00 +36 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +20 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +30 + +19 +00 +00 +00 +00 +00 +00 +00 +25 + +10 +40 +00 +01 +00 +00 +00 +00 + + +1004010 + + + +10040 +40 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +50 + +10 +00 +00 +00 +00 +00 +00 +00 +16 + +30 +40 +00 +01 +00 +00 +00 +00 + + +1004030 + + + +10040 +60 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +70 + +09 +00 +00 +00 +00 +00 +00 +00 +9 + +50 +40 +00 +01 +00 +00 +00 +00 + + +1004050 + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + + +70 +40 +00 +01 +00 +00 +00 +00 + + +1004070 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +c0 +00 +00 +00 +00 +00 +00 +00 +00 +41 +0f +02 +00 +00 +00 +00 +00 +malloc's: the top chunk + + + + + +19 rows + + + +stack +69 words from rsp · the frames they belong to +rbp rsp + ++0 +saved rbp +7fffffffe +ce0 + + +7fffffffed00 + + + + + ++8 +7fffffffe +ce8 + + +10018b0 +main+80 ++10 +7fffffffe +cf0 + + +7ffff7e20de8 ++18 +saved rbx +7fffffffe +cf8 + + +0 ++20 +saved rbp +7fffffffe +d00 + + +7fffffffedb0 + + + + + ++28 +7fffffffe +d08 + + +7ffff7c27781 +libc+27781 ++30 +7fffffffe +d10 + + +7ffff7fe0c60 +ld.so+22c60 ++38 +7fffffffe +d18 + + +7fffffffee38 + + +7fffffffefea + + +".… ++40 +7fffffffe +d20 + + +0x1f7fbe000 ++48 +7fffffffe +d28 + + +1001860 +main+0 ++50 +7fffffffe +d30 + + +7fffffffed70 + + + + + ++58 +7fffffffe +d38 + + + + + ++60 +7fffffffe +d40 + + +0 ++68 +7fffffffe +d48 + + +0x1fe335fc95a5781c ++70 +7fffffffe +d50 + + +7fffffffee38 + + +7fffffffefea + + +".… ++78 +7fffffffe +d58 + + +1 ++80 +7fffffffe +d60 + + +7ffff7ffd000 ++88 +7fffffffe +d68 + + +10029c0 ++90 +7fffffffe +d70 + + +0x1fe335fc94e5781c ++98 +7fffffffe +d78 + + +0x1fe32587a0af781c ++a0 +7fffffffe +d80 + + +0x7fff00000000 ++a8 +7fffffffe +d88 + + +0 ++b0 +7fffffffe +d90 + + +0 ++b8 +7fffffffe +d98 + + +0 ++c0 +7fffffffe +da0 + + +7fffffffee38 + + +7fffffffefea + + +".… ++c8 +7fffffffe +da8 + + +0x15f6f7c6b8dafb00 ++d0 +saved rbp +7fffffffe +db0 + + +7fffffffee10 + + +0 ++d8 +7fffffffe +db8 + + + + + ++e0 +7fffffffe +dc0 + + +7fffffffee48 + + +0 ++e8 +7fffffffe +dc8 + + +10029c0 ++f0 +7fffffffe +dd0 + + +1001860 +main+0 ++f8 +7fffffffe +dd8 + + +7fffffffee48 + + +0 ++100 +7fffffffe +de0 + + +0 ++108 +7fffffffe +de8 + + +0 ++110 +7fffffffe +df0 + + +1001730 +_start+0 ++118 +7fffffffe +df8 + + +7fffffffee30 + + +1 ++120 +7fffffffe +e00 + + +0 ++128 +7fffffffe +e08 + + +0 ++130 +saved rbp +7fffffffe +e10 + + +0 ++138 +7fffffffe +e18 + + +1001755 +_start+37 ++140 +7fffffffe +e20 + + +7fffffffee28 + + +0x38 +56 ++148 +7fffffffe +e28 + + +0x38 +56 ++150 +argc +7fffffffe +e30 + + +1 ++158 +argv[0] +7fffffffe +e38 + + +7fffffffefea + + +"./list" ++160 +argv end +7fffffffe +e40 + + +0 ++168 +envp end +7fffffffe +e48 + + +0 ++170 +auxv +7fffffffe +e50 + + +0x21 +33 ++178 +7fffffffe +e58 + + +7ffff7fbc000 +vdso+0 ++180 +7fffffffe +e60 + + +0x33 +51 ++188 +7fffffffe +e68 + + +0xe30 +3632 ++190 +7fffffffe +e70 + + +0x10 +16 ++198 +7fffffffe +e78 + + +0xbfebfbff ++1a0 +7fffffffe +e80 + + +6 ++1a8 +7fffffffe +e88 + + +0x1000 +4096 ++1b0 +7fffffffe +e90 + + +0x11 +17 ++1b8 +7fffffffe +e98 + + +0x64 +100 ++1c0 +7fffffffe +ea0 + + +3 ++1c8 +7fffffffe +ea8 + + +1000040 ++1d0 +7fffffffe +eb0 + + +4 ++1d8 +7fffffffe +eb8 + + +0x38 +56 ++1e0 +7fffffffe +ec0 + + +5 ++1e8 +7fffffffe +ec8 + + +0xb +11 ++1f0 +7fffffffe +ed0 + + +7 ++1f8 +7fffffffe +ed8 + + +0x7ffff7fbe000 ++200 +7fffffffe +ee0 + + +8 ++208 +7fffffffe +ee8 + + +0 ++210 +7fffffffe +ef0 + + +9 ++218 +7fffffffe +ef8 + + +1001730 +_start+0 ++220 +7fffffffe +f00 + + +0xb +11 + + + +reverse + + + +main + + + +libc+27781 + + + +__libc_start_main + + +_start + + + + +rdi + → +1004070 +heap · struct node, 16 bytes + + + +10040 +30 + +19 +00 +00 +00 +00 +00 +00 +00 +25 + +10 +40 +00 +01 +00 +00 +00 +00 + + +1004010 + + + +10040 +40 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +50 + +10 +00 +00 +00 +00 +00 +00 +00 +16 + +30 +40 +00 +01 +00 +00 +00 +00 + + +1004030 + + + +10040 +60 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +70 + + +09 +00 +00 +00 +00 +00 +00 +00 +9 + + +50 +40 +00 +01 +00 +00 +00 +00 + + +1004050 + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +70 +40 +00 +01 +00 +00 +00 +00 + + +1004070 + + + +10040 +a0 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +b0 + +01 +00 +00 +00 +00 +00 +00 +00 +1 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + + + + + +1004078 + → +1004050 +heap · struct node, 16 bytes + + + +10040 +10 + +24 +00 +00 +00 +00 +00 +00 +00 +36 + +00 +00 +00 +00 +00 +00 +00 +00 +NULL + + + +10040 +20 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +30 + +19 +00 +00 +00 +00 +00 +00 +00 +25 + +10 +40 +00 +01 +00 +00 +00 +00 + + +1004010 + + + +10040 +40 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +50 + + +10 +00 +00 +00 +00 +00 +00 +00 +16 + + +30 +40 +00 +01 +00 +00 +00 +00 + + +1004030 + + + +10040 +60 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +70 + +09 +00 +00 +00 +00 +00 +00 +00 +9 + +50 +40 +00 +01 +00 +00 +00 +00 + + +1004050 + + + +10040 +80 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +malloc's: a chunk of 32 + + + +10040 +90 + +04 +00 +00 +00 +00 +00 +00 +00 +4 + +70 +40 +00 +01 +00 +00 +00 +00 + + +1004070 + + + + +moment 3 of 4 +The load is done: rdi holds 1004070, and beside it the heap round it opens. +Its next word opens the node after it, one deeper. + diff --git a/design/mock/context.py b/design/mock/context.py index 64603a2..303c7c1 100644 --- a/design/mock/context.py +++ b/design/mock/context.py @@ -43,6 +43,61 @@ def ph(rows): return TAG + 2 * PAD + rows * ROW +# ---- marks: the forms of `current`, `struck` and `held`. A is the first videos'; B the catalogue's now; C the +# other readings of "white, with less opacity" (mock 15 sets them side by side). +STYLE = {"current": "B", "struck": "B", "held": "B"} +WASH = mix(BRIGHT, PAGE, 0.10) # the current row: a white wash, opaque, a tenth of the way to bright +SOFT = mix(VERM, PAGE, 0.70) # a strike's paper, B + + +def band(): + """The paper across the current row.""" + return EMBER[GOLD] if STYLE["current"] == "A" else WASH + + +def current_row(g, x, y, w, plaque): + """The current mark on a row: the band across it and the plaque on its label. Returns the plaque's letters' ink.""" + g.rect(x, y, w, ROW, band()) + g.rect(x, y, plaque, ROW, BRIGHT if STYLE["current"] == "C" else GOLD) + return INK + + +def struck(g, x, y, w, h=ROW): + """A struck value's paper (x, w: the value's, 5 out each side). Returns its digits' ink.""" + st = STYLE["struck"] + if st == "A": + g.rect(x, y + 1, w, h - 2, VERM) + return INK + if st == "B": + g.rect(x, y + 1, w, h - 2, SOFT) + return BRIGHT + g.rect(x, y + 1, w, h - 2, mix(BRIGHT, PAGE, 0.18)) + g.frame(x, y + 1, w, h - 2, VERM, 2) + return BRIGHT + + +def held(g, x, y, w, h=ROW): + """Changed within three steps, at the value whose left is x (w wide) on the row at y.""" + st = STYLE["held"] + if st == "A": + g.rect(x - 9, y + 3, 4, h - 6, VERM) + elif st == "B": # a dog-ear: the corner of the value turned down + g.path(f"M{x - 4},{y + 2} h9 l-9,9 Z", fill=VERM) + else: # a bar under it, half strength + g.rect(x - 2, y + h - 4, w + 4, 2, mix(VERM, PAGE, 0.6)) + + +def held_cell(g, x, y, w, h, k=1): + """`held` on a lens's cell (k: the drawing's scale).""" + st = STYLE["held"] + if st == "A": + g.rect(x, y + h - 4 * k, w, 4 * k, VERM) + elif st == "B": + g.path(f"M{x},{y} h{12 * k} l{-12 * k},{12 * k} Z", fill=VERM) + else: + g.rect(x, y + h - 3 * k, w, 3 * k, mix(VERM, PAGE, 0.6)) + + def tag(g, x, y, w, h, title, focus=False, note=None): """A panel's frame and its one-row tag. note: a string, or runs (text, ink, underlined) for a legend.""" g.rect(x, y, w, TAG, RAISED) @@ -146,11 +201,10 @@ def chain(g, x, y, links, end, marks=None, room=None, lead=0): x = link_arrow(g, x, y) m = marks.get(i) if m == "strike": - g.rect(x - 5, y + 1, w + 10, ROW - 2, VERM) - addr(g, x, y, n, INK, BOLD) + addr(g, x, y, n, struck(g, x - 5, y, w + 10), BOLD) else: if m == "tick": - g.rect(x - 9, y + 3, 4, ROW - 6, VERM) + held(g, x, y, w) if m == "read": g.frame(x - 6, y, w + 12, ROW, READ, 2) addr(g, x, y, n, ink, lead=lead if i == 0 else 0) @@ -166,7 +220,7 @@ def chain(g, x, y, links, end, marks=None, room=None, lead=0): return where x = value_arrow(g, x, y) if links else x if marks.get("end") == "tick": # the value it holds changed within three steps - g.rect(x - 7, y + 3, 4, ROW - 6, VERM) + held(g, x + 2, y, len(str(end[1])) * A if end[0] == "int" else 3 * A) if end[0] == "int": integer(g, x, y, end[1]) else: @@ -186,11 +240,11 @@ def pin(g, x, y, names, ink): g.path(f"M{x + 9},{y + 12} l-9,-6 v12 Z", fill=ink) -def pin_up(g, cx, y, names, ink, size, link=None): +def pin_up(g, cx, y, names, ink, size, link=None, sw=3): """A register's name under what it points at: a stub with its head on the thing, the names either side. link: the points the stub is the end of, when this is the step that set the register.""" rise = size + 10 - gen.arrow(g, (link or []) + [(cx, y + rise), (cx, y + 1)], ink, 3, r=8, hl=10, hw=10) + gen.arrow(g, (link or []) + [(cx, y + rise), (cx, y + 1)], ink, sw, r=8, hl=10 + 2 * (sw - 3), hw=10 + 2 * (sw - 3)) face = BOLD by = y + 8 + size * 0.86 if names and names[0]: # names keep their side: None holds a side that was left @@ -215,37 +269,41 @@ def registers(g, y, regs, flags, marks): for i, (name, links, end) in enumerate(regs): yy = y0 + i * ROW if name == "rip": - g.rect(RX + 2, yy, CW - 4, ROW, EMBER[GOLD]) - g.rect(RX + 2, yy, 54, ROW, GOLD) - g.t(RX + 12, b(yy), name, S, INK, BOLD) + g.t(RX + 12, b(yy), name, S, current_row(g, RX + 2, yy, CW - 4, 54), BOLD) else: g.t(RX + 12, b(yy), name, S, DIM, MONO) where[name] = yy if links: chain(g, RX + 72, yy, links, end, marks.get(name), room=RX + CW - 12) else: + if marks.get(name, {}).get(0) == "strike": + s_ = ("0x%x" % end[1]) if end[1] >= 10 else str(end[1]) + g.t(RX + 72, b(yy), s_, S, struck(g, RX + 67, yy, len(s_) * A + 10), BOLD) + continue integer(g, RX + 72, yy, end[1]) if marks.get(name, {}).get(0) == "tick": - g.rect(RX + 63, yy + 3, 4, ROW - 6, VERM) + held(g, RX + 72, yy, len(str(end[1])) * A) # the flags, in rip's row: where the machine is, and the condition it is in x = RX + CW - 12 - len(flags) * 42 + 10 for name, on, changed in flags: if changed: - g.rect(x - 7, yy + 3, 4, ROW - 6, VERM) + held(g, x + 4, yy, 2 * A) if on: g.rect(x, yy + 2, 2 * A + 8, 20, RAISED) g.t(x + 4, b(yy), name, S, BRIGHT, BOLD) else: - g.t(x + 4, b(yy), name.lower(), S, mix(DIM, EMBER[GOLD], 0.8), MONO) + g.t(x + 4, b(yy), name.lower(), S, mix(DIM, band(), 0.8), MONO) x += 42 return where -def stack(g, y, rows, frames, note=None): +def stack(g, y, rows, frames, note=None, rsp=None, roles=None): """rows: (slot, pins, links, end[, marks]). frames: (name, first row, last row), newest first: the backtrace, drawn on the words that are each frame; a first row under 0 runs above the window. The window is the newest frame's. A frame's name is never cut for a chain: the chains on the rows it sits on end 12 - before it. Returns each row's y.""" + before it. rsp: the slots' offsets from it are drawn (pwndbg's column). roles: {row: (what the slot is, ink)}: + a local's name, `saved rbp`, `return`, ranged right where the chain's room ends; the chain ends 12 before it. + Returns each row's y.""" y0 = panel(g, RX, y, CW, len(rows), "stack", note=(note or "%s words from rsp" % {6: "six", 8: "eight"}[len(rows)]) + " · the frames they belong to") lead = shared([r[0] for r in rows]) @@ -264,13 +322,22 @@ def stack(g, y, rows, frames, note=None): room[r] = min(room.get(r, RX + CW - 136), nx - 12) spans.append((i, name, x, ya, yb, ny, open_top, open_)) ys = [] + roles = roles or {} + first = RX + (184 if rsp is not None else 122) for i, (slot, pins, links, end, *marks) in enumerate(rows): yy = y0 + i * ROW ys.append(yy) if pins: pin(g, RX + 10, yy, pins, STACK) - chain(g, RX + 122, yy, [(slot, STACK)] + links, end, marks[0] if marks else None, - room=room.get(i, RX + CW - 136), lead=lead) + if rsp is not None: # the offset from rsp, pwndbg's way: +18 + off = slot - rsp + g.t(RX + 172, b(yy), ("+%x" % off) if off >= 0 else ("-%x" % -off), S, FAINT, MONO, "end") + end_x = room.get(i, RX + CW - 136) + if i in roles: + text, ink = roles[i] + g.t(end_x, b(yy), text, S, ink, MONO, "end") + end_x -= len(text) * A + 12 + chain(g, first, yy, [(slot, STACK)] + links, end, marks[0] if marks else None, room=end_x, lead=lead) for i, name, x, ya, yb, ny, open_top, open_ in spans: ink = GOLD if i == 0 else RULE g.rect(x - 1, ya, 2, yb - ya, ink) @@ -319,14 +386,12 @@ def wide(total): def source(g, y, rows, lines, first, cur, trail, name, total): """Returns the y of the current line's row. Numbers as wide as the file's last: the text moves by the extra.""" w = wide(total) - y0 = panel(g, LX, y, CW, rows, name, note=f"lines {first} to {first + rows - 1} of {total}") + y0 = panel(g, LX, y, CW, rows, name, note=f"lines {first} to {min(first + rows - 1, total)} of {total}") for i in range(rows): n = first + i yy = y0 + i * ROW if n == cur: - g.rect(LX + 2, yy, CW - 4, ROW, EMBER[GOLD]) - g.rect(LX + 2, yy, 50 + w, ROW, GOLD) - g.t(LX + 46 + w, b(yy), str(n), S, INK, BOLD, "end") + g.t(LX + 46 + w, b(yy), str(n), S, current_row(g, LX + 2, yy, CW - 4, 50 + w), BOLD, "end") else: if n in trail: g.rect(LX + 2, yy + 1, 4, ROW - 2, TRAIL[min(trail.index(n), 2)]) @@ -352,16 +417,14 @@ def disasm(g, y, rows, func, cur_line, jump=None, w=0): yy = y0 + i * ROW where[a] = yy dim = st == "out" - if dim: # the function ends: a rule, and the next one's name + if dim or st == "other_first": # a function ends: a rule, and the next one's name g.rect(LX + 2, yy, CW - 4, 2, RULE) if st == "cur": - g.rect(LX + 2, yy, CW - 4, ROW, EMBER[GOLD]) - g.rect(LX + 2, yy, 24, ROW, GOLD) - g.path(f"M{LX + 20},{yy + 12} l-10,-6 v12 Z", fill=INK) + g.path(f"M{LX + 20},{yy + 12} l-10,-6 v12 Z", fill=current_row(g, LX + 2, yy, CW - 4, 24)) elif st and st.startswith("trail"): g.rect(LX + 2, yy + 1, 4, ROW - 2, TRAIL[int(st[-1])]) addr(g, LX + DX_ADDR, yy, a, mix(CODE, PAGE, 0.6) if dim else CODE, lead=0 if dim else lead) - if line != last_line and not dim: # the line this run of instructions was compiled from + if line is not None and line != last_line and not dim: # the line this run was compiled from on = line == cur_line g.t(LX + DX_LINE + 3 * A + w, b(yy), str(line), S, GOLD if on else FAINT, BOLD if on else MONO, "end") last_line = line @@ -400,30 +463,38 @@ def thread(g, ys, spans): # ---- the lens: a list, and beside it the bytes it is drawn from ------------------------- -def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=()): +def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=(), title="its bytes", x=None, + framed=(), bare=False, rows_shown=None): """`hexdump` by `fields`: the region a scene names, read by the fields it gives it, in the band's view. flist: (at, len, reads, big, mark) with reads in number | pointer | text | bytes. mem: {address: byte} of what the stop shown saw (or the kernel took); a byte not in it is unread. marks: the field marks framed as read. - Rows that hold no field are one `more` row and their count. The bytes begin 12 after the widest address.""" - tag(g, RX, y, CW, h, "its bytes") - g.t(RX + 28 + tw("its bytes", 20, "sansm") + 12, y + 18, about, 18, FAINT, "sans") + Rows that hold no field are one `more` row and their count. The bytes begin 12 after the widest address. + reads `malloc`: the allocator's size word, loose, read as a note. framed: (at, len) drawn with `attention`'s + bright frame (a loupe's target). bare: no tag (a loupe draws its own). rows_shown: the rows to show, when the + window is not every row that holds a field. Returns {row address: y}.""" + X = RX if x is None else x + if not bare: + tag(g, X, y, CW, h, title) + g.t(X + 28 + tw(title, 20, "sansm") + 12, y + 18, about, 18, FAINT, "sans") total = (length + 15) // 16 holds = lambda r: any(base + at < base + 16 * (r + 1) and base + at + n > base + 16 * r for at, n, *_ in flist) - shown = [r for r in range(total) if holds(r) or total <= (h - TAG - 2 * PAD) // ROW] + shown = rows_shown if rows_shown is not None else [r for r in range(total) if holds(r)] + ys = {} digits = max(len("%x" % (base + 16 * r)) for r in shown) shift = max(18 + digits * A + 12 - 132, 0) - bx = lambda i: RX + 132 + shift + i * 30 + (12 if i >= 8 else 0) + bx = lambda i: X + 132 + shift + i * 30 + (12 if i >= 8 else 0) lead = shared([base + 16 * r for r in shown]) if len(shown) > 1 else 0 yy, last = y + TAG + PAD, None for r in shown: if last is not None and r > last + 1: # the rows left out: one row, and how many - more(g, RX + 18 - 6, yy) - g.t(RX + 18 + 30 + 36, b(yy), "%d rows" % (r - last - 1), S, FAINT, MONO) + more(g, X + 18 - 6, yy) + g.t(X + 18 + 30 + 36, b(yy), "%d rows" % (r - last - 1), S, FAINT, MONO) yy += ROW last = r a0 = base + 16 * r - bracket(g, RX + 7, yy + 3, yy + ROW - 3, mix(region, PAGE, 0.6)) - addr(g, RX + 18, yy, a0, region, lead=lead) + ys[a0] = yy + bracket(g, X + 7, yy + 3, yy + ROW - 3, mix(region, PAGE, 0.6)) + addr(g, X + 18, yy, a0, region, lead=lead) runs, i = [], 0 while i < 16 and a0 + i < base + length: f = next((f for f in flist if base + f[0] <= a0 + i < base + f[0] + f[1]), None) @@ -433,12 +504,12 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() n = min([base + o[0] - a0 for o in flist if a0 + i < base + o[0] < a0 + 16] + [16, base + length - a0]) - i runs.append((i, n, f)) i += n - x = RX + 640 + shift # the reading: a list, a character apart + x = X + 640 + shift # the reading: a list, a character apart for i0, n, f in runs: vals = [mem.get(a0 + k) for k in range(i0, i0 + n)] reads = f[2] if f else "loose" x0, x1 = bx(i0) - 4, bx(i0 + n - 1) + 28 - if f: + if f and reads != "malloc": g.rect(x0, yy + 1, x1 - x0, ROW - 2, RAISED) if f[4] is not None and f[4] in marks: g.frame(x0 - 3, yy - 1, x1 - x0 + 6, ROW + 2, READ, 2) @@ -448,8 +519,11 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() order = vals[::-1] if not (f and f[3]) else vals for v in order: word = word << 8 | v - ink = {"number": VELLUM, "bytes": VELLUM, "text": LIT, "loose": DIM, - "pointer": region_of(word) if known else VELLUM}[reads] + for fa, fl in framed: # the target: framed bright, as attention + if base + fa < a0 + i0 + n and base + fa + fl > a0 + i0: + g.frame(x0 - 3, yy - 1, x1 - x0 + 6, ROW + 2, BRIGHT, 2) + ink = {"number": VELLUM, "bytes": VELLUM, "text": LIT, "loose": DIM, "malloc": DIM, + "pointer": (region_of(word) or VELLUM) if known else VELLUM}[reads] nz = [k for k, v in enumerate(vals) if v] for k, v in enumerate(vals): xx = bx(i0 + k) @@ -461,21 +535,30 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() g.t(xx, b(yy), "%02x" % v, S, mix(ink, PAGE, 0.45) if padded else ink, MONO) if not known or reads in ("bytes", "loose"): continue + if reads == "malloc": # the allocator's own: the size word of the chunk after it + note = "malloc's: a chunk of %d" % (word & ~7) if word < 0x10000 else "malloc's: the top chunk" + g.t(x, b(yy) - 1, note, 18, FAINT, "sans") + x += tw(note, 18, "sans") + A + continue if reads == "pointer": if word == 0: s_, sink = "NULL", DIM else: - x = addr(g, link_arrow(g, x, yy), yy, word, region_of(word)) + A + x = addr(g, link_arrow(g, x, yy), yy, word, region_of(word) or VELLUM) + A continue elif reads == "number": s_, sink = str(word), VELLUM else: s_, sink = '"' + bytes(vals).split(b"\0")[0].decode("latin1") + '"', LIT - if x + len(s_) * A > RX + CW - 12: - s_ = s_[:max(int((RX + CW - 12 - x) // A) - 1, 0)] + "…" + if x + len(s_) * A > X + CW - 12: + s_ = s_[:max(int((X + CW - 12 - x) // A) - 1, 0)] + "…" g.t(x, b(yy), s_, S, sink, MONO) x += (len(s_) + 1) * A yy += ROW + if shown and shown[-1] < total - 1: # the rows after the last field: one row, and how many + more(g, X + 18 - 6, yy) + g.t(X + 18 + 30 + 36, b(yy), "%d rows" % (total - 1 - shown[-1]), S, FAINT, MONO) + return ys def kernel(g, y, h, calls, name, nr, rows, given): @@ -524,7 +607,7 @@ def dump_row(g, y, a, runs, lead, mark=None, node=False): if mark.get("read") == k: g.frame(x0 - 3, y - 1, x1 - x0 + 6, ROW + 2, READ, 2) if mark.get("tick") == k: - g.rect(x0 - 7, y + 3, 4, ROW - 6, VERM) + held(g, x0 + 4, y, x1 - x0 - 8) ink = {"value": VELLUM, "next": HEAP, "malloc": DIM, "unread": FAINT}[kind] top = max((j for j in range(n) if (v or 0) >> (8 * j) & 0xff), default=0) for j in range(n): @@ -548,26 +631,30 @@ def dump_row(g, y, a, runs, lead, mark=None, node=False): g.t(x + 3 * A + 8 + 30, b(y), "NULL", S, DIM, MONO) -def lens(g, y, h, hv, nodes, pins, marks, first, nrows, link_from=None, subject=False): +def lens(g, y, h, hv, nodes, pins, marks, first, nrows, link_from=None, subject=False, dw=None, k=1, view_rows=None): """The band: the list drawn, over the program column, and the heap bytes it is drawn from, over the state column; two panels, h and hv high, the gutter between them the ties'. nodes: (address, value, next address or 0), in the list's order. pins: {address: [registers]}. marks: {"read": address of a word, "tick": [addresses of words]}. link_from: the y of the register row the step's link comes from, and the register. - As the subject the drawing is a size up; the dump stays on the context's grid and shows more rows.""" - tag(g, LX, y, CW, h, "the list", focus=True) + As the subject the drawing is a size up; the dump stays on the context's grid and shows more rows. + On the 4K stage the drawing is dw wide and drawn k times the size (2), and the view is drawn by `fields`, whose + rows (view_rows: {row address: y}) the projection starts from.""" + dw = dw or CW + tag(g, LX, y, dw, h, "the list", focus=True) last = first + (nrows - 1) * 16 - tag(g, RX, y, CW, hv, "its bytes", - note=[("value", VELLUM, False), ("next", HEAP, False), ("malloc's", DIM, False), ("never read", FAINT, False)]) - g.t(RX + 28 + tw("its bytes", 20, "sansm") + 12, y + 18, "the heap, %x to %x" % (first, last + 15), 18, FAINT, - "sans") + rows = view_rows or {} + if view_rows is None: + tag(g, RX, y, CW, hv, "its bytes", + note=[("value", VELLUM, False), ("next", HEAP, False), ("malloc's", DIM, False), ("never read", FAINT, False)]) + g.t(RX + 28 + tw("its bytes", 20, "sansm") + 12, y + 18, "the heap, %x to %x" % (first, last + 15), 18, FAINT, + "sans") # the dump y0 = y + TAG + PAD by_addr = {a: (v, nx) for a, v, nx in nodes} lead = shared([first, last]) - rows = {} - for i in range(nrows): + for i in range(nrows if view_rows is None else 0): a, yy = first + i * 16, y0 + i * ROW rows[a] = yy if a in by_addr: @@ -584,12 +671,13 @@ def lens(g, y, h, hv, nodes, pins, marks, first, nrows, link_from=None, subject= dump_row(g, yy, a, [(0, 8, "unread", None), (8, 8, "malloc", 0x21)], lead) # the drawing, centred between its lanes - NW, NH, GAP, VS, LS = (124, 72, 22, 45, 25) if subject else (116, 44, 28, 25, 20) - VW = NW - 48 # the value's half; the pointer's is 48 - x0 = LX + (CW - len(nodes) * NW - (len(nodes) - 1) * GAP) / 2 + NW, NH, GAP, VS, LS = [v * k for v in ((124, 72, 22, 45, 25) if subject else (116, 44, 28, 25, 20))] + VW = NW - 48 * k # the value's half; the pointer's is 48 + tie_w = (3, 2) if k == 1 else (4, 3) # a link, a projection: on the 4K stage, 2 and 1.5 pixels at 1080p + x0 = LX + (dw - len(nodes) * NW - (len(nodes) - 1) * GAP) / 2 lane_top, lane_bot = y + TAG + 4, y + h - 8 block = LS * 1.2 + 4 + NH + LS + 10 + 8 # address, node, the pins' stub and names - ly = y + TAG + (16 if not subject else round((h - TAG - block) / 2)) # the row of addresses over the nodes + ly = y + TAG + (16 * k if not subject else round((h - TAG - block) / 2)) # the row of addresses over the nodes ny = ly + LS * 1.2 + 4 xs = {a: x0 + i * (NW + GAP) for i, (a, v, nx) in enumerate(nodes)} for a, v, nx in nodes: @@ -599,22 +687,22 @@ def lens(g, y, h, hv, nodes, pins, marks, first, nrows, link_from=None, subject= g.t(x + VW / 2 - 1, ny + NH / 2 + 0.36 * VS, str(v), VS, VELLUM, MONO if VS < 30 else "mono", "middle") g.rect(x + VW, ny, NW - VW, NH, WELL) if marks.get("read") == a + 8: - g.frame(x + VW - 2, ny - 2, NW - VW + 4, NH + 4, READ, 2) + g.frame(x + VW - 2 * k, ny - 2 * k, NW - VW + 4 * k, NH + 4 * k, READ, 2 * k) if a + 8 in marks.get("tick", ()): - g.rect(x + VW, ny + NH - 4, NW - VW, 4, VERM) + held_cell(g, x + VW, ny, NW - VW, NH, k) cx, cy = x + VW + (NW - VW) / 2, ny + NH / 2 if nx: - g.rect(cx - 5, cy - 5, 10, 10, HEAP) - gen.arrow(g, [(cx + 8, cy), (xs[nx] - 3, cy)], HEAP, 3, hl=12, hw=10) + g.rect(cx - 5 * k, cy - 5 * k, 10 * k, 10 * k, HEAP) + gen.arrow(g, [(cx + 8 * k, cy), (xs[nx] - 3 * k, cy)], HEAP, 3 * k, hl=12 * k, hw=10 * k) else: - g.path(f"M{x + VW + 10},{ny + NH - 8} L{x + NW - 10},{ny + 8}", DIM, 2) + g.path(f"M{x + VW + 10 * k},{ny + NH - 8 * k} L{x + NW - 10 * k},{ny + 8 * k}", DIM, 2 * k) names = pins.get(a) if names: via = None if link_from and link_from[1] in names: # the step's link ends in this pin via = [(RX + 2, link_from[0] + 12), (LANE_LINK, link_from[0] + 12), (LANE_LINK, lane_bot), (x + NW / 2, lane_bot)] - pin_up(g, x + NW / 2, ny + NH, names, HEAP, LS, via) + pin_up(g, x + NW / 2, ny + NH, names, HEAP, LS, via, sw=tie_w[0]) # the projection: the bytes a step read, and the part of the drawing that is those bytes if marks.get("read"): @@ -623,7 +711,7 @@ def lens(g, y, h, hv, nodes, pins, marks, first, nrows, link_from=None, subject= bracket(g, RX + 7, yy + 2, yy + ROW - 2, READ, 3, 6) g.path(f"M{RX + 6},{yy + 12} H{LANE_VIEW + 6} Q{LANE_VIEW},{yy + 12} {LANE_VIEW},{yy + 6} V{lane_top + 6} " f"Q{LANE_VIEW},{lane_top} {LANE_VIEW - 6},{lane_top} H{x + NW / 2 + 6} " - f"Q{x + NW / 2},{lane_top} {x + NW / 2},{lane_top + 6} V{ly - 4}", READ, 2) + f"Q{x + NW / 2},{lane_top} {x + NW / 2},{lane_top + 6} V{ly - 4}", READ, tie_w[1]) g.rect(x, ly - 5, NW, 3, READ) g.rect(x, ly - 5, 3, 8, READ) g.rect(x + NW - 3, ly - 5, 3, 8, READ) @@ -848,9 +936,7 @@ def backtrace(g, y, h, frames, x=RX, note="the calls waiting · newest on top", for i, (name, args, file, line) in enumerate(frames[:rows]): yy = y0 + i * ROW if i == 0: - g.rect(x + 2, yy, CW - 4, ROW, EMBER[GOLD]) - g.rect(x + 2, yy, 40, ROW, GOLD) - g.t(x + 12, b(yy), "#0", S, INK, BOLD) + g.t(x + 12, b(yy), "#0", S, current_row(g, x + 2, yy, CW - 4, 40), BOLD) else: g.t(x + 12, b(yy), "#%d" % i, S, FAINT, MONO) g.t(x + 60, b(yy), name, S, VELLUM, MONO) diff --git a/design/mock/dense.py b/design/mock/dense.py new file mode 100644 index 0000000..cb047ac --- /dev/null +++ b/design/mock/dense.py @@ -0,0 +1,441 @@ +#!/usr/bin/env python3 +"""The frame on the 4K stage: four columns of 880, the context at mono 20, four times what 1080 held. + + python3 -B dense.py # writes 15-marks.svg, 16-none.svg, 17-subject.svg, 18-loupes.svg + +The blocks are context.py's, placed on the 4K stage's columns; what is new here is the stage, the thread across +the gutter, the `loupe`, and the marks sheet. The moment is real: a fresh recording of the same `targets/list`, +`ztrace dbg --stack 1024` with a breakpoint at `reverse+22` (the load at line 21), its second stop and the +instruction after (`list-dbg.txt`, kept beside this file), and the program's disassembly with its lines +(`objdump -dl`, `list.dis`). +""" +import re + +import gen +gen.W, gen.H = 3840, 2160 # the Svg's canvas: the 4K stage, in units +import context as C +from context import (PAGE, RAISED, VELLUM, BRIGHT, DIM, FAINT, INK, GOLD, VERM, READ, HEAP, STACK, A, S, ROW, + TAG, PAD, MONO, BOLD, b, ph, tw, mix, bracket, chain, Svg, S_, H_, C_, D_, P) + +W4, H4 = 3840, 2160 +COL = [112, 1024, 1936, 2848] # four columns of 880, gutters of 32 +CW = 880 +TOP4, BOT4 = 96, 1784 # the stage: 1688, a single panel of 69 rows +C.W = W4 +C.TOP, C.BOTTOM = TOP4, BOT4 +C.LANE_LINK, C.LANE_VIEW = 1912, 1924 # the gutter between the program's columns and the state's +THREAD_X = 1008 # the gutter between the source and the disassembly +LIFT, LIFT_TAG, SHADE = "#121c52", "#22317a", "#02061a" # a loupe's surface, its tag, its shadow + + +def put(x): + """Place the next block in the column at x.""" + C.LX = C.RX = x + + +# ---- the recording ---------------------------------------------------------------------------------- +DBG = open(__file__.replace("dense.py", "list-dbg.txt")).read() +MEM = {} +for line in DBG.split("\n"): + m = re.match(r"^([0-9a-f]{12}) ((?:[0-9a-f?]{2} ){16})", line) + if m and "??" not in m.group(2): + for i, v in enumerate(m.group(2).split()): + MEM[int(m.group(1), 16) + i] = int(v, 16) +NAMES = {0x1001730: "_start", 0x1001830: "list_done", 0x1001860: "main", 0x10018e0: "push", 0x1001910: "reverse", + 0x1001938: "_init", 0x1001954: "_fini"} +LIBNAMES = {0x7ffff7c27781: "libc+27781", 0x7ffff7c278b9: "__libc_start_main+137", 0x7ffff7fe0c60: "ld.so+22c60", + 0x7ffff7fbc000: "vdso+0"} + + +def region(v): + """The ink of what v points into, by the run's mappings (None: no mapping).""" + for lo, hi, ink in [(0x7ffffffde000, 0x7ffffffff000, S_), (0x1004000, 0x1025000, H_), (0x1001000, 0x1002000, C_), + (0x1000000, 0x1001000, VELLUM), (0x1002000, 0x1003000, VELLUM), (0x1003000, 0x1004000, D_), + (0x7ffff7c24000, 0x7ffff7d9f000, C_), (0x7ffff7c00000, 0x7ffff7c24000, VELLUM), + (0x7ffff7e15000, 0x7ffff7e23000, D_), (0x7ffff7fbc000, 0x7ffff7fbe000, C_), + (0x7ffff7fbf000, 0x7ffff7fec000, C_), (0x7ffff7ffb000, 0x7ffff7fff000, D_)]: + if lo <= v < hi: + return ink + return None + + +def name(v): + if v in LIBNAMES: + return LIBNAMES[v] + f = max((a for a in NAMES if a <= v), default=None) + return "%s+%d" % (NAMES[f], v - f) if f is not None else "%x" % v + + +def word(a): + if all(a + i in MEM for i in range(8)): + return sum(MEM[a + i] << (8 * i) for i in range(8)) + return None + + +def text(a): + """The C string at a, if there is one of two characters or more.""" + out = [] + while a + len(out) in MEM and MEM[a + len(out)] and 32 <= MEM[a + len(out)] < 127: + out.append(chr(MEM[a + len(out)])) + return "".join(out) if len(out) >= 2 and MEM.get(a + len(out)) == 0 else None + + +def follow(v, depth=5): + """A chain from the address v, as far as the recording holds the memory: (links, end) for context.chain.""" + links = [] + while True: + ink = region(v) + if ink == C_: + return links + [(v, C_, name(v))], None + links.append((v, ink)) + s = text(v) + if s: + return links, ("str", s) + w = word(v) + if w is None or len(links) > depth: + return links, None + if w and region(w): + v = w + continue + return links, ("int", w) + + +def value(v): + return follow(v) if v and region(v) else ([], ("int", v)) + + +RSP = 0x7fffffffece0 +FRAMES = [("reverse", 0, 1), ("main", 2, 5), ("libc+27781", 6, 27), ("__libc_start_main", 28, 39), ("_start", 40, 99)] +# What a slot is, where the recording can know it: a saved register (the frame-pointer chain; the prologue's pushes, +# from the call frame information), the process's start (argc, argv, envp, auxv, from the first stack pointer). A +# return address needs no word: its chain is code, named, and its frame's bracket ends on it. +ROLES = {0: "saved rbp", 3: "saved rbx", 4: "saved rbp", 26: "saved rbp", 38: "saved rbp", 42: "argc", 43: "argv[0]", + 44: "argv end", 45: "envp end", 46: "auxv"} + + +def stack_rows(n, rbp_rsp=True): + rows = [] + for i in range(n): + a = RSP + 8 * i + links, end = value(word(a)) + rows.append((a, (["rbp", "rsp"] if i == 0 and rbp_rsp else []), links, end)) + return rows + + +def roles(n): + return {i: (t, DIM) for i, t in ROLES.items() if i < n} + + +def regs(step): + rdi = 0x1004070 if step else 0x1004090 + out = [] + for r, v in [("rax", 0x1004090), ("rbx", 0), ("rcx", 0x10040b0), ("rdx", 0), ("rsi", 0x10040c0), ("rdi", rdi), + ("rbp", RSP), ("rsp", RSP), ("r8", 0x7ffff7e19ac0), ("r9", 0x20), ("r10", 0x10), ("r11", 0x7ffff7e19ac8), + ("r12", 0x7fffffffee38), ("r13", 1), ("r14", 0x7ffff7ffd000), ("r15", 0x10029c0)]: + links, end = value(v) + if r == "r14": # ld.so's data: the recording followed it (ztrace's own telescope) + links, end = [(0x7ffff7ffd000, D_), (0x7ffff7ffe3c0, D_)], ("int", 0) + if r == "r15": + links, end = [(0x10029c0, VELLUM)], ("int", 1) + out.append((r, links, end)) + out.append(("rip", [(0x1001926, C_, "reverse+22")], None)) + return out + + +FLAGS = [("CF", 0, 0), ("PF", 1, 0), ("AF", 0, 0), ("ZF", 0, 0), ("SF", 0, 0), ("IF", 1, 0), ("DF", 0, 0), ("OF", 0, 0)] +BT = [("reverse+22", "", "list.c", 21), ("main+80", "", "list.c", 40), ("libc+27781", "", None, 0), + ("__libc_start_main+137", "", None, 0), ("_start+37", "", None, 0)] +NODES = [(0x10040b0, 1, 0), (0x1004090, 4, 0x1004070), (0x1004070, 9, 0x1004050), (0x1004050, 16, 0x1004030), + (0x1004030, 25, 0x1004010), (0x1004010, 36, 0)] +SRC = C.SRC[:42] + [""] * 40 + + +def heap_fields(base, length, read_at=None): + """The heap's words by what the program and malloc made of them: each node a value and a next, each chunk's + size word malloc's, the top chunk's size word, and the rest loose. The word at read_at carries mark 9.""" + out = [] + for a, _, _ in NODES: + out += [(a - base, 8, "number", False, None), (a + 8 - base, 8, "pointer", False, 9 if a + 8 == read_at else None), + (a - 8 - base, 8, "malloc", False, None)] + out.append((0x10040c8 - base, 8, "malloc", False, None)) + return [f for f in out if 0 <= f[0] < length] + + +def conv(mn, ops): + """objdump's Intel syntax as the recording's disassembler writes it.""" + if mn.startswith("data16") or mn == "cs": + return "nop", "word ptr cs:[rax + rax]" + ops = ops.lower().replace(",", ", ") + ops = re.sub(r"\[(.*?)\]", lambda m: "[" + re.sub(r"([+*-])", r" \1 ", m.group(1)).replace(" * ", "*") + "]", ops) + ops = ops.replace("*1 + 0x0", "").replace(" + 0x0]", "]") + + def num(m): + v = int(m.group(1), 16) + return str(v) if v < 10 else "0x%x" % v + ops = re.sub(r"rip \+ 0x(f{8}[0-9a-f]+)", lambda m: "rip - 0x%x" % ((1 << 64) - int(m.group(1), 16)), ops) + ops = re.sub(r"(?:", l) + if m: + func = m.group(2) + continue + m = re.match(r"^targets/list\.c:(\d+)", l) + if m: + line = int(m.group(1)) + continue + m = re.match(r"^\s+([0-9a-f]+):\s+(\S+)\s*(.*)$", l) + if m: + ops = re.sub(r"\s*<[^>]+>", "", re.sub(r"\s+#.*", "", m.group(3))).strip() + mn, ops = conv(m.group(2), ops) + own = func in ("main", "push", "reverse", "list_done") + rows.append((int(m.group(1), 16), func, line if own else None, mn, ops)) + return rows + + +CALLEES = {0x1001990: "printf", 0x10019a0: "malloc", 0x1001980: "strtol"} + + +def window(n, step): + """n instructions round the pc: the function's and its neighbours', each neighbour under a rule and its name.""" + rows = disasm_rows() + i = [r[0] for r in rows].index(0x1001926) + lo = max(0, min(i - n // 2, len(rows) - n)) + out, last_func = [], None + for a, func, line, mn, ops in rows[lo:lo + n]: + target = re.fullmatch(r"([0-9a-f]{6,})", ops) + parts = [(int(ops, 16), C_)] if target else ([(ops, P)] if ops else []) + st = "cur" if a == 0x1001926 else None + note = None + if func != "reverse": + st = "other_first" if func != last_func else "other" + if func != last_func: + note = ("text", func, DIM) + if mn == "call" and target and int(ops, 16) in CALLEES: + note = ("text", CALLEES[int(ops, 16)], VELLUM) + if a == 0x1001926: + note = ("chain", [(0x1004098, H_), (0x1004070, H_)], ("int", 9), {0: "read"} if step else None) + out.append((a, line, mn, parts, st, note)) + last_func = func + return out + + +# ---- the stage's blocks ------------------------------------------------------------------------------- +def thread_across(g, ys, spans): + """The thread on the 4K stage: the source and the disassembly side by side, the gutter between them its + channel. A bracket on the line at the source's right edge, one on each run at the disassembly's left, a + line down the gutter between.""" + x0, x1 = COL[0] + CW + 6, COL[1] - 6 + bracket(g, x0, ys + 2, ys + ROW - 2, GOLD, 4, 7, side=-1) + tops = [ys + 12] + for ya, yb in spans: + bracket(g, x1, ya + 2, yb - 2, GOLD, 4, 7) + tops.append((ya + yb) / 2) + g.rect(THREAD_X, (ya + yb) / 2 - 2, x1 - THREAD_X, 4, GOLD) + g.rect(x0, ys + 10, THREAD_X - x0, 4, GOLD) + g.rect(THREAD_X - 2, min(tops) - 2, 4, max(tops) - min(tops) + 4, GOLD) + + +def clock4(g, moment, total): + g.rect(COL[0], 1798, 3616, 4, C.RULE) + g.rect(COL[0], 1796, 3616 * moment / total, 8, GOLD) + g.t(COL[3] + CW, 1852, "moment %d of %d" % (moment, total), 40, FAINT, "mono", "end") + + +def caption4(g, lines): + """The caption, twice the 1080 frame's: Go 80 on 108, code mono 70; so it reads the same at 1080p.""" + y = 1824 + (104 if len(lines) == 2 else 156) + for parts in lines: + g.rich(COL[0], y, [(p[0], VELLUM) + tuple(p[1:]) for p in parts], 80) + y += 108 + + +def loupe(g, x, y, title, note, base, flist, framed, depth): + """`loupe`: the memory round a pointer's target, floating over the context, tied to the pointer it opens + from. Nine rows, the target's in the middle; the target framed bright. Lifted: its own surface, a shadow + under it, deeper for a loupe opened from another. Returns its rows' y.""" + h = ph(9) + sx, sy = (12, 16) if depth == 1 else (20, 26) + g.rect(x + sx, y + sy, CW, h, SHADE) + g.rect(x, y, CW, h, LIFT) + g.rect(x, y, CW, TAG, LIFT_TAG) + g.frame(x, y, CW, h, DIM, 2) + xx = x + 12 + for s_, ink in title: + g.t(xx, y + 18, s_, S, ink, MONO) + xx += len(s_) * A + g.t(x + CW - 10, y + 18, note, 18, DIM, "sans", "end") + return C.fields(g, y, h, "", base, 144, flist, MEM, HEAP, region, framed=framed, bare=True, x=x) + + +def stem(g, pts): + """The tie from a pointer to its loupe: a link, in the ink of what it points into, head on the loupe.""" + gen.arrow(g, pts, HEAP, 4, r=8, hl=12, hw=12) + + +# ---- the frames ---------------------------------------------------------------------------------------- +def frame_none(name, step, loupes=False): + """`none` on the 4K stage: source | disassembly | registers, backtrace, memory | stack.""" + g = Svg() + put(COL[0]) + ys = C.source(g, TOP4, 69, SRC, 1, 21, [], "list.c", 42) + put(COL[1]) + at = C.disasm(g, TOP4, window(69, step), "reverse", 21) + thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)]) + put(COL[2]) + marks = {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike" if step else "tick"}} + where = C.registers(g, TOP4, regs(step), FLAGS, marks) + C.backtrace(g, 548, 416, BT, x=COL[2], note="newest on top") + C.fields(g, 976, 808, "the heap, round what the step reads", 0x1004000, 512, + heap_fields(0x1004000, 512, 0x1004098), MEM, HEAP, region, marks=(9,) if step else (), title="memory") + put(COL[3]) + C.stack(g, TOP4, stack_rows(69), FRAMES, note="69 words from rsp", rsp=RSP, roles=roles(69)) + if loupes: + ry = where["rdi"] + x1, y1 = 2728, ry + r1 = loupe(g, x1, y1, [("rdi", DIM), (" → ", FAINT), ("1004070", HEAP)], "heap · struct node, 16 bytes", + 0x1004030, heap_fields(0x1004030, 144), [(0x1004070 - 0x1004030, 16)], 1) + stem(g, [(COL[2] + 72 + 7 * A + 30 + A + 16, ry + 12), (x1, ry + 12)]) # from the end of rdi's chain + # the next word in it opens the next: the field's bytes bracketed, a stem down into the deeper loupe + fy = r1[0x1004070] + bx0 = x1 + 132 + 8 * 30 + 12 - 4 + bx1 = x1 + 132 + 15 * 30 + 12 + 28 + g.rect(bx0, fy + ROW + 1, bx1 - bx0, 3, HEAP) + x2, y2 = x1 + 120, fy + ROW + 34 + loupe(g, x2, y2, [("1004078", HEAP), (" → ", FAINT), ("1004050", HEAP)], "heap · struct node, 16 bytes", + 0x1004010, heap_fields(0x1004010, 144), [(0x1004050 - 0x1004010, 16)], 2) + stem(g, [((bx0 + bx1) / 2, fy + ROW + 4), ((bx0 + bx1) / 2, y2)]) + clock4(g, 3 if step else 2, 4) + if loupes: + caption4(g, [[("The load is done: ",), ("rdi", "mono"), (" holds ",), ("1004070", "mono"), + (", and beside it the heap round it opens.",)], + [("Its ",), ("next", "mono"), (" word opens the node after it, one deeper.",)]]) + else: + caption4(g, [[("Stopped in ",), ("reverse", "mono"), (", about to load ",), ("head->next", "mono"), (".",)], + [("rdi", "mono"), (" points at a node; the word after its value is the next node.",)]]) + g.save(name) + + +def frame_subject(name): + """`subject` on the 4K stage, mid-step: the list drawn twice the size over the program's two columns, its + bytes over the third, the context under and beside them.""" + g = Svg() + band = 604 + put(COL[2]) + view = C.fields(g, TOP4, 800, "the heap, 1004000 to 10041ff", 0x1004000, 512, + heap_fields(0x1004000, 512, 0x1004098), MEM, HEAP, region, marks=(9,)) + where = C.registers(g, 908, regs(True), FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike"}}) + C.backtrace(g, 1360, 424, BT, x=COL[2], note="newest on top") + put(COL[0]) + pins = {0x10040b0: ["rcx"], 0x1004090: ["rax"], 0x1004070: ["rdi"]} + C.RX = COL[2] # the link leaves the registers, the projection the view + C.lens(g, TOP4, band, 800, NODES, pins, {"tick": [0x10040b8], "read": 0x1004098}, 0x1004000, 32, + link_from=(where["rdi"], "rdi"), subject=True, dw=2 * CW + 32, k=2, view_rows=view) + put(COL[0]) + ys = C.source(g, TOP4 + band + 12, 43, SRC, 1, 21, [], "list.c", 42) + put(COL[1]) + at = C.disasm(g, TOP4 + band + 12, window(43, True), "reverse", 21) + thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)]) + put(COL[3]) + C.stack(g, TOP4, stack_rows(69), FRAMES, note="69 words from rsp", rsp=RSP, roles=roles(69)) + clock4(g, 2, 4) + caption4(g, [[("The load read the word at ",), ("1004098", "mono"), (": the address of the next node.",)], + [("rdi", "mono"), (" holds it now, and points at the node whose value is 9.",)]]) + g.save(name) + + +def frame_marks(name): + """Mock 15: current, struck and held, as the first videos drew them (A), as the catalogue now does (B), and + the other reading of "white, with less opacity" (C), on real rows of the same moment and the one after.""" + g = Svg() + xs = [112, 1376, 2640] + titles = [("A", "the first videos: gold band, solid vermilion, a tick"), + ("B", "recommended: a white wash, a softened strike, a turned corner"), + ("C", "white: a white plaque, a white strike framed in vermilion, a bar under")] + g.t(112, 120, "current, struck, held", 40, BRIGHT, "sansm") + g.t(112, 164, "Rows of targets/list at the load in reverse (moment 3) and the store after it (moment 4), at the " + "4K stage's density: mono 20, rows of 24. Look at it at full size.", 24, DIM, "sans") + for (key, label), x in zip(titles, xs): + C.STYLE.update(current=key, struck=key, held=key) + g.t(x, 244, key, 56, GOLD if key == "B" else BRIGHT, "sansb") + g.t(x + 56, 236, label, 22, DIM, "sans") + put(x) + y = 280 + ys = C.source(g, y, 6, SRC, 18, 21, [20], "list.c", 42) + y += ph(6) + 24 + rows = [r for r in window(69, True) if 0x1001919 <= r[0] <= 0x100192e] + rows = [(a, ln, mn, ops, "trail0" if a == 0x1001923 else st, note) for a, ln, mn, ops, st, note in rows] + C.disasm(g, y, rows, "reverse", 21) + y += ph(len(rows)) + 24 + reg = [r for r in regs(True) if r[0] in ("rax", "rcx", "rsi", "rdi", "rbp")] + [regs(True)[-1]] + y0 = C.panel(g, x, y, CW, len(reg), "registers") + for i, (r, links, end) in enumerate(reg): + yy = y0 + i * ROW + if r == "rip": + g.t(x + 12, b(yy), r, S, C.current_row(g, x + 2, yy, CW - 4, 54), BOLD) + else: + g.t(x + 12, b(yy), r, S, DIM, MONO) + m = {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike"}}.get(r) + chain(g, x + 72, yy, links, end, m, room=x + CW - 12) + y += ph(len(reg)) + 24 + mem4 = dict(MEM) # moment 4: the store wrote 10040b0 into the word at 1004098 + for i, v in enumerate((0x10040b0).to_bytes(8, "little")): + mem4[0x1004098 + i] = v + flist = heap_fields(0x1004080, 64) + flist = [(a, n, r, bg, 7 if a == 0x18 else m) for a, n, r, bg, m in flist] + yr = C.fields(g, y, ph(4), "moment 4: the store, struck; 10040b8, held", 0x1004080, 64, flist, mem4, HEAP, + region, marks=()) + # struck on the run the store wrote, held on the one iteration 1 wrote (its own row, 10040b0's next) + r_y = yr[0x1004090] + x0 = x + 132 + 8 * 30 + 12 - 4 + ink = C.struck(g, x0, r_y, 30) # only the byte that changed: 70 to b0; 40 00 01 kept their value + g.t(x + 132 + 8 * 30 + 12, b(r_y), "b0", S, ink, BOLD) + C.held(g, x + 132 + 8 * 30 + 12, yr[0x10040b0], 8 * 30 - 6) + y += ph(4) + 36 + # a lens's cells, at the drawing's scale on this stage (2): a node held, a node struck + g.t(x, y, "in a lens's cell, twice the size", 20, DIM, "sansm") + y += 16 + for j, (lab, mark) in enumerate([("4", "held"), ("4", "struck")]): + cx = x + j * 300 + g.rect(cx, y, 152, 88, RAISED) + g.rect(cx + 152, y, 96, 88, C.WELL) + if mark == "struck": + ink = C.struck(g, cx, y - 1, 152, 90) + else: + ink = VELLUM + C.held_cell(g, cx + 152, y, 96, 88, 2) + g.t(cx + 76, y + 44 + 18, lab, 50, ink, "mono", "middle") + g.rect(cx + 190, y + 34, 20, 20, HEAP) + g.t(cx + 124, y + 118, mark, 20, DIM, "sansm", "middle") + # the same rows, closer: 1.4 times, for judging on a screen smaller than 4K + g.t(x, 1236, "the same, 1.35 times", 20, DIM, "sansm") + g.o.append('' % (x, 1256)) + put(0) + C.source(g, 0, 3, SRC, 19, 21, [20], "list.c", 42) + y0 = C.panel(g, 0, ph(3) + 16, CW, 4, "registers") + for i, r in enumerate([r for r in regs(True) if r[0] in ("rax", "rdi")] + [regs(True)[-1]]): + yy = y0 + i * ROW + nm, links, end = r + if nm == "rip": + g.t(12, b(yy), nm, S, C.current_row(g, 2, yy, CW - 4, 54), BOLD) + else: + g.t(12, b(yy), nm, S, DIM, MONO) + chain(g, 72, yy, links, end, {"rax": {0: "tick"}, "rdi": {0: "strike"}}.get(nm), room=CW - 12) + yy = y0 + 3 * ROW + g.t(12, b(yy), "rcx", S, DIM, MONO) + chain(g, 72, yy, [(0x10040b0, H_)], ("int", 1), {0: "tick"}, room=CW - 12) + g.o.append("") + put(x) + C.STYLE.update(current="B", struck="B", held="B") + g.save(name) + + +if __name__ == "__main__": + frame_marks("15-marks") + frame_none("16-none", False) + frame_subject("17-subject") + frame_none("18-loupes", True, loupes=True) diff --git a/design/mock/list-dbg.txt b/design/mock/list-dbg.txt new file mode 100644 index 0000000..14e8196 --- /dev/null +++ b/design/mock/list-dbg.txt @@ -0,0 +1,178 @@ +# ztrace dbg -o list.ztrace --stack 1024 -- ./list (env -i setarch -R), break at *0x1001926, the second stop; then si. +# moment 2 (stop) and moment 3 (after the load): registers, the stack from rsp, the heap from 0x1004000. +(ztrace) ctx +moment 2 of 3, 49 events so far + +thread 1131036 targets/list.c:21:35 + rax 1004090 + rbx 0 + rcx 10040b0 + rdx 0 + rsi 10040c0 + rdi 1004090 + rbp 7fffffffece0 —▸ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + rsp 7fffffffece0 —▸ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + r8 7ffff7e19ac0 + r9 20 + r10 10 + r11 7ffff7e19ac8 + r12 7fffffffee38 —▸ 7fffffffefea ◂— "./list" + r13 1 + r14 7ffff7ffd000 —▸ 7ffff7ffe3c0 ◂— 0 + r15 10029c0 ◂— 1 + rip 1001926 (reverse+22) + eflags 206 + + 000001001910 test rdi, rdi + 000001001913 je 0x1001935 + 000001001915 push rbp + 000001001916 mov rbp, rsp + 000001001919 xor eax, eax + 00000100191b nop dword ptr [rax + rax] + 000001001920 mov rcx, rax + 000001001923 mov rax, rdi + ► 000001001926 mov rdi, qword ptr [rdi + 8] + 00000100192a mov qword ptr [rax + 8], rcx + 00000100192e test rdi, rdi + 000001001931 jne 0x1001920 + 000001001933 pop rbp + 000001001934 ret + 000001001935 xor eax, eax + 000001001937 ret + + 00:0000│ rsp 7fffffffece0 —▸ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + 01:0008│ 7fffffffece8 —▸ 10018b0 (main+80) + 02:0010│ 7fffffffecf0 ◂— 7ffff7e20de8 + 03:0018│ 7fffffffecf8 ◂— 0 + 04:0020│ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + 05:0028│ 7fffffffed08 ◂— 7ffff7c27781 + 06:0030│ 7fffffffed10 —▸ 7ffff7fe0c60 (ld-linux-x86-64.so.2!22c60) + 07:0038│ 7fffffffed18 —▸ 7fffffffee38 —▸ 7fffffffefea ◂— "./list" + + #0 1001926 reverse+22 + #1 10018b0 main+80 + #2 7ffff7c27781 + #3 7ffff7c278b9 + #4 1001755 _start+37 + +(ztrace) x $rsp 1024 +7fffffffece0 00 ed ff ff ff 7f 00 00 b0 18 00 01 00 00 00 00 ................ +7fffffffecf0 e8 0d e2 f7 ff 7f 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffed00 b0 ed ff ff ff 7f 00 00 81 77 c2 f7 ff 7f 00 00 .........w...... +7fffffffed10 60 0c fe f7 ff 7f 00 00 38 ee ff ff ff 7f 00 00 `.......8....... +7fffffffed20 00 e0 fb f7 01 00 00 00 60 18 00 01 00 00 00 00 ........`....... +7fffffffed30 70 ed ff ff ff 7f 00 00 60 f2 fd f7 ff 7f 00 00 p.......`....... +7fffffffed40 00 00 00 00 00 00 00 00 1c 78 a5 95 fc 35 e3 1f .........x...5.. +7fffffffed50 38 ee ff ff ff 7f 00 00 01 00 00 00 00 00 00 00 8............... +7fffffffed60 00 d0 ff f7 ff 7f 00 00 c0 29 00 01 00 00 00 00 .........)...... +7fffffffed70 1c 78 e5 94 fc 35 e3 1f 1c 78 af a0 87 25 e3 1f .x...5...x...%.. +7fffffffed80 00 00 00 00 ff 7f 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffed90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffeda0 38 ee ff ff ff 7f 00 00 00 fb da b8 c6 f7 f6 15 8............... +7fffffffedb0 10 ee ff ff ff 7f 00 00 b9 78 c2 f7 ff 7f 00 00 .........x...... +7fffffffedc0 48 ee ff ff ff 7f 00 00 c0 29 00 01 00 00 00 00 H........)...... +7fffffffedd0 60 18 00 01 00 00 00 00 48 ee ff ff ff 7f 00 00 `.......H....... +7fffffffede0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffedf0 30 17 00 01 00 00 00 00 30 ee ff ff ff 7f 00 00 0.......0....... +7fffffffee00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffee10 00 00 00 00 00 00 00 00 55 17 00 01 00 00 00 00 ........U....... +7fffffffee20 28 ee ff ff ff 7f 00 00 38 00 00 00 00 00 00 00 (.......8....... +7fffffffee30 01 00 00 00 00 00 00 00 ea ef ff ff ff 7f 00 00 ................ +7fffffffee40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffee50 21 00 00 00 00 00 00 00 00 c0 fb f7 ff 7f 00 00 !............... +7fffffffee60 33 00 00 00 00 00 00 00 30 0e 00 00 00 00 00 00 3.......0....... +7fffffffee70 10 00 00 00 00 00 00 00 ff fb eb bf 00 00 00 00 ................ +7fffffffee80 06 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 ................ +7fffffffee90 11 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 ........d....... +7fffffffeea0 03 00 00 00 00 00 00 00 40 00 00 01 00 00 00 00 ........@....... +7fffffffeeb0 04 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 ........8....... +7fffffffeec0 05 00 00 00 00 00 00 00 0b 00 00 00 00 00 00 00 ................ +7fffffffeed0 07 00 00 00 00 00 00 00 00 e0 fb f7 ff 7f 00 00 ................ +7fffffffeee0 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffeef0 09 00 00 00 00 00 00 00 30 17 00 01 00 00 00 00 ........0....... +7fffffffef00 0b 00 00 00 00 00 00 00 e8 03 00 00 00 00 00 00 ................ +7fffffffef10 0c 00 00 00 00 00 00 00 e8 03 00 00 00 00 00 00 ................ +7fffffffef20 0d 00 00 00 00 00 00 00 e8 03 00 00 00 00 00 00 ................ +7fffffffef30 0e 00 00 00 00 00 00 00 e8 03 00 00 00 00 00 00 ................ +7fffffffef40 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffef50 19 00 00 00 00 00 00 00 c9 ef ff ff ff 7f 00 00 ................ +7fffffffef60 1a 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................ +7fffffffef70 1f 00 00 00 00 00 00 00 f1 ef ff ff ff 7f 00 00 ................ +7fffffffef80 0f 00 00 00 00 00 00 00 d9 ef ff ff ff 7f 00 00 ................ +7fffffffef90 1b 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +7fffffffefa0 1c 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ........@....... +7fffffffefb0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffefc0 00 00 00 00 00 00 00 00 00 84 c8 54 0f f6 1f c4 ...........T.... +7fffffffefd0 b2 f5 2b eb c7 65 9e 6d 65 78 38 36 5f 36 34 00 ..+..e.mex86_64. +7fffffffefe0 00 00 00 00 00 00 00 00 00 00 2e 2f 6c 69 73 74 .........../list +7fffffffeff0 00 2e 2f 6c 69 73 74 00 00 00 00 00 00 00 00 00 ../list......... +(ztrace) x 0x1004000 512 +000001004000 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004010 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 $............... +000001004020 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004030 19 00 00 00 00 00 00 00 10 40 00 01 00 00 00 00 .........@...... +000001004040 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004050 10 00 00 00 00 00 00 00 30 40 00 01 00 00 00 00 ........0@...... +000001004060 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004070 09 00 00 00 00 00 00 00 50 40 00 01 00 00 00 00 ........P@...... +000001004080 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004090 04 00 00 00 00 00 00 00 70 40 00 01 00 00 00 00 ........p@...... +0000010040a0 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +0000010040b0 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040c0 00 00 00 00 00 00 00 00 41 0f 02 00 00 00 00 00 ........A....... +0000010040d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +(ztrace) si +[3] step at 100192a reverse+26 (list.c:22) +(ztrace) x 0x1004000 512 +000001004000 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004010 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 $............... +000001004020 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004030 19 00 00 00 00 00 00 00 10 40 00 01 00 00 00 00 .........@...... +000001004040 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004050 10 00 00 00 00 00 00 00 30 40 00 01 00 00 00 00 ........0@...... +000001004060 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004070 09 00 00 00 00 00 00 00 50 40 00 01 00 00 00 00 ........P@...... +000001004080 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +000001004090 04 00 00 00 00 00 00 00 70 40 00 01 00 00 00 00 ........p@...... +0000010040a0 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... +0000010040b0 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040c0 00 00 00 00 00 00 00 00 41 0f 02 00 00 00 00 00 ........A....... +0000010040d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010040f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +000001004190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +0000010041f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +(ztrace) q +list3.ztrace: 4 moments diff --git a/design/mock/list.dis b/design/mock/list.dis new file mode 100644 index 0000000..7cdee2b --- /dev/null +++ b/design/mock/list.dis @@ -0,0 +1,263 @@ +0000000001001730 <_start>: +_start(): + 1001730: endbr64 + 1001734: xor ebp,ebp + 1001736: mov r9,rdx + 1001739: pop rsi + 100173a: mov rdx,rsp + 100173d: and rsp,0xfffffffffffffff0 + 1001741: push rax + 1001742: push rsp + 1001743: xor r8d,r8d + 1001746: xor ecx,ecx + 1001748: lea rdi,[rip+0x111] # 1001860
+ 100174f: call QWORD PTR [rip+0x141b] # 1002b70 <__libc_start_main@GLIBC_2.34> + 1001755: hlt + 1001756: cs nop WORD PTR [rax+rax*1+0x0] + +0000000001001760 <_dl_relocate_static_pie>: +_dl_relocate_static_pie(): + 1001760: endbr64 + 1001764: ret + 1001765: data16 cs nop WORD PTR [rax+rax*1+0x0] + +0000000001001770 <_dl_relocate_static_pie_ifunc>: +_dl_relocate_static_pie_ifunc(): + 1001770: endbr64 + 1001774: ret + 1001775: int3 + 1001776: int3 + 1001777: int3 + 1001778: int3 + 1001779: int3 + 100177a: int3 + 100177b: int3 + 100177c: int3 + 100177d: int3 + 100177e: int3 + 100177f: int3 + +0000000001001780 : +deregister_tm_clones(): + 1001780: mov eax,0x1003bd0 + 1001785: cmp rax,0x1003bd0 + 100178b: je 10017a0 + 100178d: mov rax,QWORD PTR [rip+0x13ec] # 1002b80 <_ITM_deregisterTMCloneTable> + 1001794: test rax,rax + 1001797: je 10017a0 + 1001799: mov edi,0x1003bd0 + 100179e: jmp rax + 10017a0: ret + 10017a1: nop DWORD PTR [rax+0x0] + 10017a5: data16 cs nop WORD PTR [rax+rax*1+0x0] + +00000000010017b0 : +register_tm_clones(): + 10017b0: mov esi,0x1003bd0 + 10017b5: sub rsi,0x1003bd0 + 10017bc: mov rax,rsi + 10017bf: shr rsi,0x3f + 10017c3: sar rax,0x3 + 10017c7: add rsi,rax + 10017ca: sar rsi,1 + 10017cd: je 10017e8 + 10017cf: mov rax,QWORD PTR [rip+0x13b2] # 1002b88 <_ITM_registerTMCloneTable> + 10017d6: test rax,rax + 10017d9: je 10017e8 + 10017db: mov edi,0x1003bd0 + 10017e0: jmp rax + 10017e2: nop WORD PTR [rax+rax*1+0x0] + 10017e8: ret + 10017e9: nop DWORD PTR [rax+0x0] + +00000000010017f0 <__do_global_dtors_aux>: +__do_global_dtors_aux(): + 10017f0: endbr64 + 10017f4: cmp BYTE PTR [rip+0x23d5],0x0 # 1003bd0 + 10017fb: jne 1001810 <__do_global_dtors_aux+0x20> + 10017fd: push rbp + 10017fe: mov rbp,rsp + 1001801: call 1001780 + 1001806: mov BYTE PTR [rip+0x23c3],0x1 # 1003bd0 + 100180d: pop rbp + 100180e: ret + 100180f: nop + 1001810: ret + 1001811: nop DWORD PTR [rax+0x0] + 1001815: data16 cs nop WORD PTR [rax+rax*1+0x0] + +0000000001001820 : +frame_dummy(): + 1001820: endbr64 + 1001824: jmp 10017b0 + 1001826: int3 + 1001827: int3 + 1001828: int3 + 1001829: int3 + 100182a: int3 + 100182b: int3 + 100182c: int3 + 100182d: int3 + 100182e: int3 + 100182f: int3 + +0000000001001830 : +list_done(): +targets/list.c:31 + 1001830: test rdi,rdi + 1001833: je 100184e + 1001835: push rbp + 1001836: mov rbp,rsp + 1001839: xor eax,eax + 100183b: nop DWORD PTR [rax+rax*1+0x0] + 1001840: add rax,QWORD PTR [rdi] + 1001843: mov rdi,QWORD PTR [rdi+0x8] + 1001847: test rdi,rdi + 100184a: jne 1001840 + 100184c: pop rbp +targets/list.c:32 + 100184d: ret + 100184e: xor eax,eax + 1001850: ret + 1001851: data16 data16 data16 data16 data16 cs nop WORD PTR [rax+rax*1+0x0] + +0000000001001860
: +main(): +targets/list.c:35 + 1001860: push rbp + 1001861: mov rbp,rsp + 1001864: push rbx + 1001865: push rax + 1001866: mov eax,0x6 +targets/list.c:36 + 100186b: cmp edi,0x2 + 100186e: jl 1001880 + 1001870: mov rdi,QWORD PTR [rsi+0x8] +atoi(): +/usr/include/stdlib.h:487 + 1001874: xor esi,esi + 1001876: mov edx,0xa + 100187b: call 1001980 +main(): +targets/list.c:38 + 1001880: test eax,eax + 1001882: jle 10018a6 + 1001884: mov ebx,eax + 1001886: xor eax,eax + 1001888: nop DWORD PTR [rax+rax*1+0x0] + 1001890: mov rsi,rbx + 1001893: imul rsi,rbx + 1001897: mov rdi,rax + 100189a: call 10018e0 + 100189f: dec rbx + 10018a2: jg 1001890 + 10018a4: jmp 10018a8 + 10018a6: xor eax,eax +targets/list.c:39 + 10018a8: mov rdi,rax + 10018ab: call 1001910 +targets/list.c:40 + 10018b0: mov rdi,rax + 10018b3: call 1001830 + 10018b8: lea rdi,[rip+0xffffffffffffed35] # 10005f4 <_IO_stdin_used+0x4> + 10018bf: mov rsi,rax + 10018c2: xor eax,eax + 10018c4: call 1001990 +targets/list.c:41 + 10018c9: xor eax,eax + 10018cb: add rsp,0x8 + 10018cf: pop rbx + 10018d0: pop rbp + 10018d1: ret + 10018d2: data16 data16 data16 data16 cs nop WORD PTR [rax+rax*1+0x0] + +00000000010018e0 : +push(): +targets/list.c:11 + 10018e0: push rbp + 10018e1: mov rbp,rsp + 10018e4: push r14 + 10018e6: push rbx + 10018e7: mov rbx,rsi + 10018ea: mov r14,rdi +targets/list.c:12 + 10018ed: mov edi,0x10 + 10018f2: call 10019a0 +targets/list.c:13 + 10018f7: mov QWORD PTR [rax],rbx +targets/list.c:14 + 10018fa: mov QWORD PTR [rax+0x8],r14 +targets/list.c:15 + 10018fe: pop rbx + 10018ff: pop r14 + 1001901: pop rbp + 1001902: ret + 1001903: data16 data16 data16 cs nop WORD PTR [rax+rax*1+0x0] + +0000000001001910 : +reverse(): +targets/list.c:20 + 1001910: test rdi,rdi + 1001913: je 1001935 + 1001915: push rbp + 1001916: mov rbp,rsp + 1001919: xor eax,eax + 100191b: nop DWORD PTR [rax+rax*1+0x0] + 1001920: mov rcx,rax + 1001923: mov rax,rdi +targets/list.c:21 + 1001926: mov rdi,QWORD PTR [rdi+0x8] +targets/list.c:22 + 100192a: mov QWORD PTR [rax+0x8],rcx +targets/list.c:20 + 100192e: test rdi,rdi + 1001931: jne 1001920 + 1001933: pop rbp +targets/list.c:26 + 1001934: ret + 1001935: xor eax,eax + 1001937: ret + +Disassembly of section .init: + +0000000001001938 <_init>: +_init(): + 1001938: endbr64 + 100193c: sub rsp,0x8 + 1001940: mov rax,QWORD PTR [rip+0x1231] # 1002b78 <__gmon_start__> + 1001947: test rax,rax + 100194a: je 100194e <_init+0x16> + 100194c: call rax + 100194e: add rsp,0x8 + 1001952: ret + +Disassembly of section .fini: + +0000000001001954 <_fini>: +_fini(): + 1001954: endbr64 + 1001958: sub rsp,0x8 + 100195c: add rsp,0x8 + 1001960: ret + +Disassembly of section .plt: + +0000000001001970 : + 1001970: push QWORD PTR [rip+0x1222] # 1002b98 <_GLOBAL_OFFSET_TABLE_+0x8> + 1001976: jmp QWORD PTR [rip+0x1224] # 1002ba0 <_GLOBAL_OFFSET_TABLE_+0x10> + 100197c: nop DWORD PTR [rax+0x0] + +0000000001001980 : + 1001980: jmp QWORD PTR [rip+0x1222] # 1002ba8 + 1001986: push 0x0 + 100198b: jmp 1001970 <_fini+0x1c> + +0000000001001990 : + 1001990: jmp QWORD PTR [rip+0x121a] # 1002bb0 + 1001996: push 0x1 + 100199b: jmp 1001970 <_fini+0x1c> + +00000000010019a0 : + 10019a0: jmp QWORD PTR [rip+0x1212] # 1002bb8 + 10019a6: push 0x2 + 10019ab: jmp 1001970 <_fini+0x1c> diff --git a/design/motion.md b/design/motion.md index 065ee86..24cc106 100644 --- a/design/motion.md +++ b/design/motion.md @@ -18,7 +18,7 @@ differently now: through a step at a walk or a run (the step's piece of gold fades in once its mark has landed), sweeping at a sprint. - In the context a strike arms with a 2-unit frame, pulses out 3 units, and - cools to nothing, leaving the `held` tick where this page says ember and + cools to nothing, leaving the `held` corner where this page says ember and bar. A lens's cell cools to a bar along its bottom edge. The cool starts with the advance, whenever that is. - Tags of variables and registers are `pin`s. A pin is one thing and @@ -46,8 +46,16 @@ differently now: and the registers (CPU), the stack's slots and the dump's bytes (memory), the drawing (the idea). The order and the 18 f between them are the same. -- The camera rests at x1.5 as well, and that is its usual scale: a frame - of 1195 by 560. At x2 the frame is 896 by 420. It always returns. +- The stage is 4K, 3840 by 2160 units, the context at the same type size + and four times as much of it. Every frame count here stands; every + distance a chart times by (200 and 400 units for a flight, 400 for a + link, 600 for a projection) doubles on it, since the same move on screen + is twice the units. The camera's rests are the same factors: x2 frames + 1920 by 1080 of the stage, the 1920 stage's density at 1080p. It always + returns. +- `current` is a white wash across the row and the gold plaque; a strike's + paper is a softened vermilion, and cools to nothing; `held` is a turned + corner, which fades in over the cool's last 6 f. ## What was measured @@ -335,11 +343,11 @@ always the same sub-chart: | Frames | A strike at frame s | | --- | --- | | s-12 to s | arm: a 3-unit frame in write's colour inside the cell's edge, in over 2 f; the old value unchanged | -| s to s+6 | the fill comes in, linear; the digits become the new value, bold, in ink, at s+3 | +| s to s+6 | the fill (`b54f42`) comes in, linear; the digits become the new value, bold, bright, at s+3 | | s to s+12 | pulse: the fill's edges go out 4 units and back, sine | | s+6 to the advance | solid (at least to s+36) | -| the advance to +24 | cool to the ember, on `glide`; the bar is under it from the start; digits to their ordinary face at its middle | -| then | ember and bar for three steps; out over 36 f, linear, in the step after | +| the advance to +24 | cool, on `glide`, the paper to nothing; digits to their ordinary face at its middle; the turned corner fades in over the last 6 f | +| then | the corner for three steps; out over 36 f, linear, in the step after | ### A register written @@ -424,8 +432,8 @@ Three levels shown: the registers, the stack, the tree | 12 to 24, 24 | arm, strike: `rsp`. Its pin stays on the window's top row: no link | | 30 to 48 | the stack's rows slide down one slot, `glide`, as rows making room do: the new top row comes in with them | | 48 to 60, 60 | arm, strike: the return address, in the new top row; the new frame's `call` span (gold, `fib(2)`) and its `backtrace` row fade in with the strike, the old ones going to rule and dim | -| 66 to 72 | the return address's bracket (`project`) | -| 72 to 102 | the projection draws from it up the gutter and along the drawing's bottom lane to the place of the new node, 30 f, `standard` | +| 66 to 72 | the new backtrace row's bracket (`project`): the frame the return address made | +| 72 to 102 | the projection draws from it into the gutter beside the drawing and along the drawing's bottom lane to the place of the new node, 30 f, `standard` | | 90 to 102 | the edge draws from the caller's node, arriving with the line | | 102 to 108 | the callee's node fades in gold; the caller's goes from gold to a waiting ring | | 108 to 144 | hold | @@ -443,8 +451,8 @@ in five frames). | 0 to 12 | fire on the `return` | | 6 to 18, 18 | arm, strike: `rax`, the answer | | 12 to 24, 24 | arm, strike: `rsp` | -| 42 to 48 | the return address framed as read (`ret` reads it), with its bracket | -| 48 to 78 | the projection, in read's colour, draws from it to the node, 30 f | +| 42 to 48 | the return address framed as read (`ret` reads it); the frame's backtrace row takes its bracket | +| 48 to 78 | the projection, in read's colour, draws from that row to the node, 30 f | | 78 to 90, 90 | arm, strike: the node's result on its shoulder, rax's digits; the node goes from gold to done, the caller from waiting to gold | | 96 to 108 | the frame's span and backtrace row fade out, `exit` | | 108 to 126 | the stack's rows slide up to the new rsp, `glide` | @@ -523,6 +531,25 @@ The levels are the cascade's; what is in them is not one write each. A dozen registers struck on one frame is a flash that says only "a lot"; the wave says it in about 0.6 s and lets the eye run down the panel with it. +### A pointer opened + +A `loupe`, on a beat the caption names: `rdi` has just taken the next +node, and the heap round it is opened beside it. + +| Frames | | +| --- | --- | +| p to p+6 | the pointer's hop framed as read | +| p+6 to p+24 | the stem draws from the end of its row to the loupe's place, head first, `standard` (30 f where it is longer than 1200 units) | +| p+6 to p+24 | the loupe rises with it: fading in over 12 f from 8 units lower, its shadow growing from nothing to 12 and 16 over 18 f, `standard` | +| p+30 to p+36 | its target's bright frame | +| p+36 to p+96 | held: the caption reads it | +| q to q+36 | from a pointer inside it, the next opens the same way, over its lower rows, its shadow 20 and 26 | +| the advance after | close, the deepest first: the stem draws back (12 f), the loupe sinks, fading as it falls 8 units (12 f); the other 6 f after | + +Two loupes at most; a third closes the first as it rises. Nothing else +moves while a loupe rises: it is a beat of its own, or the idea's slot of +a step, never two at once. At a run or a sprint none opens. + ### A swap The compare in the step before is its anticipation: both cells framed as @@ -584,11 +611,14 @@ will write are in its middle, with `free` slots above rsp for the pushes. A push fills one of them; rsp's pin climbs to it (24 f, `glide`), rbp's travels the same way, and no row of the panel moves. -The frame at x2 is 896 by 384 units, on the 24-unit grid: the panel's tag -and as many whole rows as fit, with the rows the next steps will change in -the middle third. If they move out of it the frame glides a whole row -(24 f) between steps. The stage clips what the camera shows at y = 112 and -888. Two seconds at x2 without a change and the camera should not be there. +The frame at x2 is 1920 by 1080 units of the 4K stage, on the 24-unit +grid: two columns' panel tags and as many whole rows as fit (45), with the +rows the next steps will change in the middle third. If they move out of it +the frame glides a whole row (24 f) between steps. The stage clips what the +camera shows at its own edges, 96 and 1784. At x2 the context reads at +1080p as the 1920 stage did, so the camera is how a scene meant for small +screens reads a detail; two seconds at x2 without a change and it should +not be there. ### Captions, opening, closing -- cgit v1.3