From 4862e778af7779bbdb047b9c71adfb62add319b2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 14:17:43 -0300 Subject: design: the disassembly stays under the source; the graph as a track From the user, on the sort render. Registers a scene never changes fold three to a row, so the stack is twelve to fifteen slots and the disassembly keeps its place under the source with eleven to seventeen rows; a blocks lens has no view. The graph leaves the layered picture of the reverse-engineering tools: blocks are pills on one line in the order they run, a loop an arch over its blocks with the turn count at its centre, every bend a quarter circle; sort's eleven blocks and both loops are seen whole across the band. Sheets 42 and 43 set the layouts and the graph's forms side by side. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- design/mock/22-graph-sort.png | Bin 226841 -> 241323 bytes design/mock/22-graph-sort.svg | 591 ++++++----- design/mock/23-graph-open.png | Bin 169887 -> 152825 bytes design/mock/23-graph-open.svg | 450 ++++----- design/mock/24-graph-strip.png | Bin 155495 -> 64854 bytes design/mock/24-graph-strip.svg | 714 +++---------- design/mock/25-blocks-lens-480.png | Bin 32015 -> 36257 bytes design/mock/25-blocks-lens.png | Bin 191630 -> 216534 bytes design/mock/25-blocks-lens.svg | 1279 +++++++++++++++-------- design/mock/40-frame-beside-480.png | Bin 0 -> 38575 bytes design/mock/40-frame-beside.png | Bin 0 -> 238996 bytes design/mock/40-frame-beside.svg | 1848 ++++++++++++++++++++++++++++++++++ design/mock/41-frame-subject-480.png | Bin 0 -> 39616 bytes design/mock/41-frame-subject.png | Bin 0 -> 235341 bytes design/mock/41-frame-subject.svg | 1816 +++++++++++++++++++++++++++++++++ design/mock/42-frame-layouts.png | Bin 0 -> 360073 bytes design/mock/43-graph-forms.png | Bin 0 -> 220933 bytes design/mock/43-graph-forms.svg | 311 ++++++ design/mock/context.py | 34 +- design/mock/frame.py | 410 ++++++++ design/mock/graph.py | 724 ++++++++++--- design/mock/sort-O0.dis | 61 -- design/mock/sort-clang.dis | 106 ++ design/mock/sort-dbg.txt | 151 +++ 24 files changed, 6737 insertions(+), 1758 deletions(-) create mode 100644 design/mock/40-frame-beside-480.png create mode 100644 design/mock/40-frame-beside.png create mode 100644 design/mock/40-frame-beside.svg create mode 100644 design/mock/41-frame-subject-480.png create mode 100644 design/mock/41-frame-subject.png create mode 100644 design/mock/41-frame-subject.svg create mode 100644 design/mock/42-frame-layouts.png create mode 100644 design/mock/43-graph-forms.png create mode 100644 design/mock/43-graph-forms.svg create mode 100644 design/mock/frame.py delete mode 100644 design/mock/sort-O0.dis create mode 100644 design/mock/sort-clang.dis create mode 100644 design/mock/sort-dbg.txt (limited to 'design/mock') diff --git a/design/mock/22-graph-sort.png b/design/mock/22-graph-sort.png index b77304a..d536ca4 100644 Binary files a/design/mock/22-graph-sort.png and b/design/mock/22-graph-sort.png differ diff --git a/design/mock/22-graph-sort.svg b/design/mock/22-graph-sort.svg index 21d4041..b30ffe4 100644 --- a/design/mock/22-graph-sort.svg +++ b/design/mock/22-graph-sort.svg @@ -1,6 +1,6 @@ - + - + @@ -122,7 +122,7 @@ ] ) { - + 13 swap ( @@ -141,7 +141,7 @@ ] ) ; - + 14 j - @@ -173,281 +173,314 @@ ; 22 } -the map: sort's disassembly as its graph, two columns wide (1024 to 2816), at moment 370 of 465 in sort - - +the map: sort's disassembly as its track, in the second column (1024 to 1904), at the 11th compare + + disassembly · sort -its blocks · visits so far · the edges the run took - - - - -6 - - - - - - - - -11 - - -5 - - -5 - - -×5 - - -×5 - - - -401143 -lines 9 to 10 -×1 -+0 -9 -push -rbp -+1 -mov -rbp, rsp -+4 -sub -rsp, 0x18 -+8 -mov -[rbp - 0x14], edi -+b -10 -mov -[rbp - 8] - - - - -, 1 -+12 -jmp -4011e1 - - - -40115a -lines 11 to 12 -×6 -+17 -11 -mov -eax, [rbp - 8] -+1a -mov -[rbp - 4], eax -+1d -12 -jmp -4011a2 - - - -401162 -lines 13 to 14 -×5 -+1f -13 -mov -eax, [rbp - 4] -+22 -cdqe - -+24 -lea -rdx, [rax*4] -+2c -lea -rax, [rip + 0x2eaa] -+33 -add -rdx, rax -+36 -mov -eax, [rbp - 4] -+39 -sub -eax, 1 -+3c -cdqe - -+3e -lea -rcx, [rax*4] -+46 -lea -rax, [rip + 0x2e90] -+4d -add -rax, rcx -+50 -mov -rsi, rdx -+53 -mov -rdi, rax -+56 -call -401116 - - -swap -+5b -14 -sub -[rbp - 4] - - - - -, 1 - - - -4011a2 -line 12 -×11 -+5f -12 -cmp -[rbp - 4] - - - - -, 0 -+63 -jle -4011dd - - - -4011a8 -line 12 -×11 -+65 -12 -mov -eax, [rbp - 4] -+68 -sub -eax, 1 -+6b -cdqe - -+6d -lea -rdx, [rax*4] -+75 -lea -rax, [rip + 0x2e61] -+7c -mov -edx, [rdx + rax*1] -404030 -◂ -17 -+7f -mov -eax, [rbp - 4] -+82 -cdqe - -+84 -lea -rcx, [rax*4] - -+8c -lea -rax, [rip + 0x2e4a] - -+93 -mov -eax, [rcx + rax*1] -404034 -◂ -5 - -+96 -cmp -edx, eax -17 - : -5 - -zf - sf - of - - - -+98 -jg -401162 -taken - · reads zf sf of - - - -4011dd -line 10 -×5 -+9a -10 -add -[rbp - 8] - - - - -, 1 - - - -4011e1 -line 10 -×6 -+9e -10 -mov -eax, [rbp - 8] -+a1 -cmp -eax, [rbp - 0x14] -+a4 -jl -40115a - - - -4011ed -line 17 -+aa -17 -nop - -+ab -nop - -+ac -leave - -+ad -ret - - - +its blocks · visits · the edges taken · the loops' turns + + + + + + + + + + + + + + + + + + + + + + + + + + +×5 +×5 + + + +401150 +lines 9 to 10 +×1 ++0 +9 +push +rbp ++1 +mov +rbp, rsp ++4 +sub +rsp, 0x10 ++8 +mov +[rbp - 4], edi ++b +10 +mov +[rbp - 8] + + + + +, 1 + + + +401162 +line 10 +×6 ++12 +10 +mov +eax, [rbp - 8] ++15 +cmp +eax, [rbp - 4] ++18 +jge +4011f7 +taken 0 · not 6 + + + +40116e +line 11 +×6 ++1e +11 +mov +eax, [rbp - 8] ++21 +mov +[rbp - 0xc], eax + + + +401174 +line 12 +×11 ++24 +12 +xor +eax, eax ++26 +cmp +[rbp - 0xc] + + + + +, 0 ++2a +mov +[rbp - 0xd], al ++2d +jle +4011a6 +taken 0 · not 11 + + + +40117f +line 12 +×11 ++2f +12 +mov +eax, [rbp - 0xc] ++32 +sub +eax, 1 ++35 +movsxd +rcx, eax ++38 +lea +rax, [rip + 0x2e81] ++3f +mov +eax, [rax + rcx*4] ++42 +movsxd +rdx, [rbp - 0xc] + + + + + ++46 +lea +rcx, [rip + 0x2e73] ++4d +cmp +eax, [rcx + rdx*4] ++50 +setg +al ++53 +mov +[rbp - 0xd], al + + + +4011a6 +line 12 +×11 + ++56 +12 +mov +al, [rbp - 0xd] +7fffffffecd3 +◂ +1 + ++59 +test +al, 1 +1 + : +1 + +zf + + + ++5b +jne +4011af +taken + · reads zf + + + +4011af +lines 12 to 14 +×5 ++5f +13 +mov +eax, [rbp - 0xc] ++62 +sub +eax, 1 ++65 +cdqe + ++67 +lea +rdi, [rip + 0x2e52] ++6e +shl +rax, 2 ++72 +add +rdi, rax ++75 +movsxd +rax, [rbp - 0xc] + + + + + ++79 +lea +rsi, [rip + 0x2e40] ++80 +shl +rax, 2 ++84 +add +rsi, rax ++87 +call +401120 + + +swap ++8c +14 +mov +eax, [rbp - 0xc] ++8f +add +eax, 0xffffffff ++92 +mov +[rbp - 0xc], eax ++95 +12 +jmp +401174 + + + +4011ad +line 12 +×5 ++5d +12 +jmp +4011e7 + + + +4011e7 +line 16 +×5 ++97 +16 +jmp +4011e9 + + + +4011e9 +line 10 +×5 ++99 +10 +mov +eax, [rbp - 8] ++9c +add +eax, 1 ++9f +mov +[rbp - 8], eax ++a2 +jmp +401162 + + + +4011f7 +line 17 ++a7 +17 +add +rsp, 0x10 ++ab +pop +rbp ++ac +ret + + + + +the map's stage ends at 1784 diff --git a/design/mock/23-graph-open.png b/design/mock/23-graph-open.png index 20b08c6..1c3e8df 100644 Binary files a/design/mock/23-graph-open.png and b/design/mock/23-graph-open.png differ diff --git a/design/mock/23-graph-open.svg b/design/mock/23-graph-open.svg index f6154e7..0d7e9aa 100644 --- a/design/mock/23-graph-open.svg +++ b/design/mock/23-graph-open.svg @@ -1,229 +1,229 @@ - + - -the map: libc's open as its graph · 19 blocks, the run reached 8 so far; the 11 it never reached are folded into five boxes - - + +the map: libc's open as its track · 19 blocks, the run reached 8; the 11 never reached folded + + disassembly · open · libc.so.6 -no source · 19 blocks · folded: 11 never reached - - - - -1 - - - - -1 - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -7ffff7d10ec0 -×1 -+0 -endbr64 - -+4 -push -rbp -+5 -mov -rbp, rsp -+8 -sub -rsp, 0x70 -+c -mov -[rbp - 0x30], rdx -+10 -mov -rax, fs:0x28 -+19 -mov -[rbp - 0x48], rax -+1d -xor -eax, eax -+1f -test -sil, 0x40 -+23 -jne -7ffff7d10f90 - - - -7ffff7d10ee9 -×1 -+29 -mov -eax, esi -+2b -xor -r10d, r10d -+2e -not -eax -+30 -test -eax, 0x410000 -+35 -je -7ffff7d10f90 - - - -7ffff7d10efb -×1 -+3b -mov -r11, fs:0x10 -+44 -movsxd -rdx, esi -+47 -mov -eax, [r11 + 0x308] -+4e -cmp -[rip + 0x11018b] - -, 0 -+55 -jne -7ffff7d10fb0 - - - -7ffff7d10fb0 -×1 -+f0 -mov -rsi, rdi -+f3 -xor -r9d, r9d - -+f6 -xor -r8d, r8d - -+f9 -mov -rdi, 0xffffffffffffff9c - -+100 -mov -eax, 0x101 - - - -+105 -syscall - -openat - nr 257 -+107 -mov -rdx, rax - - - -7ffff7d10fca -+10a -cmp -rax, 0xfffffffffffff000 -+110 -ja -7ffff7d10fe8 - - - -7ffff7d10fd2 -+112 -mov -eax, edx - - - -7ffff7d10fd4 -+114 -mov -rdx, [rbp - 0x48] -+118 -sub -rdx, fs:0x28 -+121 -jne -7ffff7d10fec - - - -7ffff7d10fe3 -+123 -leave - -+124 -ret - - - - - -+d0 to +eb -never reached -the O_CREAT path: the mode from the varargs - - -+5b to +b3 -4 blocks never reached -multi-threaded: a cancellable call - - -+128 to +cd -3 blocks never reached -an error: errno set, -1 returned - - -+136 to +149 -2 blocks never reached -cancelled - - -+12c to +130 -2 blocks never reached -the canary broken +no source · 19 blocks · folded: 11 never reached + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +7ffff7d10ec0 +×1 ++0 +endbr64 + ++4 +push +rbp ++5 +mov +rbp, rsp ++8 +sub +rsp, 0x70 ++c +mov +[rbp - 0x30], rdx ++10 +mov +rax, fs:0x28 ++19 +mov +[rbp - 0x48], rax ++1d +xor +eax, eax ++1f +test +sil, 0x40 ++23 +jne +7ffff7d10f90 +taken 0 · not 1 + + + +7ffff7d10ee9 +×1 ++29 +mov +eax, esi ++2b +xor +r10d, r10d ++2e +not +eax ++30 +test +eax, 0x410000 ++35 +je +7ffff7d10f90 +taken 0 · not 1 + + ++d0 to +eb +never reached +the O_CREAT path: the mode from the varargs + + + +7ffff7d10efb +×1 ++3b +mov +r11, fs:0x10 ++44 +movsxd +rdx, esi ++47 +mov +eax, [r11 + 0x308] ++4e +cmp +[rip + 0x11018b] + +, 0 ++55 +jne +7ffff7d10fb0 +taken 1 · not 0 + + ++5b to +b3 +4 blocks never reached +multi-threaded: a cancellable call + + + +7ffff7d10fb0 +×1 ++f0 +mov +rsi, rdi ++f3 +xor +r9d, r9d + ++f6 +xor +r8d, r8d + ++f9 +mov +rdi, 0xffffffffffffff9c + ++100 +mov +eax, 0x101 + + + ++105 +syscall + +openat + nr 257 ++107 +mov +rdx, rax + + ++136 to +149 +2 blocks never reached +cancelled + + + +7ffff7d10fca ++10a +cmp +rax, 0xfffffffffffff000 ++110 +ja +7ffff7d10fe8 + + + +7ffff7d10fd2 ++112 +mov +eax, edx + + ++128 to +cd +3 blocks never reached +an error: errno set, -1 returned + + + +7ffff7d10fd4 ++114 +mov +rdx, [rbp - 0x48] ++118 +sub +rdx, fs:0x28 ++121 +jne +7ffff7d10fec + + ++12c to +130 +2 blocks never reached +the canary broken + + + +7ffff7d10fe3 ++123 +leave + ++124 +ret + + + diff --git a/design/mock/24-graph-strip.png b/design/mock/24-graph-strip.png index 390a859..2c1bf80 100644 Binary files a/design/mock/24-graph-strip.png and b/design/mock/24-graph-strip.png differ diff --git a/design/mock/24-graph-strip.svg b/design/mock/24-graph-strip.svg index e9db6d9..fda1525 100644 --- a/design/mock/24-graph-strip.svg +++ b/design/mock/24-graph-strip.svg @@ -1,596 +1,122 @@ - + - - -1 -the condition -cur at jne, the compare's chips framed; the second turn - - - -disassembly · reverse - - - - - -1 - - - - -×1 - - - -401188 -lines 17 to 20 -×1 -+0 -17 -push -rbp -+1 -mov -rbp, rsp -+4 -18 -mov -[rbp - 0x18] - - - - - - - - -, 0 -+c -19 -mov -rax, [rip + 0x2e7d] -+13 -mov -[rbp - 0x10], rax -+17 -20 -jmp -4011c9 - - - -4011a1 -lines 21 to 24 -×1 -+19 -21 -mov -rax, [rbp - 0x10] -+1d -mov -rax, [rax + 8] -+21 -mov -[rbp - 8], rax -+25 -22 -mov -rax, [rbp - 0x10] -+29 -mov -rdx, [rbp - 0x18] -+2d -mov -[rax + 8], rdx -+31 -23 -mov -rax, [rbp - 0x10] -+35 -mov -[rbp - 0x18], rax -+39 -24 -mov -rax, [rbp - 8] -+3d -mov -[rbp - 0x10], rax - - - -4011c9 -line 20 -×2 -+41 -20 -cmp -[rbp - 0x10] - - - - - - - - -, 0 -1004070 - : -0 - -zf - - - -+46 -jne -4011a1 -taken - · reads zf - - - -4011d0 -lines 26 to 27 -+48 -26 -mov -rax, [rbp - 0x18] -+4c -mov -[rip + 0x2e3d], rax -+53 -27 -nop - -+54 -pop -rbp -+55 -ret - - - - - -2 -the edge taken -the edge lit gold, the mark on it, halfway - - - -disassembly · reverse - - - - - -2 - - - - -×1 - - - -401188 -lines 17 to 20 -×1 -+0 -17 -push -rbp -+1 -mov -rbp, rsp -+4 -18 -mov -[rbp - 0x18] - - - - - - - - -, 0 -+c -19 -mov -rax, [rip + 0x2e7d] -+13 -mov -[rbp - 0x10], rax -+17 -20 -jmp -4011c9 - - - -4011a1 -lines 21 to 24 -×2 -+19 -21 -mov -rax, [rbp - 0x10] -+1d -mov -rax, [rax + 8] -+21 -mov -[rbp - 8], rax -+25 -22 -mov -rax, [rbp - 0x10] -+29 -mov -rdx, [rbp - 0x18] -+2d -mov -[rax + 8], rdx -+31 -23 -mov -rax, [rbp - 0x10] -+35 -mov -[rbp - 0x18], rax -+39 -24 -mov -rax, [rbp - 8] -+3d -mov -[rbp - 0x10], rax - - - -4011c9 -line 20 -×2 -+41 -20 -cmp -[rbp - 0x10] - - - - - - - - -, 0 -+46 -jne -4011a1 - - - -4011d0 -lines 26 to 27 -+48 -26 -mov -rax, [rbp - 0x18] -+4c -mov -[rip + 0x2e3d], rax -+53 -27 -nop - -+54 -pop -rbp -+55 -ret - - - - - - - -3 -the loop's turn -the back edge climbs, the mark on it; its count struck: the second turn - - - -disassembly · reverse - - - - - -2 - - - - - -×2 - - - -401188 -lines 17 to 20 -×1 -+0 -17 -push -rbp -+1 -mov -rbp, rsp -+4 -18 -mov -[rbp - 0x18] - - - - - - - - -, 0 -+c -19 -mov -rax, [rip + 0x2e7d] -+13 -mov -[rbp - 0x10], rax -+17 -20 -jmp -4011c9 - - - -4011a1 -lines 21 to 24 -×2 -+19 -21 -mov -rax, [rbp - 0x10] -+1d -mov -rax, [rax + 8] -+21 -mov -[rbp - 8], rax -+25 -22 -mov -rax, [rbp - 0x10] -+29 -mov -rdx, [rbp - 0x18] -+2d -mov -[rax + 8], rdx -+31 -23 -mov -rax, [rbp - 0x10] -+35 -mov -[rbp - 0x18], rax -+39 -24 -mov -rax, [rbp - 8] -+3d -mov -[rbp - 0x10], rax - - - -4011c9 -line 20 -×3 -+41 -20 -cmp -[rbp - 0x10] - - - - - - - - -, 0 -+46 -jne -4011a1 - - - -4011d0 -lines 26 to 27 -+48 -26 -mov -rax, [rbp - 0x18] -+4c -mov -[rip + 0x2e3d], rax -+53 -27 -nop - -+54 -pop -rbp -+55 -ret - - - - - - - -4 -the way out -not taken: down to the exit, landed - - - -disassembly · reverse - - - - - -3 - - -1 - - -×3 - - - -401188 -lines 17 to 20 -×1 -+0 -17 -push -rbp -+1 -mov -rbp, rsp -+4 -18 -mov -[rbp - 0x18] - - - - - - - - -, 0 -+c -19 -mov -rax, [rip + 0x2e7d] -+13 -mov -[rbp - 0x10], rax -+17 -20 -jmp -4011c9 - - - -4011a1 -lines 21 to 24 -×3 -+19 -21 -mov -rax, [rbp - 0x10] -+1d -mov -rax, [rax + 8] -+21 -mov -[rbp - 8], rax -+25 -22 -mov -rax, [rbp - 0x10] -+29 -mov -rdx, [rbp - 0x18] -+2d -mov -[rax + 8], rdx -+31 -23 -mov -rax, [rbp - 0x10] -+35 -mov -[rbp - 0x18], rax -+39 -24 -mov -rax, [rbp - 8] -+3d -mov -[rbp - 0x10], rax - - - -4011c9 -line 20 -×4 -+41 -20 -cmp -[rbp - 0x10] - - - - - - - - -, 0 -+46 -jne -4011a1 - - - -4011d0 -lines 26 to 27 -×1 - - - -+48 -26 -mov -rax, [rbp - 0x18] -+4c -mov -[rip + 0x2e3d], rax -+53 -27 -nop - -+54 -pop -rbp -+55 -ret - - - - + +1 +the condition +the pc on jne in the test's block, the second time; its two ways out + + + +the blocks of reverse +its blocks · the visits · the path · the loops' turns + + + + + + + + +×1 + ++0 +×1 + ++41 +×2 + ++19 +×1 + ++48 +2 +the edge taken +taken: along the line to the body, the mark on the edge, landing + + + +the blocks of reverse +its blocks · the visits · the path · the loops' turns + + + + + + + + +×1 + ++0 +×1 + ++41 +×2 + ++19 +×1 + ++48 + + +3 +the loop's turn +back over the arch to the test, the mark coming round; the count struck as it lands + + + +the blocks of reverse +its blocks · the visits · the path · the loops' turns + + + + + + + + + +×2 + ++0 +×1 + ++41 +×2 + ++19 +×2 + ++48 + + +4 +the way out +not taken, the fourth time: under the body to the exit, landed + + + +the blocks of reverse +its blocks · the visits · the path · the loops' turns + + + + + + + + +×3 + ++0 +×1 + ++41 +×4 + ++19 +×3 + ++48 +×1 diff --git a/design/mock/25-blocks-lens-480.png b/design/mock/25-blocks-lens-480.png index 80276c3..af3d2b6 100644 Binary files a/design/mock/25-blocks-lens-480.png and b/design/mock/25-blocks-lens-480.png differ diff --git a/design/mock/25-blocks-lens.png b/design/mock/25-blocks-lens.png index 1a348eb..468aee9 100644 Binary files a/design/mock/25-blocks-lens.png and b/design/mock/25-blocks-lens.png differ diff --git a/design/mock/25-blocks-lens.svg b/design/mock/25-blocks-lens.svg index 3504f8e..5041b62 100644 --- a/design/mock/25-blocks-lens.svg +++ b/design/mock/25-blocks-lens.svg @@ -1,294 +1,259 @@ - - + + the blocks of sort -its blocks · the visits · the path - - - - - - - - - - - - - - - - - - -×5 - - -×5 - - -+0 -×1 - - -+17 -×6 - - -+1f -×5 - - -+5f -×11 - - -+65 -×11 - - -+9a -×5 - - -+9e -×6 - - -+aa - - - -disassembly -sort · +84 to +a1 -4011 -c7 -12 -lea -rcx, [rax*4] - -4011 -cf -lea -rax, [rip + 0x2e4a] - -4011 -d6 -mov -eax, [rcx + rax*1] -404034 -◂ -5 - -4011 -d9 -cmp -edx, eax -17 - : -5 - -zf - sf - of - - - -4011 -db -jg -401162 -taken - · reads zf sf of -4011 -dd -10 -add -[rbp - 8] - - - - -, 1 -4011 -e1 -mov -eax, [rbp - 8] - - - -sort.c -lines 1 to 21 of 22 -1 -int -a -[ -8 -] -= -{ -4 -, -9 -, -17 -, -31 -, -12 -, -26 -, -5 -, -20 -} -; -2 -3 -void -swap -( -int -* -x -, -int -* -y -) -{ -4 -int -t -= -* -x -; -5 -* -x -= -* -y -; -6 -* -y -= -t -; -7 -} -8 -9 -void -sort -( -int -n -) -{ -10 -for -( -int -i -= -1 -; -i -< -n -; -i -+ -+ -) -{ -11 -int -j -= -i -; - - -12 -while -( -j -> -0 -& -& -a -[ -j -- -1 -] -> -a -[ -j -] -) -{ - -13 -swap -( -& -a -[ -j -- -1 -] -, -& -a -[ -j -] -) -; - -14 -j -- -- -; -15 -} -16 -} -17 -} -18 -19 -int -main -( -void -) -{ -20 -sort -( -8 -) -; -21 -return -0 -; +its blocks · the visits · the path · the loops' turns + + + + + + + + + + + + + + + + + + + + + + + + + + +×5 +×5 + ++0 +×1 + ++12 +×6 + ++1e +×6 + ++24 +×11 + ++2f +×11 + ++56 +×11 + ++5f +×5 + +swap + ++5d +×5 + ++97 +×5 + ++99 +×5 + ++a7 + + + +sort.c +lines 8 to 15 of 22 +8 +9 +void +sort +( +int +n +) +{ +10 +for +( +int +i += +1 +; +i +< +n +; +i ++ ++ +) +{ +11 +int +j += +i +; + + +12 +while +( +j +> +0 +& +& +a +[ +j +- +1 +] +> +a +[ +j +] +) +{ + +13 +swap +( +& +a +[ +j +- +1 +] +, +& +a +[ +j +] +) +; + +14 +j +- +- +; +15 +} + + + +disassembly +sort +4011 +92 +12 +movsxd +rdx, [rbp - 0xc] + + + + + +4011 +96 +lea +rcx, [rip + 0x2e73] +4011 +9d +cmp +eax, [rcx + rdx*4] +4011 +a0 +setg +al + +4011 +a3 +mov +[rbp - 0xd], al +7fffffffecd3 +◂ +1 + +4011 +a6 +mov +al, [rbp - 0xd] +7fffffffecd3 +◂ +1 + +4011 +a9 +test +al, 1 +1 + : +1 + +zf + + + +4011 +ab +jne +4011af +taken + · reads zf +4011 +ad +jmp +4011e7 +4011 +af +13 +mov +eax, [rbp - 0xc] +4011 +b2 +sub +eax, 1 +4011 +b5 +cdqe + +4011 +b7 +lea +rdi, [rip + 0x2e52] +4011 +be +shl +rax, 2 +4011 +c2 +add +rdi, rax + +×11 + +×5 + +×5 - + registers stack @@ -298,167 +263,621 @@ rwx read-only + +rbx +0 +r8 +7ffff7e19680 +r9 +7ffff7e1afa0 +r10 +7fffffffea60 + + + + + +r11 +7ffff7ffca90 + + + + + +r12 +7fffffffee38 + + + + + +r13 +1 +r14 +7ffff7ffd000 + + + + + +r15 +403e10 + + + + + rax -5 - -rbx -0 -rcx -0x10 -16 -rdx -0x11 -17 - -rsi -404034 +1 +rcx +404010 + + +0x900000004 +rdx +4 +rsi +404024 + + +0x1f0000001a +rdi +404020 -0x1f0000001a -rdi -404030 - - -0x1a00000005 -rbp -7fffffffecf0 - - -7fffffffed00 - - -7fffffffedb0 - - -7fffffffee10 - - -0 -rsp -7fffffffecd8 - - -0x800000000 -r8 -7ffff7e19680 -r9 -7ffff7e1afa0 -r10 -7fffffffea60 - - -0 -r11 -7ffff7ffca90 - - -0x786843bb9f54c5c1 -r12 -7fffffffee38 - - -7fffffffefea - - -"./sort" -r13 -1 -r14 -7ffff7ffd000 - - -7ffff7ffe3c0 - - -0 -r15 -403e10 - - -4010e0 -__do_global_dtors_aux - - -rip -4011db -sort+152 -cf - -PF - -AF -zf -sf - -IF -df -of - - - -stack -six words from rsp · the frames they belong to -rsp - -+0 +0x1a00000005 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffecd0 + + +0x401000000 + + +rip +4011ab +sort+91 +cf + +pf + +af +zf +sf + +IF +df +of + + + +stack +twelve words from rsp · the frames they belong to +rsp + ++0 +j, high half +7fffffffe +cd0 + + +0x401000000 ++8 +i, n +7fffffffe +cd8 + + +0x800000006 +rbp + ++10 +saved rbp +7fffffffe +ce0 + + +7fffffffed00 + + + + + ++18 +7fffffffe +ce8 + + +401219 +main+25 ++20 +7fffffffe +cf0 + + +0 ++28 +7fffffffe +cf8 + + +0 ++30 +saved rbp 7fffffffe -cd8 - - -0x800000000 -+8 +d00 + + +7fffffffedb0 + + + + + ++38 7fffffffe -ce0 - - -0 -+10 -i, j +d08 + + +7ffff7c27781 +libc+27781 ++40 7fffffffe -ce8 - - -0x400000006 -rbp - -+18 -saved rbp +d10 + + +7ffff7fe0c60 +ld.so+22c60 ++48 7fffffffe -cf0 +d18 -7fffffffed00 +7fffffffee38 -+20 ++50 7fffffffe -cf8 - - -4011ff -main+14 -+28 +d20 + + +0x1f7fbe000 ++58 7fffffffe -d00 +d28 -7fffffffedb0 - - -7fffffffee10 - - -0 - - - -sort(8) - - -moment 370 of 465 -The sixth pass, its third compare: 17 : 5, so jg goes back to the swap. -The swap has run 5 times so far; the outer loop has turned 5. +401200 +main+0 + + + +sort + + + +main + + +libc.so.6+27781 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +moment 434 of 1905 +The sixth pass, its third compare: 17 > 5, so jne takes the swap. +The swap has run 5 times so far, and each loop has turned 5. diff --git a/design/mock/40-frame-beside-480.png b/design/mock/40-frame-beside-480.png new file mode 100644 index 0000000..8cba82f Binary files /dev/null and b/design/mock/40-frame-beside-480.png differ diff --git a/design/mock/40-frame-beside.png b/design/mock/40-frame-beside.png new file mode 100644 index 0000000..5af68f1 Binary files /dev/null and b/design/mock/40-frame-beside.png differ diff --git a/design/mock/40-frame-beside.svg b/design/mock/40-frame-beside.svg new file mode 100644 index 0000000..2474178 --- /dev/null +++ b/design/mock/40-frame-beside.svg @@ -0,0 +1,1848 @@ + + + + + + +list.c +lines 19 to 26 of 42 +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 +; + + + +disassembly +reverse +10019 +10 +20 +test +rdi, rdi +10019 +13 +je +1001935 +10019 +15 +push +rbp +10019 +16 +mov +rbp, rsp +10019 +19 +xor +eax, eax +10019 +1b +nop +[rax + rax] +10019 +20 +mov +rcx, rax +10019 +23 +mov +rax, rdi + + + +10019 +26 +21 +mov +rdi, [rdi + 8] +1004098 + + +1004070 + + +9 +10019 +2a +22 +mov +[rax + 8], rcx +10019 +2e +20 +test +rdi, rdi +10019 +31 +jne +1001920 +10019 +33 +pop +rbp +10019 +34 +26 +ret +10019 +35 +xor +eax, eax +10019 +37 +ret + +10019 +38 +endbr64 +_init + + + +registers +stack +heap +code +data +rwx + +read-only + +rbx +0 +rdx +0 +rsi +10040c0 + + + + + +r8 +7ffff7e19ac0 +r9 +0x20 +32 +r10 +0x10 +16 +r11 +7ffff7e19ac8 +r12 +7fffffffee38 + + + + + +r13 +1 +r14 +7ffff7ffd000 + + + + + +r15 +10029c0 + + + + + +rax + +1004090 + + +4 +rcx + +10040b0 + + +1 +rdi + +1004090 + + +4 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 + + +rip +1001926 +reverse+22 +cf + +PF +af +zf +sf + +IF +df +of + + + +stack +fifteen 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 + + + + + ++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 + + + + + + + + +reverse + + + +main + + +libc+27781 + + + +its bytes +the heap, 1004070 to 10040bf + + + +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 + + + + + + + + + + + + +the list +10040b0 + +1 + + + + + +rcx +1004090 + +4 + + + + + + +rax +rdi +1004070 + +9 + + + + +1004050 + +16 + + + + +1004030 + +25 + + + + +1004010 + +36 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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/41-frame-subject-480.png b/design/mock/41-frame-subject-480.png new file mode 100644 index 0000000..64df973 Binary files /dev/null and b/design/mock/41-frame-subject-480.png differ diff --git a/design/mock/41-frame-subject.png b/design/mock/41-frame-subject.png new file mode 100644 index 0000000..fa6f619 Binary files /dev/null and b/design/mock/41-frame-subject.png differ diff --git a/design/mock/41-frame-subject.svg b/design/mock/41-frame-subject.svg new file mode 100644 index 0000000..f6f0c64 --- /dev/null +++ b/design/mock/41-frame-subject.svg @@ -0,0 +1,1816 @@ + + + + + + +list.c +lines 18 to 25 of 42 +18 +__attribute__ +( +( +noinline +) +) +static +struct +node +* +reverse +( +struct +n +… +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 +} + + + +disassembly +reverse +10019 +16 +20 +mov +rbp, rsp +10019 +19 +xor +eax, eax +10019 +1b +nop +[rax + rax] +10019 +20 +mov +rcx, rax +10019 +23 +mov +rax, rdi + + + +10019 +26 +21 +mov +rdi, [rdi + 8] + +1004098 + + +1004070 + + +9 +10019 +2a +22 +mov +[rax + 8], rcx +10019 +2e +20 +test +rdi, rdi +10019 +31 +jne +1001920 +10019 +33 +pop +rbp +10019 +34 +26 +ret + + + +registers +stack +heap +code +data +rwx + +read-only + +rbx +0 +rdx +0 +rsi +10040c0 + + + + + +r8 +7ffff7e19ac0 +r9 +0x20 +32 +r10 +0x10 +16 +r11 +7ffff7e19ac8 +r12 +7fffffffee38 + + + + + +r13 +1 +r14 +7ffff7ffd000 + + + + + +r15 +10029c0 + + + + + +rax + +1004090 + + +4 +rcx + +10040b0 + + +1 +rdi + +1004070 + + +9 +rbp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 +rsp +7fffffffece0 + + +7fffffffed00 + + +7fffffffedb0 + + +7fffffffee10 + + +0 + + +rip +1001926 +reverse+22 +cf + +PF +af +zf +sf + +IF +df +of + + + +stack +thirteen 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 + + + + + ++40 +7fffffffe +d20 + + +0x1f7fbe000 ++48 +7fffffffe +d28 + + +1001860 +main+0 ++50 +7fffffffe +d30 + + +7fffffffed70 + + + + + ++58 +7fffffffe +d38 + + + + + ++60 +7fffffffe +d40 + + +0 + + + +reverse + + + +main + + +libc+27781 + + + +its bytes +the heap, 1004050 to 10040bf + + + +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 + + + + + + + + + + + + + + +the list +10040b0 + +1 + + + + + +rcx +1004090 + +4 + + + + + + + +rax +1004070 + +9 + + + + + + +rdi +1004050 + +16 + + + + +1004030 + +25 + + + + +1004010 + +36 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +moment 3 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/42-frame-layouts.png b/design/mock/42-frame-layouts.png new file mode 100644 index 0000000..ab9cece Binary files /dev/null and b/design/mock/42-frame-layouts.png differ diff --git a/design/mock/43-graph-forms.png b/design/mock/43-graph-forms.png new file mode 100644 index 0000000..1775fd6 Binary files /dev/null and b/design/mock/43-graph-forms.png differ diff --git a/design/mock/43-graph-forms.svg b/design/mock/43-graph-forms.svg new file mode 100644 index 0000000..6ec334b --- /dev/null +++ b/design/mock/43-graph-forms.svg @@ -0,0 +1,311 @@ + + + +sort's graph, four ways +The same moment in each (the 11th compare: 17 > 5, jne about to take the swap); the lens's scale, mono 20. Veiled: what falls outside the box the frame gives the lens. +1 +present: layers, boxes, square lanes +ten layers, 400 high: past the lens's 296 (veiled), so it pans; a third of its width + + + +the blocks of sort +its blocks · the visits · the path + + + + + + + + + + + + + + + + + + + + + + +×5 + + + + +×5 + + ++0 +×1 + + ++12 +×6 + + ++1e +×6 + + ++24 +×11 + + ++2f +×11 + + ++56 +×11 + + ++5d +×5 + + ++5f +×5 + + ++97 +×5 + + ++99 +×5 + + ++a7 + +2 +the same layers, rounded +pills and round corners: smoother, and just as tall + + + +the blocks of sort +its blocks · the visits · the path + + + + + + + + + + + + + + + + + + + + + + +×5 + + + + +×5 + ++0 +×1 + ++12 +×6 + ++1e +×6 + ++24 +×11 + ++2f +×11 + ++56 +×11 + ++5d +×5 + ++5f +×5 + ++97 +×5 + ++99 +×5 + ++a7 + +3 +rings +each loop a circle its blocks sit on, the inner inside the outer: 420 high, past the band's 200 (veiled) + + + +the blocks of sort +its blocks · the visits · the path · the loops' turns + + + + + + + + + + + + + + + + + + + + + + + + + + +×5 +×5 + ++0 +×1 + ++12 +×6 + ++1e +×6 + ++24 +×11 + ++2f +×11 + ++56 +×11 + ++5d +×5 + ++5f +×5 + ++97 +×5 + ++99 +×5 + ++a7 + +swap + +What each costs +1 The tools' picture. Tall by nature: a layer a block, + so it pans in a short pane, and leaves the width. +2 Rounding the corners does not change the shape. +3 The most circular, and a loop is a ring; but rings + want a square pane, a loop's way out is a chord + across them, and pills on its sides sit across it. +4 The track. A line of blocks as they run, each loop + an arch over its own blocks: a closed shape, its + turns at its centre; a jump past blocks a dip + under them. Wide and short: 11 blocks in 1622 + by 150, whole. Its order is the disassembly's, + which is under the source; run down, it is the + map's column with its rows. +4 +the track: recommended +the band across the frame, 1792 by 200: the whole graph, no pan + + + +the blocks of sort +its blocks · the visits · the path · the loops' turns + + + + + + + + + + + + + + + + + + + + + + + + + + +×5 +×5 + ++0 +×1 + ++12 +×6 + ++1e +×6 + ++24 +×11 + ++2f +×11 + ++56 +×11 + ++5f +×5 + +swap + ++5d +×5 + ++97 +×5 + ++99 +×5 + ++a7 +Ink in 3 and 4: never taken in the whole run, dashed rule (j > 0 failing); not yet, rule (the way out); taken, dim; the last three, the trail's golds. 1 and 2 keep the layers' ink: never taken, rule. + diff --git a/design/mock/context.py b/design/mock/context.py index 31a54f6..b35abd5 100644 --- a/design/mock/context.py +++ b/design/mock/context.py @@ -301,12 +301,40 @@ def bracket(g, x, y0, y1, ink, sw=2, serif=5, side=1): # ---- the state column --------------------------------------------------------------- -def registers(g, y, regs, flags, marks): +QUIET_PITCH = 285 # a quiet register's cell: three to a row + + +def reg_rows(quiet): + """The registers panel's rows: one a register the scene moves (and rsp, rbp, rip), a row of three the rest.""" + return 17 - len(quiet) + (len(quiet) + 2) // 3 + + +def registers(g, y, regs, flags, marks, quiet=()): + """quiet: the registers no step of the scene changes, folded three to a row over rip: each its name and its + value in its ink, a pointer's chain cut to `more` at once (the map has it whole).""" legend = [("stack", STACK, False), ("heap", HEAP, False), ("code", CODE, False), ("data", DATA, False), ("rwx", DATA, True), ("read-only", VELLUM, False)] - y0 = panel(g, RX, y, CW, 17, "registers", note=legend) + y0 = panel(g, RX, y, CW, reg_rows(quiet), "registers", note=legend) where = {} - for i, (name, links, end) in enumerate(regs): + full = [r for r in regs if r[0] not in quiet] + if quiet: + qy = y0 + (len(full) - 1) * ROW + g.rect(RX + 2, qy, CW - 4, 2, RULE) + for k, (name, links, end) in enumerate(r for r in regs if r[0] in quiet): + xx, yy = RX + 12 + (k % 3) * QUIET_PITCH, qy + (k // 3) * ROW + where[name] = yy + g.t(xx, b(yy), name, S, FAINT, MONO) + if links: + x = addr(g, xx + 48, yy, links[0][0], links[0][1]) + if len(links) > 1 or end is not None: + more(g, x, yy) + else: + integer(g, xx + 48, yy, end[1]) + full = full[:-1] + [None] * ((len(quiet) + 2) // 3) + full[-1:] + for i, r in enumerate(full): + if r is None: + continue + name, links, end = r yy = y0 + i * ROW if name == "rip": g.t(RX + 12, b(yy), name, S, current_row(g, RX + 2, yy, CW - 4, 54), BOLD) diff --git a/design/mock/frame.py b/design/mock/frame.py new file mode 100644 index 0000000..15b3933 --- /dev/null +++ b/design/mock/frame.py @@ -0,0 +1,410 @@ +#!/usr/bin/env python3 +"""The working frame reworked: the disassembly under the source in every split, the registers a scene does not +move folded three to a row, the stack given what that frees, and the `blocks` lens's drawing across the band. + + python3 -B frame.py # 40-frame-beside, 41-frame-subject, 25-blocks-lens (.svg), 42-frame-layouts.png + +40 and 41 are mocks 9 and 11 in the reworked frame (the same recording of targets/list, the same moments, each +pane's minimap from the map as map.py draws it); 25 is sort with the `blocks` lens (graph.py's track, the stop in +sort-dbg.txt); 42 sets the three layouts weighed this round side by side, each as the list's `subject` and sort's +`blocks`, at a third of their size: A (recommended) folds the quiet registers, B keeps all seventeen and gives the +source's rows to the disassembly, C sets the registers in two columns. +""" +import math +import re +import subprocess + +from PIL import Image, ImageDraw, ImageFont + +import gen +import dense as D +import context as C +import map as M +import graph as G +from context import (PAGE, RAISED, RULE, VELLUM, BRIGHT, DIM, FAINT, GOLD, HEAP, STACK, CODE, DATA, A, S, ROW, TAG, + MONO, BOLD, b, ph, mix, Svg) + +HERE = G.HERE +TOP, FOOT = 48, 888 +WORDS = {6: "six", 8: "eight", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen"} + +# ---- the splits ------------------------------------------------------------------------------------------------- +# What a scene gives its lens, and the program column's rows under it: (drawing, view, source, disassembly). The +# `blocks` lens has no view: its drawing is the band across both columns. +SPLITS = {"none": (0, 0, 14, 17), "beside": (152, 152, 8, 17), "subject": (296, 200, 8, 11), "blocks": (200, 0, 8, 15)} +LAYOUTS = { + "A": dict(regs="fold", src=None, dis=None), # the splits above + "B": dict(regs="all", src=6, dis=lambda d: d + 2), # all seventeen rows; the source gives two rows + "C": dict(regs="two", src=None, dis=None), # the registers in two columns of eight, rip across +} + + +def boxes(split, layout, quiet): + """Every panel's box in a split: x, y, h (the width is the column's, or both for the band across).""" + band, view, src, dis = SPLITS[split] + L = LAYOUTS[layout] + if L["src"] is not None and split != "none": + src, dis = L["src"], L["dis"](dis) + regs = {"fold": C.reg_rows(quiet), "all": 17, "two": 9}[L["regs"]] + out = {} + y = TOP + (band + 12 if band else 0) + out["source"] = (64, y, ph(src)) + out["disasm"] = (64, y + ph(src) + 12, ph(dis)) + assert out["disasm"][1] + out["disasm"][2] == FOOT or split == "none", (split, layout, out) + ys = TOP + (view + 12 if view else band + 12 if split == "blocks" else 0) + out["registers"] = (976, ys, ph(regs)) + yk = ys + ph(regs) + 12 + out["stack"] = (976, yk, FOOT - yk) + if band: + out["drawing"] = (64, TOP, band) + if view: + out["view"] = (976, TOP, view) + return out, regs, (FOOT - yk - TAG - 8) // ROW + + +# ---- the registers in two columns (layout C) ------------------------------------------------------------------ +def registers_two(g, y, regs, flags, marks): + """C: sixteen in two columns of eight, each 440 wide, its chain cut to that; rip across the foot with the flags.""" + legend = [("stack", STACK, False), ("heap", HEAP, False), ("code", CODE, False), ("data", DATA, False), + ("rwx", DATA, True), ("read-only", VELLUM, False)] + y0 = C.panel(g, C.RX, y, C.CW, 9, "registers", note=legend) + where = {} + for i, (name, links, end) in enumerate(regs[:16]): + x, yy = C.RX + (i // 8) * 440, y0 + (i % 8) * ROW + where[name] = yy + g.t(x + 12, b(yy), name, S, DIM, MONO) + if links: + C.chain(g, x + 60, yy, links, end, marks.get(name), room=x + 428) + else: + C.integer(g, x + 60, yy, end[1]) + yy = y0 + 8 * ROW + name, links, end = regs[16] + g.t(C.RX + 12, b(yy), name, S, C.current_row(g, C.RX + 2, yy, C.CW - 4, 54), BOLD) + C.chain(g, C.RX + 72, yy, links, end, room=C.RX + C.CW - 12) + x = C.RX + C.CW - 12 - len(flags) * 42 + 10 + for fl, on, changed in flags: + if on: + g.rect(x, yy + 2, 2 * A + 8, 20, RAISED) + g.t(x + 4, b(yy), fl, S, BRIGHT, BOLD) + else: + g.t(x + 4, b(yy), fl.lower(), S, mix(DIM, C.band(), 0.8), MONO) + x += 42 + where["rip"] = yy + return where + + +def draw_registers(g, layout, y, regs, flags, marks, quiet): + C.RX = 976 + if LAYOUTS[layout]["regs"] == "two": + return registers_two(g, y, regs, flags, marks) + return C.registers(g, y, regs, flags, marks, quiet if LAYOUTS[layout]["regs"] == "fold" else ()) + + +# ---- a pane's minimap from rows we hold (sort's), as map.py draws one from the map ---------------------------- +def strip(g, x, y, h, rows, w0, wn, marks=None, ticks=()): + """rows: per row of the column, its runs as (x, width, ink) in the panel's units. The window framed; the marks + at a row's left; a block's first row ticked at the strip's left; dots where the column goes on.""" + marks = marks or {} + g.rect(x, y, M.MW, h, C.WELL) + cap, total = int((h - 6) // M.MR), len(rows) + first = 0 if total <= cap else min(max(w0 + wn // 2 - cap // 2, 0), total - cap) + for r in range(first, min(first + cap, total)): + ry = y + 3 + (r - first) * M.MR + for rx, rw, ink in rows[r]: + g.rect(x + 2 + rx * M.KX, ry, max(rw * M.KX, 1), 3, mix(ink, PAGE, 0.65)) + if r in ticks: + g.rect(x, ry - 1, 2, 4, DIM) + if r in marks: + g.rect(x + 2, ry - 0.5, 4, 4, {"current": GOLD, "struck": gen.VERM, "read": gen.READ}[marks[r]]) + g.frame(x, y + 3 + (w0 - first) * M.MR - 3, M.MW, wn * M.MR + 5, VELLUM, 2) + for end, more in (("top", first > 0), ("foot", first + cap < total)): + if more: + yy = y + 1 if end == "top" else y + h - 3 + for d in range(3): + g.rect(x + M.MW / 2 - 7 + d * 6, yy, 2, 2, FAINT) + + +def strip_at(box): + x, y, h = box + return x + 880 - 2 - M.MW, y + TAG, h - TAG - 2 + + +# ---- the list: 40 (`beside`, at rest) and 41 (`subject`, mid-step) --------------------------------------------- +LIST_QUIET = ("rbx", "rdx", "rsi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15") # reverse moves rax rcx rdi + + +def list_frame(g, split, step, layout="A", caption=None, strips=True): + subject = split == "subject" + bx, nregs, words = boxes(split, layout, LIST_QUIET) + band, view, src, dis = SPLITS[split] + src, dis = (bx["source"][2] - 32) // ROW, (bx["disasm"][2] - 32) // ROW + # the map, its windows set for this split's rows: each pane's column for its minimap + old = dict(C.SUBJECT), dict(C.BESIDE) + sp = C.SUBJECT if subject else C.BESIDE + sp.update(src=src, dis=dis, words=words) + m, win = M.map_log(step, False, subject) + M.stage(False) + C.SUBJECT.update(old[0]) + C.BESIDE.update(old[1]) + D.put(64) + M.strip(True) + first = 18 if subject else 19 + ys = C.source(g, bx["source"][1], src, D.SRC, first, 21, [], "list.c", 42) + at = C.disasm(g, bx["disasm"][1], D.window(dis, step), "reverse", 21) + M.strip(False) + marks = {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike" if step else "tick"}} + regs = draw_registers(g, layout, bx["registers"][1], D.regs(step), D.FLAGS, marks, LIST_QUIET) + M.strip(True) + C.RX = 976 + C.stack(g, bx["stack"][1], M.slot_rows(M.UNDER, words), M.frames_from(M.UNDER, words), rsp=M.RSP, + roles=M.roles_from(M.UNDER, words), note="%s words from rsp" % WORDS[words]) + rows_shown = M.SUBJECT_VIEW if subject else M.BESIDE_VIEW + vr = C.fields(g, TOP, view, "the heap, %x to %x" % (0x1004000 + 16 * rows_shown[0], 0x10040bf), 0x1004000, 512, + D.heap_fields(0x1004000, 512, 0x1004098), D.MEM, HEAP, D.region, marks=(9,) if step else (), + rows_shown=rows_shown, more_rows=False, touched={0x1004098} if step else ()) + M.strip(False) + D.put(64) + C.thread(g, ys, [(at[0x1001926], at[0x1001926] + ROW)]) + C.RX = 976 + C.lens(g, TOP, band, view, D.NODES, M.pins(step), M.node_marks(step), 0x1004000, 32, + link_from=(regs["rdi"], "rdi") if step else None, subject=subject, view_rows=vr) + if strips: + M.minimaps(g, m.log, {k: bx[k] for k in ("source", "disasm", "stack", "view")}) + M.clock(g, 3 if step else 2, 4) + gen.caption(g, caption) + return bx, words + + +CAP9 = [[("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.",)]] +CAP10 = [[("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.",)]] + + +# ---- sort, stopped at the 11th compare (sort-dbg.txt) ---------------------------------------------------------- +SORT_MEM = {} +for line in open(HERE + "/sort-dbg.txt"): + mm = re.match(r"^(7fffffff[0-9a-f]{4}) ((?:[0-9a-f]{2} ){16})", line) + if mm: + for i, v in enumerate(mm.group(2).split()): + SORT_MEM[int(mm.group(1), 16) + i] = int(v, 16) +SORT_NAMES = {0x401020: "_start", 0x4010e0: "__do_global_dtors_aux", 0x401120: "swap", 0x401150: "sort", 0x401200: "main"} +RSP_S = 0x7fffffffecd0 + + +def s_region(v): + for lo, hi, ink in [(0x401000, 0x402000, CODE), (0x400000, 0x401000, VELLUM), (0x402000, 0x403000, VELLUM), + (0x403000, 0x405000, DATA)]: + if lo <= v < hi: + return ink + return D.region(v) + + +def s_name(v): + if 0x7ffff7fbe000 <= v < 0x7ffff7fec000: + return "ld.so+%x" % (v - 0x7ffff7fbe000) + if v in D.LIBNAMES: + return D.LIBNAMES[v] + f = max(a for a in SORT_NAMES if a <= v) + return "%s+%d" % (SORT_NAMES[f], v - f) + + +def s_word(a): + return sum(SORT_MEM[a + i] << (8 * i) for i in range(8)) if all(a + i in SORT_MEM for i in range(8)) else None + + +def s_follow(v): + links = [] + while True: + ink = s_region(v) + if ink == CODE: + return links + [(v, CODE, s_name(v))], None + links.append((v, ink)) + s = "".join(chr(SORT_MEM[v + i]) for i in range(16) if v + i in SORT_MEM).split("\0")[0] + if ink == STACK and len(s) >= 2 and s.isprintable() and SORT_MEM.get(v + len(s)) == 0: + return links, ("str", s) + w = s_word(v) + if w is None or len(links) > 5: + return links, None + if w and s_region(w): + v = w + continue + return links, ("int", w) + + +def sort_slots(n): + rows = [] + for i in range(n): + a = RSP_S + 8 * i + w = s_word(a) + links, end = s_follow(w) if w and s_region(w) else ([], ("int", w)) + rows.append((a, {0: ["rsp"], 2: ["rbp"]}.get(i, []), links, end)) + return rows + + +E_ = [(0x7fffffffed00, STACK), (0x7fffffffedb0, STACK), (0x7fffffffee10, STACK)] +SORT_REGS = [("rax", [], ("int", 1)), ("rbx", [], ("int", 0)), ("rcx", [(0x404010, DATA)], ("int", 0x900000004)), + ("rdx", [], ("int", 4)), ("rsi", [(0x404024, DATA)], ("int", 0x1f0000001a)), + ("rdi", [(0x404020, DATA)], ("int", 0x1a00000005)), ("rbp", [(0x7fffffffece0, STACK)] + E_, ("int", 0)), + ("rsp", [(0x7fffffffecd0, STACK)], ("int", 0x401000000)), ("r8", [(0x7ffff7e19680, DATA)], None), + ("r9", [(0x7ffff7e1afa0, DATA)], None), ("r10", [(0x7fffffffea60, STACK)], ("int", 0)), + ("r11", [(0x7ffff7ffca90, DATA)], ("int", 0xba55a1098a503203)), + ("r12", [(0x7fffffffee38, STACK), (0x7fffffffefea, STACK)], ("str", "./sort")), ("r13", [], ("int", 1)), + ("r14", [(0x7ffff7ffd000, DATA), (0x7ffff7ffe3c0, DATA)], ("int", 0)), + ("r15", [(0x403e10, DATA), (0x4010e0, CODE, "__do_global_dtors_aux")], None), + ("rip", [(0x4011ab, CODE, "sort+91")], None)] +SORT_FLAGS = [("CF", 0, 0), ("PF", 0, 1), ("AF", 0, 1), ("ZF", 0, 0), ("SF", 0, 0), ("IF", 1, 0), ("DF", 0, 0), ("OF", 0, 0)] +SORT_QUIET = ("rbx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15") # sort moves the other eight +SORT_SRC = open(HERE + "/../../anim/tools/sort.c").read().split("\n") +TEXT = G.read_dis("sort-clang.dis") # the program's text: swap, sort, main +FUNC = lambda a: "swap" if a < 0x401150 else "sort" if a < 0x401200 else "main" + + +def sort_disasm(g, y, n): + """n rows round the pc; each block's first row under a rule, its visits ranged right in the annotation's room + (the pill's count, in its digits); the trail's three rows and the pc's with what they did.""" + i = [r[0] for r in TEXT].index(G.PC) + lo = max(0, min(i - n // 2, len(TEXT) - n)) + st = G.sort_state(G.UPTO, G.PC, G.TRAIL_ROWS) + notes = dict(G.NOTES) + notes[0x4011a3] = [("7fffffffecd3 ", STACK), ("◂ ", FAINT), ("1", VELLUM)] + rows = [] + for a, ln, mn, ops, t, callee in TEXT[lo:lo + n]: + state = "cur" if a == G.PC else {0x4011a9: "trail0", 0x4011a6: "trail1", 0x4011a3: "trail2"}.get(a) + note = ("runs", notes[a]) if a in notes else ("text", callee, VELLUM) if mn == "call" else None + rows.append((a, ln, mn, [(t, CODE)] if t and (mn.startswith("j") or mn == "call") else [(ops, VELLUM)], + state, note)) + at = C.disasm(g, y, rows, "sort", 12) + for a in at: + if a in G.SORT_BL and a != "note": # a block's first row: the rule over it, its pill's digits + yy = at[a] + g.rect(C.LX + 2, yy, C.CW - 4, 2, RULE) + n_ = st["blocks"][a]["count"] + g.t(C.LX + C.CW - 12, b(yy), "×%d" % n_, S, FAINT, MONO, "end") + line12 = [at[r[0]] for r in rows if r[1] == 12 and r[0] < 0x4011af] + return at, (min(line12), max(line12) + ROW), lo + + +def sort_strips(g, bx, lo, n, words): + """The panes' minimaps from what the stop holds: the file, the program's text (69 rows round the pc), the + stack from 16 words above rsp to as far as the dump goes.""" + src_rows = [[(64 + (len(l) - len(l.lstrip())) * A, len(l.strip()) * A, VELLUM)] if l.strip() else [] + for l in SORT_SRC[:22]] + strip(g, *strip_at(bx["source"]), src_rows, 8, 8, {11: "current"}) + i = [r[0] for r in TEXT].index(G.PC) + col = TEXT[max(0, i - 34):i + 35] + dis_rows = [[(40, 7 * A, CODE), (180, len(mn) * A, gen.KW), (264, len(ops) * A, VELLUM if FUNC(a) == "sort" else FAINT)] + for a, ln, mn, ops, t, c in col] + c0 = [r[0] for r in col] + strip(g, *strip_at(bx["disasm"]), dis_rows, c0.index(TEXT[lo][0]), n, {c0.index(G.PC): "current"}, + ticks={c0.index(a) for a in G.SORT_BL if a in c0}) + stk = [] + for k in range(-16, 110): + a = RSP_S + 8 * k + w = s_word(a) + if w is None: + break + ink = s_region(w) if w else None + stk.append([(184, 12 * A, STACK)] + ([(184 + 13 * A, 12 * A, ink or VELLUM)] if w else [(184 + 13 * A, A, FAINT)])) + strip(g, *strip_at(bx["stack"]), stk, 16, words) + + +def sort_frame(g, layout="A", strips=True): + """Mock 25 in a layout: the `blocks` lens across the band, the source and the disassembly under it.""" + bx, nregs, words = boxes("blocks", layout, SORT_QUIET) + st = G.sort_state(G.UPTO, G.PC, G.TRAIL_ROWS, G.NOTES) + G.track_lens(g, 64, TOP, 1792, 200, G.SORT_BL, G.SB[0], G.SORT_BASE, st, "the blocks of sort") + src, dis = (bx["source"][2] - 32) // ROW, (bx["disasm"][2] - 32) // ROW + C.LX, C.RX = 64, 976 + M.strip(strips) + first = max(1, 12 - src // 2) + ys = C.source(g, bx["source"][1], src, SORT_SRC, first, 12, [14, 13], "sort.c", 22) + at, run, lo = sort_disasm(g, bx["disasm"][1], dis) + M.strip(False) + draw_registers(g, layout, bx["registers"][1], SORT_REGS, SORT_FLAGS, {}, SORT_QUIET) + M.strip(strips) + C.RX = 976 + roles = {0: ("j, high half", VELLUM), 1: ("i, n", VELLUM), 2: ("saved rbp", DIM), 6: ("saved rbp", DIM)} + C.stack(g, bx["stack"][1], sort_slots(words), [("sort", 0, 3), ("main", 4, 7), ("libc.so.6+27781", 8, 29)], + rsp=RSP_S, roles={k: v for k, v in roles.items() if k < words}, note="%s words from rsp" % WORDS[words]) + M.strip(False) + C.thread(g, ys, [run]) + if strips: + sort_strips(g, bx, lo, dis, words) + M.clock(g, 434, 1905) + gen.caption(g, [[("The sixth pass, its third compare: ",), ("17 > 5", "mono"), (", so ",), ("jne", "mono"), + (" takes the swap.",)], + [("The swap has run 5 times so far, and each loop has turned 5.",)]]) + return bx, words + + +# ---- the frames ------------------------------------------------------------------------------------------------ +def save(name, draw, *a, **k): + gen.W, gen.H = 1920, 1080 + M.stage(False) + g = Svg() + out = draw(g, *a, **k) + g.save(name) + return out + + +def sheet(out): + """Mock 42: A, B, C as columns; the list's `subject` and sort's `blocks` as rows; a third of their size.""" + tiles, info = [], {} + for key in "ABC": + for kind in ("subject", "blocks"): + name = "42-%s-%s" % (key, kind) + if kind == "subject": + bx, words = save(name, list_frame, "subject", True, key, CAP10) + else: + bx, words = save(name, sort_frame, key) + src, dis = (bx["source"][2] - 32) // ROW, (bx["disasm"][2] - 32) // ROW + regs = (bx["registers"][2] - 32) // ROW + info[(key, kind)] = (src, dis, regs, words) + subprocess.run(["resvg", "-w", "608", HERE + "/" + name + ".svg", HERE + "/" + name + ".png"], check=True) + tiles.append((key, kind, Image.open(HERE + "/" + name + ".png").convert("RGB"))) + W_, H_ = 64 + 3 * 608 + 2 * 32 + 64, 210 + 2 * (342 + 120) + s = Image.new("RGB", (W_, H_), "#0a1030") + d = ImageDraw.Draw(s) + big = ImageFont.truetype("/usr/share/fonts/go/Go-Medium.ttf", 30) + head = ImageFont.truetype("/usr/share/fonts/go/Go-Medium.ttf", 24) + body = ImageFont.truetype("/usr/share/fonts/go/Go-Regular.ttf", 18) + d.text((64, 28), "The frame, three ways: where the room for the stack and the disassembly comes from", font=big, + fill="#fff8e8") + d.text((64, 72), "Each the same two moments: the list as `subject` mid-step (top), sort with the `blocks` lens (foot). " + "A third of their size: the layout, not the digits.", font=body, fill="#9aa6d9") + titles = {"A": ("A fold the quiet registers (recommended)", "#e8c46a"), + "B": ("B all seventeen; the source gives", "#eee6d2"), + "C": ("C the registers in two columns", "#eee6d2")} + subs = {"A": "the registers a scene moves keep their rows and chains; the rest three a row", + "B": "rule 6 as it stood: every chain whole; the stack does not grow", + "C": "two registers a row, 440 each: chains cut to a hop; the stack the most"} + for i, (key, kind, im) in enumerate(tiles): + col, row = "ABC".index(key), 0 if kind == "subject" else 1 + x, y = 64 + col * (608 + 32), 210 + row * (342 + 120) + if row == 0: + d.text((x, 118), titles[key][0], font=head, fill=titles[key][1]) + d.text((x, 152), subs[key], font=body, fill="#9aa6d9") + s.paste(im, (x, y)) + d.rectangle((x - 1, y - 1, x + 608, y + 342), outline="#e8c46a" if key == "A" else "#3a4a8a", width=2) + src, dis, regs, words = info[(key, kind)] + lab = "%s: source %d · disassembly %d · registers %d rows · stack %d" % ( + "list, subject" if kind == "subject" else "sort, blocks", src, dis, regs, words) + d.text((x, y + 352), lab, font=body, fill="#eee6d2") + if kind == "blocks": + d.text((x, y + 378), "the graph across the band: 1792 by 200, whole", font=body, fill="#9aa6d9") + else: + d.text((x, y + 378), "the drawing 296 and its view of 7 over the state column", font=body, fill="#9aa6d9") + s.save(HERE + "/" + out) + for key in "ABC": + for kind in ("subject", "blocks"): + for ext in ("svg", "png"): + subprocess.run(["rm", "-f", "%s/42-%s-%s.%s" % (HERE, key, kind, ext)], check=True) + return info + + +if __name__ == "__main__": + print("40", save("40-frame-beside", list_frame, "beside", False, "A", CAP9)) + print("41", save("41-frame-subject", list_frame, "subject", True, "A", CAP10)) + print("25", save("25-blocks-lens", sort_frame, "A")) + print("42", sheet("42-frame-layouts.png")) diff --git a/design/mock/graph.py b/design/mock/graph.py index e9b8f2b..6062fa9 100644 --- a/design/mock/graph.py +++ b/design/mock/graph.py @@ -1,12 +1,21 @@ #!/usr/bin/env python3 """The disassembly's other form: a function as a graph of its basic blocks, with what the run did on it. - python3 -B graph.py # 22-graph-sort, 23-graph-open, 24-graph-strip, 25-blocks-lens (.svg) - -Data: sort and reverse from anim/tools/sort.c and list.c (cc -O0 -g -no-pie), their disassembly in -sort-O0.dis and reverse-O0.dis (objdump -dl), the paths their runs took from `ztrace dbg` stepped by instruction; -libc's `open` from objdump of /usr/lib/libc.so.6 (libc-open.dis), its path the one mock 16's run took. + python3 -B graph.py # 22-graph-sort, 23-graph-open, 24-graph-strip, 43-graph-forms (.svg) + # (25, the `blocks` lens in the working frame, is frame.py's) + +The form is the track: the blocks in a line in the order they run, each loop closing over the line as an arch +whose blocks sit on its floor, a forward jump that skips blocks dipping under them. Across in the lens's band, +down on the map, where the blocks are cards that carry their rows. The layered form it replaced (`silhouette`, +with `place` and `edges`) is kept for the comparison sheet, 43. + +Data: sort as the scene builds it (clang -O0, anim/build.zig, less the instrumentation's calls): sort-clang.dis +(objdump -dl), its path from `ztrace record --by insn --from sort` (the block leaders it hit), its stop in +sort-dbg.txt. reverse from anim/tools/list.c (cc -O0), reverse-O0.dis, its path from `ztrace dbg` stepped by +instruction. libc's `open` from objdump of +/usr/lib/libc.so.6 (libc-open.dis), its path the one mock 16's run took. """ +import math import re from collections import Counter @@ -125,7 +134,9 @@ X_OFF, X_LINE, X_MN, X_OPS = 72, 116, 128, 212 def block_w(blk, base, note_w=0): - return max(300, X_OPS + max(len(r[3]) for r in blk.rows) * A + 24 + note_w) + """As wide as its widest row as drawn (the size words gone, a width's cells in their place), 300 at least.""" + ops = [len(re.sub(r"\b\w+ ptr ", "", r[3])) + (3 if " ptr " in r[3] else 0) for r in blk.rows] + return max(300, X_OPS + max(ops) * A + 24 + note_w) def fold_rows(rows, keep): @@ -202,6 +213,9 @@ def draw_block(g, x, y, w, blk, base, st): g.path(f"M{hx},{yy + 12} h14 q6,0 6,6 v12 q0,6 -6,6 h-8", fade(DIM) if reached else RULE, 2) g.path(f"M{hx},{yy + 36} l8,-4 v8 Z", fill=fade(DIM) if reached else RULE) g.t(hx + 28, b(yy) + 12, callee, S, fade(VELLUM), MONO) + if st.get("split") and r is rows[-1] and not st.get("cur"): # a conditional's two ways, counted, in words + tk, nt = st["split"] + g.t(max(ex + 2 * A, x + X_OPS + 10 * A), b(yy), "taken %d · not %d" % (tk, nt), S, FAINT, MONO) yy += ROW if blk.ret: # the way out: a stub and a bar under the block cx = x + w / 2 @@ -235,7 +249,7 @@ def place(bl, lay, cols, widths, heights, x0, y0, pitch, gap): return pos, lh, ly -def edges(g, bl, lay, back, pos, widths, heights, lh, ly, gap, st, base, lane_x0, channel_x, small=False): +def edges(g, bl, lay, back, pos, widths, heights, lh, ly, gap, st, base, lane_x0, channel_x, small=False, radius=None): """Every edge: forward ones down from the bottom by the side their target lies on, along the gap's middle, down into the target's top; one that would cross a block runs in the right channel; a back edge leaves the bottom, goes out to its loop's lane on the left, climbs it and enters its header's head from the side: the one thing @@ -271,7 +285,7 @@ def edges(g, bl, lay, back, pos, widths, heights, lh, ly, gap, st, base, lane_x0 hy = ty + (12 if not small else 12) pts = [(sx, y + h), (sx, by), (lx, by), (lx, hy), (tx - 1, hy)] st.setdefault("paths", {})[e] = pts - arrow(g, pts, ink, sw, r=4 if small else 8, hl=7 if small else 10, hw=8 if small else 10) + arrow(g, pts, ink, sw, r=radius or (4 if small else 8), hl=7 if small else 10, hw=8 if small else 10) if n: # the loop's turns, on the lane under its turn into the header if st.get("struck_count") == e: # the count is a value: written, it is struck g.rect(lx + 1, hy + 8, 10 + len(str(n)) * 11, 20, C.SOFT) @@ -296,35 +310,11 @@ def edges(g, bl, lay, back, pos, widths, heights, lh, ly, gap, st, base, lane_x0 else: pts = [(sx, y + h), (sx, gy), (tx_, gy), (tx_, ty)] st.setdefault("paths", {})[e] = pts - arrow(g, pts, ink, sw, r=4 if small else 8, hl=7 if small else 10, hw=8 if small else 10) + arrow(g, pts, ink, sw, r=radius or (4 if small else 8), hl=7 if small else 10, hw=8 if small else 10) if n and kind != "jmp" and not small and len(outs) > 1: g.t(sx + 8, y + h + 20, str(n), S, FAINT, MONO) -def graph(g, x, y, w, title, note, bl, entry, base, cols, st, pitch=None, gap=48, notes_w=0): - """The panel: its tag, the blocks at the map's size, the edges. Returns the blocks' row positions.""" - lay, back = layers(bl, entry) - widths = {a: 520 if hasattr(bl[a], "folded") else block_w(bl[a], base, notes_w if st["blocks"].get(a, {}).get("notes") - else 0) for a in bl} - heights = {a: TAG + (ROW if hasattr(bl[a], "folded") else - len(fold_rows(bl[a].rows, st["blocks"].get(a, {}).get("cur"))) * ROW) + PAD for a in bl} - nb = len([e for e in back]) - lane_x0 = x + 24 - x0 = x + 24 + nb * 16 + 24 - pitch = pitch or max(widths.values()) + 56 - pos, lh, ly = place(bl, lay, cols, widths, heights, x0, y + TAG + 36, pitch, gap) - channel_x = max(pos[a][0] + widths[a] for a in bl) + 32 - hgt = max(pos[a][1] + heights[a] for a in bl) - y + 48 - C.tag(g, x, y, w, hgt, title, focus=True, note=note) - edges(g, bl, lay, back, pos, widths, heights, lh, ly, gap, st, base, lane_x0, channel_x) - ats = {} - for a in bl: - s_ = st["blocks"].get(a, {}) - _, at = draw_block(g, pos[a][0], pos[a][1], widths[a], bl[a], base, s_) - ats.update(at) - return pos, ats, hgt - - def run_state(bl, path, upto, base): """Visits and edge counts over the path's first `upto` blocks; the last three edges taken.""" p = path[:upto] @@ -334,49 +324,56 @@ def run_state(bl, path, upto, base): return cnt, ec, trail -# ---- the data --------------------------------------------------------------------------------------------- -SORT = read_dis("sort-O0.dis") -SORT_BASE = 0x401143 -SORT_BL = blocks(SORT, SORT_BASE) -SB = sorted(SORT_BL) # B0 .. B7 by address -NAMES = dict(zip("B0 B1 B2 B3 B4 B5 B6 B7".split(), SB)) -SORT_PATH = [NAMES[n] for n in ("B0 B6 B1 B3 B4 B5 B6 B1 B3 B4 B5 B6 B1 B3 B4 B5 B6 B1 B3 B4 B2 B3 B4 B2 B3 B4 B5 B6 B1 " - "B3 B4 B2 B3 B4 B5 B6 B1 B3 B4 B2 B3 B4 B2 B3 B4 B2 B3 B4 B2 B3 B4 B2 B3 B4 B5 B6 B1 " - "B3 B4 B2 B3 B4 B2 B3 B4 B5 B6 B7").split()] -SORT_COLS = {NAMES["B0"]: 0, NAMES["B6"]: 0, NAMES["B1"]: 0, NAMES["B3"]: 0, NAMES["B4"]: 0, NAMES["B2"]: 0, - NAMES["B5"]: 1, NAMES["B7"]: 1} +# ---- the data: sort as the scene builds it ------------------------------------------------------------------ +SORTC = [r for r in read_dis("sort-clang.dis") if 0x401150 <= r[0] < 0x401200] +SORT_BASE = 0x401150 +SORT_BL = blocks(SORTC, SORT_BASE) +SB = sorted(SORT_BL) +# the block leaders the run hit, from sort's entry to its return: ztrace record --by insn --from sort, clang -O0 +SORT_PATH = [SORT_BASE + int(o, 16) for o in ( + "0 12 1e 24 2f 56 5d 97 99 12 1e 24 2f 56 5d 97 99 12 1e 24 2f 56 5d 97 99 12 1e 24 2f 56 5f 24 2f 56 5f 24 2f " + "56 5d 97 99 12 1e 24 2f 56 5f 24 2f 56 5d 97 99 12 1e 24 2f 56 5f 24 2f 56 5f 24 2f 56 5f 24 2f 56 5f 24 2f 56 " + "5f 24 2f 56 5d 97 99 12 1e 24 2f 56 5f 24 2f 56 5f 24 2f 56 5d 97 99 12 a7").split()] +O = lambda off: SORT_BASE + off +NEVER = {(a, t) for a in SORT_BL for t, _ in SORT_BL[a].out} - set(zip(SORT_PATH, SORT_PATH[1:])) def sort_state(upto, cur, trail_rows, notes=None, cur_line=12): cnt, ec, trail = run_state(SORT_BL, SORT_PATH, upto, SORT_BASE) blk = {a: {"count": cnt.get(a, 0)} for a in SORT_BL} - ca = max(a for a in SORT_BL if a <= cur) - blk[ca].update(cur=cur, trail=trail_rows, notes=notes or {}, cur_line=cur_line) - return {"blocks": blk, "edge_counts": ec, "edge_trail": trail} + if cur: + ca = max(a for a in SORT_BL if a <= cur) + blk[ca].update(cur=cur, trail=trail_rows, notes=notes or {}, cur_line=cur_line) + return {"blocks": blk, "edge_counts": ec, "edge_trail": trail, "never": NEVER} -# the 11th time through the compare: i = 6, j = 4, a[3] = 17 against a[4] = 5 (moment 370 of the stepped run) -UPTO = [i for i, a in enumerate(SORT_PATH) if a == NAMES["B4"]][10] + 1 -NOTES_370 = {0x4011bf: [("404030 ", HEAP), ("◂ ", FAINT), ("17", VELLUM)], - 0x4011d6: [("404034 ", HEAP), ("◂ ", FAINT), ("5", VELLUM)], - 0x4011d9: [("17", VELLUM), (" : ", FAINT), ("5", VELLUM), (" ", FAINT), ("zf", DIM), (" sf", DIM), (" of", DIM)], - 0x4011db: [("taken", VELLUM), (" · reads zf sf of", FAINT)]} +# the 11th time through the compare: i = 6, j = 4, a[3] = 17 against a[4] = 5; the stop is the jne after it +# (sort-dbg.txt). Five swaps so far, five turns of each loop. +UPTO = [i for i, a in enumerate(SORT_PATH) if a == O(0x56)][10] + 1 +PC = 0x4011ab +TRAIL_ROWS = [0x4011a9, 0x4011a6, 0x4011a3] +NOTES = {0x4011a6: [("7fffffffecd3 ", STACK), ("◂ ", FAINT), ("1", VELLUM)], + 0x4011a9: [("1", VELLUM), (" : ", FAINT), ("1", VELLUM), (" ", FAINT), ("zf", DIM)], + 0x4011ab: [("taken", VELLUM), (" · reads zf", FAINT)]} def frame_sort_map(name): - """Mock 22: on the map, the disassembly column as sort's graph, two columns wide, beside the source whole.""" - gen.W, gen.H = 2900, 1800 + """Mock 22: on the map, the disassembly column as sort's track, one column wide (1024 to 1904), beside the + source whole: the cards on their spine, the loops' lanes on the left, the jumps past cards on the right.""" + gen.W, gen.H = 1980, 1860 g = Svg() - D.put(112) src = open(HERE + "/../../anim/tools/sort.c").read().split("\n") C.LX = 112 - C.source(g, 96, 22, src, 1, 12, [13, 14], "sort.c", 22) + C.source(g, 96, 22, src, 1, 12, [14, 13], "sort.c", 22) C.LX = 64 - g.t(112, 60, "the map: sort's disassembly as its graph, two columns wide (1024 to 2816), at moment 370 of 465 in sort", + g.t(112, 60, "the map: sort's disassembly as its track, in the second column (1024 to 1904), at the 11th compare", 22, DIM, "sans") - st = sort_state(UPTO, 0x4011db, [0x4011d9, 0x4011d6, 0x4011cf], NOTES_370) - graph(g, 1024, 96, 1792, "disassembly · sort", "its blocks · visits so far · the edges the run took", - SORT_BL, SB[0], SORT_BASE, SORT_COLS, st, pitch=560, notes_w=30 * A) + st = sort_state(UPTO, PC, TRAIL_ROWS, NOTES) + hgt, ats, _ = track_map(g, 1024, 96, 880, SORT_BL, SB[0], SORT_BASE, st, "disassembly · sort", + "its blocks · visits · the edges taken · the loops' turns", notes_w=17 * A) + print("22: the track on the map is %d high; the map's stage holds %d" % (hgt, 1688)) + g.rect(112, 1784, 1792, 2, RULE) + g.t(112, 1808, "the map's stage ends at 1784", 18, FAINT, "sans") g.save(name) @@ -415,9 +412,9 @@ def fold_unreached(bl, path, groups): def frame_open_map(name): - """Mock 23: libc's open, 19 blocks, of which the run reached 8; the 11 it did not are folded into three boxes. - The pc is at the `syscall` (mock 16's moment 4).""" - gen.W, gen.H = 2000, 2000 + """Mock 23: libc's open, 19 blocks, of which the run reached 8; the 11 it did not are folded into five cards by + what they are. The pc is at the `syscall` (mock 16's moment 4): the blocks after it are reached later.""" + gen.W, gen.H = 1008, 1640 g = Svg() o = lambda x: x + L groups = [("the O_CREAT path: the mode from the varargs", [o(0x110f90)]), @@ -427,11 +424,7 @@ def frame_open_map(name): ("the canary broken", [o(0x110fec), o(0x110ff0)])] groups = [(n, [m for m in ms if m in OPEN_BL]) for n, ms in groups] bl = fold_unreached(OPEN_BL, OPEN_PATH, groups) - cols = {a: 0 for a in bl} - for n, ms in groups: - cols[ms[0]] = 1 - st = {"blocks": {a: {"count": 1} for a in OPEN_PATH}, "edge_counts": Counter(zip(OPEN_PATH, OPEN_PATH[1:])), - "edge_trail": list(reversed(list(zip(OPEN_PATH, OPEN_PATH[1:]))[1:4]))} + st = {"blocks": {a: {"count": 1} for a in OPEN_PATH}} st["blocks"][o(0x110fb0)].update(cur=o(0x110fc5), trail=[o(0x110fc0), o(0x110fb9), o(0x110fb6)], notes={o(0x110fc5): [("openat", BRIGHT), (" nr 257", FAINT)]}) st["edge_counts"] = Counter(zip(OPEN_PATH[:4], OPEN_PATH[1:4])) @@ -440,10 +433,11 @@ def frame_open_map(name): st["blocks"][a]["count"] = 0 # not yet: the run is at the syscall for _, ms in groups: st["blocks"][ms[0]] = {"count": 0} - g.t(64, 60, "the map: libc's open as its graph · 19 blocks, the run reached 8 so far; the 11 it never reached are " - "folded into five boxes", 22, DIM, "sans") - graph(g, 64, 96, 1872, "disassembly · open · libc.so.6", "no source · 19 blocks · folded: 11 never reached", - bl, OPEN_PATH[0], OPEN_BASE + L, cols, st, pitch=880, gap=40, notes_w=18 * A) + g.t(64, 60, "the map: libc's open as its track · 19 blocks, the run reached 8; the 11 never reached folded", 22, + DIM, "sans") + hgt, _, _ = track_map(g, 64, 96, 880, bl, OPEN_PATH[0], OPEN_BASE + L, st, "disassembly · open · libc.so.6", + "no source · 19 blocks · folded: 11 never reached", notes_w=18 * A) + print("23: %d high" % hgt) g.save(name) @@ -457,127 +451,525 @@ REV_PATH = [R0, R2, R1, R2, R1, R2, R1, R2, R3] def frame_strip(name): - """Mock 24: reverse's loop, four instants: the condition about to be decided; its edge taken, the mark - travelling it; the back edge's turn, the count going up; the way out.""" - gen.W, gen.H = 3840, 1120 + """Mock 24: reverse's loop in the lens, four instants: the condition about to be decided; the edge taken, the + mark on it; the turn, the mark on the arch over the loop's blocks, its count struck; the way out, under.""" + gen.W, gen.H = 1920, 600 g = Svg() - cols = {R0: 0, R1: 0, R2: 0, R3: 0} inst = [ - ("1", "the condition", "cur at jne, the compare's chips framed; the second turn", 4, 0x4011ce, - {0x4011c9: [("1004070", HEAP), (" : ", FAINT), ("0", VELLUM), (" ", FAINT), ("zf", DIM)], - 0x4011ce: [("taken", VELLUM), (" · reads zf", FAINT)]}, None), - ("2", "the edge taken", "the edge lit gold, the mark on it, halfway", 5, None, {}, (R2, R1)), - ("3", "the loop's turn", "the back edge climbs, the mark on it; its count struck: the second turn", 6, None, {}, (R1, R2)), - ("4", "the way out", "not taken: down to the exit, landed", 9, 0x4011d0, {}, None), + ("1", "the condition", "the pc on jne in the test's block, the second time; its two ways out", 4, 0x4011ce, None), + ("2", "the edge taken", "taken: along the line to the body, the mark on the edge, landing", 4, None, + ((R2, R1), 0.55)), + ("3", "the loop's turn", "back over the arch to the test, the mark coming round; the count struck as it lands", 5, + None, ((R1, R2), 0.6)), + ("4", "the way out", "not taken, the fourth time: under the body to the exit, landed", 9, 0x4011d0, None), ] - for k, (num, title, sub, upto, cur, notes, moving) in enumerate(inst): - dx = 64 + k * 940 - g.o.append(f'') - g.t(64, 40, num, 28, GOLD, "sansb") - g.t(92, 40, title, 28, VELLUM, "sansm") - g.t(64, 70, sub, 20, FAINT, "sans") - cnt, ec, trail = run_state(REV_BL, REV_PATH, upto, REV_BASE) + for k, (num, title, sub, upto, cur, moving) in enumerate(inst): + x, y = 64 + (k % 2) * 912, 40 + (k // 2) * 280 + g.t(x, y + 24, num, 28, GOLD, "sansb") + g.t(x + 28, y + 24, title, 28, VELLUM, "sansm") + g.t(x, y + 52, sub, 18, FAINT, "sans") + path = REV_PATH[:upto] + ([moving[0][1]] if moving else []) + cnt, ec, trail = run_state(REV_BL, path, len(path), REV_BASE) + if moving: # the mark is on its edge: the target not yet entered, the edge lit + cnt[moving[0][1]] -= 1 st = {"blocks": {a: {"count": cnt.get(a, 0)} for a in REV_BL}, "edge_counts": ec, "edge_trail": trail} if cur: ca = max(a for a in REV_BL if a <= cur) - st["blocks"][ca].update(cur=cur, notes=notes, cur_line=20 if ca == R2 else 21 if ca == R1 else 26) - if moving == (R1, R2): - st["struck_count"] = moving - pos, ats, hgt = graph(g, 64, 96, 900, "disassembly · reverse", "", REV_BL, R0, REV_BASE, cols, st, pitch=470, - gap=48, notes_w=18 * A) - if moving: # the mark between blocks: the gold plaque halfway along the edge it takes - pts = st["paths"][moving] - seg = [(p, q, abs(q[0] - p[0]) + abs(q[1] - p[1])) for p, q in zip(pts, pts[1:])] - half, run = sum(l for _, _, l in seg) / 2, 0 - for p, q, l in seg: - if run + l >= half: - f = (half - run) / l - mx, my = p[0] + (q[0] - p[0]) * f, p[1] + (q[1] - p[1]) * f - break - run += l - g.rect(mx - 12, my - 12, 24, 24, GOLD) - up = q[1] < p[1] - g.path(f"M{mx},{my + (-6 if up else 6)} l-6,{8 if up else -8} h12 Z", fill=gen.INK) - g.o.append("") + st["blocks"][ca].update(cur=cur) + track_lens(g, x, y + 72, 880, 200, REV_BL, R0, REV_BASE, st, "the blocks of reverse", moving=moving, + struck=moving[0] if moving and moving[0] == (R1, R2) else None) g.save(name) -# ---- the working frame: a `blocks` lens, the graph as shapes, its view the disassembly ----------------------- -def silhouette(g, x, y, w, h, bl, entry, base, cols, st, title): - """The graph without its text: a block a box 24 high, as wide as its rows (8 a row, 72 at least), its offset - and visits; the pc's gold; edges and lanes as on the map, small.""" +# ---- the layered form, as the lens drew it before the track (the comparison sheet) ------------------------- +def silhouette(g, x, y, w, h, bl, entry, base, cols, st, title, rounded=False, pitch=300): + """The layered form without its text (the lens before the track): a block a box 24 high, as wide as its rows + (10 a row, 132 at least), its offset and visits; the pc's gold; edges and lanes as on the map, small. + rounded: the same layers with pills and round corners (the comparison sheet's second form).""" lay, back = layers(bl, entry) widths = {a: max(132, 60 + len(bl[a].rows) * 10) for a in bl} heights = {a: 24 for a in bl} nb = len(back) x0 = x + 24 + nb * 10 + 16 - pos, lh, ly = place(bl, lay, cols, widths, heights, x0 + 60, y + TAG + 14, 300, 12) + pos, lh, ly = place(bl, lay, cols, widths, heights, x0 + 60, y + TAG + 14, pitch, 12) C.tag(g, x, y, w, h, title, focus=True, note="its blocks · the visits · the path") edges(g, bl, lay, back, pos, widths, heights, lh, ly, 12, st, base, x + 24, max(pos[a][0] + widths[a] for a in bl) + 20, - small=True) + small=True, radius=12 if rounded else None) for a in bl: s_ = st["blocks"].get(a, {}) bx, by = pos[a] cur = s_.get("cur") - g.rect(bx, by, widths[a], 24, RAISED if s_.get("count") else PAGE) - g.frame(bx, by, widths[a], 24, GOLD if cur else RULE, 2 if not cur else 3) - g.t(bx + 8, b(by), "+%x" % (a - base), S, VELLUM if s_.get("count") else FAINT, MONO) + if rounded: + pill(g, bx, by, widths[a], RAISED if s_.get("count") else PAGE, GOLD if cur else RULE, 3 if cur else 2) + else: + g.rect(bx, by, widths[a], 24, RAISED if s_.get("count") else PAGE) + g.frame(bx, by, widths[a], 24, GOLD if cur else RULE, 2 if not cur else 3) + g.t(bx + (12 if rounded else 8), b(by), "+%x" % (a - base), S, VELLUM if s_.get("count") else FAINT, MONO) if s_.get("count"): - g.t(bx + widths[a] - 8, b(by), "×%d" % s_["count"], S, DIM, MONO, "end") - return pos + g.t(bx + widths[a] - (12 if rounded else 8), b(by), "×%d" % s_["count"], S, DIM, MONO, "end") + return pos, max(by for _, by in pos.values()) + 24 - y -def frame_lens(name): - """Mock 25: sort at moment 370 in the working frame with the `blocks` lens: its drawing the graph as shapes, - its view the disassembly round the pc (moved from the program column, which is the source's alone).""" - gen.W, gen.H = 1920, 1080 +# ---- the track ---------------------------------------------------------------------------------------------- +def loops_of(bl, entry): + """Layers and back edges as `layers` finds them, and each loop's blocks: a back edge's natural loop (its + header, and every block that reaches its latch without passing the header), loops of one header merged.""" + lay, back = layers(bl, entry) + preds = {a: [] for a in bl} + for a in bl: + for t, _ in bl[a].out: + preds[t].append(a) + loops = {} + for a, h in back: + body, todo = {h, a}, [a] + while todo: + n = todo.pop() + if n == h: + continue + for p in preds[n]: + if p not in body: + body.add(p) + todo.append(p) + loops.setdefault(h, set()).update(body) + return lay, back, loops + + +def track_order(bl, lay, loops): + """The line's order: as they run (by layer, then address), each loop's blocks together from its header, so + that a block outside a loop never sits on its floor; the blocks that return last.""" + def emit(nodes, header=None): + out, done = [], set() + for a in sorted(nodes, key=lambda a: (lay[a], a)): + if a in done: + continue + if a in loops and a != header and loops[a] <= nodes: + inner = emit(loops[a], a) + out += inner + done |= set(inner) + else: + out.append(a) + done.add(a) + return out + return emit(set(bl)) + + +def spans_levels(spans): + """Arches (or dips) by nesting: one that holds another is a level higher, so that none crosses another.""" + lv = {} + for s in sorted(spans, key=lambda s: s[1] - s[0]): + inner = [lv[o[2]] for o in spans if o[2] in lv and s[0] <= o[0] and o[1] <= s[1] and o[2] != s[2]] + lv[s[2]] = 1 + max(inner, default=0) + return lv + + +class Path: + """An edge as drawn: straight runs and quarter circles, one family. Kept as points too, to measure it and to + put the travelling mark on it.""" + def __init__(self, x, y): + self.d, self.pts = f"M{x:.1f},{y:.1f}", [(x, y)] + + def to(self, x, y): + self.d += f" L{x:.1f},{y:.1f}" + self.pts.append((x, y)) + return self + + def arc(self, x, y, r, cw): + """A circular arc of radius r to (x, y), clockwise on the screen when cw.""" + x0, y0 = self.pts[-1] + self.d += f" A{r:.1f},{r:.1f} 0 0 {1 if cw else 0} {x:.1f},{y:.1f}" + cl = math.hypot(x - x0, y - y0) + ux, uy = (x - x0) / cl, (y - y0) / cl + hh = math.sqrt(max(r * r - cl * cl / 4, 0)) + nx, ny = (-uy, ux) if cw else (uy, -ux) + cx, cy = (x0 + x) / 2 + nx * hh, (y0 + y) / 2 + ny * hh + a0, a1 = math.atan2(y0 - cy, x0 - cx), math.atan2(y - cy, x - cx) + if cw and a1 < a0: + a1 += 2 * math.pi + if not cw and a1 > a0: + a1 -= 2 * math.pi + for k in range(1, 17): + a = a0 + (a1 - a0) * k / 16 + self.pts.append((cx + r * math.cos(a), cy + r * math.sin(a))) + return self + + def length(self): + return sum(math.hypot(q[0] - p[0], q[1] - p[1]) for p, q in zip(self.pts, self.pts[1:])) + + def at(self, f): + """The point a fraction f along, and the unit direction there.""" + goal, run = self.length() * f, 0 + for p, q in zip(self.pts, self.pts[1:]): + l_ = math.hypot(q[0] - p[0], q[1] - p[1]) + if l_ and run + l_ >= goal: + k = (goal - run) / l_ + return (p[0] + (q[0] - p[0]) * k, p[1] + (q[1] - p[1]) * k), ((q[0] - p[0]) / l_, (q[1] - p[1]) / l_) + run += l_ + p, q = self.pts[-2], self.pts[-1] + l_ = math.hypot(q[0] - p[0], q[1] - p[1]) + return q, ((q[0] - p[0]) / l_, (q[1] - p[1]) / l_) + + +def draw_path(g, p, ink, sw, dash=None, hl=8, hw=8): + """The edge and its head on its last point; the stroke stops at the head's base (its last leg is straight).""" + (x1, y1), (x2, y2) = p.pts[-2], p.pts[-1] + l_ = math.hypot(x2 - x1, y2 - y1) + ux, uy = (x2 - x1) / l_, (y2 - y1) / l_ + d = p.d[:p.d.rfind(" L")] + f" L{x2 - ux * (hl - 1):.1f},{y2 - uy * (hl - 1):.1f}" + g.path(d, ink, sw, dash=dash, join="round", cap="butt") + gen.head_tri(g, x2, y2, ux, uy, ink, hl, hw) + + +def pill(g, x, y, w, fill, stroke, sw=2, dash=None): + """A block in the lens: a pill 24 high, its ends half circles.""" + a = (f'") + + +def mark(g, p, f, ink=GOLD): + """The current mark travelling an edge: the gold plaque, its point the way it goes.""" + (mx, my), (ux, uy) = p.at(f) + g.rect(mx - 11, my - 11, 22, 22, ink) + gen.head_tri(g, mx + ux * 6, my + uy * 6, ux, uy, gen.INK, 12, 10) + + +def edge_ink(e, st): + """Never taken in the whole recording: rule, dashed. Not yet: rule. Taken: dim. The last three: the trail's + golds, the newest 3 units.""" + trail = st.get("edge_trail", []) + if e in trail: + return TRAIL[trail.index(e)], 3 if trail.index(e) == 0 else 2, None + if st.get("edge_counts", {}).get(e, 0): + return DIM, 2, None + return RULE, 2, "12 8" if e in st.get("never", ()) else None + + +TRACK = dict(gap=40, arch=52, arch_step=36, dip=44, dip_step=16, stub=10, port=16) + + +def track_lens(g, x, y, w, h, bl, entry, base, st, title, note="its blocks · the visits · the path · the loops' turns", + tag=True, moving=None, struck=None): + """The `blocks` lens: the function as a track across the band. A block a pill 24 high (its offset, its + visits; as long as its rows at 10 a row, the text's length at least) on one line, in the order they run; + an edge to the next block a straight run along the line; a loop's back edge an arch over its blocks, out of + its latch's top and down into its header's (the loop is the closed shape the arch and its floor make, its + turns at its centre); a forward jump past blocks a dip under them. Arches nest by level, 32 apart; dips 16. + moving: (edge, fraction): the mark on that edge. struck: an arch whose count is being struck. + Returns the edges' paths, and the line's y.""" + lay, back, loops = loops_of(bl, entry) + order = track_order(bl, lay, loops) + idx = {a: i for i, a in enumerate(order)} + + def text_of(a): + n = st["blocks"].get(a, {}).get("count", 0) + return "+%x" % (a - base), ("×%d" % n) if n else "" + pw = {a: max(24 + (len(text_of(a)[0]) + len(text_of(a)[1]) + 1) * A + 8, 10 * len(bl[a].rows) + 24) for a in order} + gap = TRACK["gap"] + total = sum(pw.values()) + gap * (len(order) - 1) + xs, xx = {}, x + (w - total) / 2 + for a in order: + xs[a] = xx + xx += pw[a] + gap + arches = [(idx[t], idx[a], (a, t)) for a, t in back] + dips = [(idx[a], idx[t], (a, t)) for a in order for t, _ in bl[a].out + if (a, t) not in back and idx[t] > idx[a] + 1] + al, dl = spans_levels(arches), spans_levels(dips) + H = lambda k: TRACK["arch"] + TRACK["arch_step"] * (k - 1) + D = lambda k: TRACK["dip"] + TRACK["dip_step"] * (k - 1) + top, foot = H(max(al.values(), default=1)), D(max(dl.values(), default=1)) + y0 = y + TAG + (h - TAG - top - foot) / 2 + top + if tag: + C.tag(g, x, y, w, h, title, focus=True, note=note) + paths = {} + s_, P = TRACK["stub"], TRACK["port"] + for a in order: + for t, kind in bl[a].out: + e = (a, t) + if e in back: # out of the latch's top, over, down into the header's + k, r = H(al[e]), H(al[e]) - 12 - s_ + xa, xt = xs[a] + pw[a] - P, xs[t] + P + p = (Path(xa, y0 - 12).to(xa, y0 - 12 - s_).arc(xa - r, y0 - k, r, False).to(xt + r, y0 - k) + .arc(xt, y0 - 12 - s_, r, False).to(xt, y0 - 12)) + elif idx[t] == idx[a] + 1: # to the next block: along the line + p = Path(xs[a] + pw[a], y0).to(xs[t], y0) + else: # past blocks: under them + k, r = D(dl[e]), D(dl[e]) - 12 - s_ + xa, xt = xs[a] + pw[a] - P, xs[t] + P + p = (Path(xa, y0 + 12).to(xa, y0 + 12 + s_).arc(xa + r, y0 + k, r, False).to(xt - r, y0 + k) + .arc(xt, y0 + 12 + s_, r, False).to(xt, y0 + 12)) + paths[e] = p + for e, p in sorted(paths.items(), key=lambda kv: kv[0] in st.get("edge_trail", ())): # the trail on top + ink, sw, dash = edge_ink(e, st) + draw_path(g, p, ink, sw, dash) + for a, t in back: # each loop's turns, at its centre: under its arch, over what it holds + e = (a, t) + n = st.get("edge_counts", {}).get(e, 0) + inner = max([H(al[o]) for o in al if al[o] < al[e]] + [12]) + cx, cy = (xs[t] + xs[a] + pw[a]) / 2, y0 - inner - (H(al[e]) - inner) * 0.4 # clear of the mark on the arch + s = "×%d" % n + if struck == e: + g.rect(cx - len(s) * A / 2 - 5, cy - 11, len(s) * A + 10, 22, C.SOFT) + g.t(cx, cy + 7, s, S, BRIGHT, BOLD, "middle") + elif n: + g.t(cx, cy + 7, s, S, DIM, MONO, "middle") + for a in order: + s0 = st["blocks"].get(a, {}) + n, cur = s0.get("count", 0), s0.get("cur") and not moving + pill(g, xs[a], y0 - 12, pw[a], RAISED if n else PAGE, GOLD if cur else RULE, 3 if cur else 2) + off, cnt = text_of(a) + g.t(xs[a] + 12, b(y0 - 12), off, S, VELLUM if n else FAINT, MONO) + if cnt: + g.t(xs[a] + pw[a] - 12, b(y0 - 12), cnt, S, DIM, MONO, "end") + for i, r_ in enumerate(bl[a].rows): # a call that comes back: a hook under the pill, out and in again + if r_[2] == "call" and r_[5] and r_[5] not in NORETURN: + cx = xs[a] + 16 + (pw[a] - 48) * i / max(len(bl[a].rows) - 1, 1) + g.path(f"M{cx:.1f},{y0 + 12:.1f} v6 a5,5 0 0 0 10,0 v-6", DIM if n else RULE, 2) + g.t(cx + 16, y0 + 34, r_[5], S, VELLUM if n else FAINT, MONO) + if moving: + mark(g, paths[moving[0]], moving[1]) + return paths, y0, xs, pw + + +def track_map(g, x, y, w, bl, entry, base, st, title, note, notes_w=0): + """The map's graph: the same track run down, a block a card that carries its rows (`draw_block`), the cards + in the line's order on one spine 40 in from their left; a back edge leaves its latch's left side and climbs + a lane on the left, 48 apart, into its header's head; a forward jump past cards leaves the source's right + side and goes down a channel on the right into its target's head. Every bend a quarter circle of 16; cards 10 + apart. The turns in the lobe between a lane and what it holds; a conditional's two ways counted in words in + its jump's row (`taken 5 · not 6`), where the pc's block has the jump's own annotation. + Returns the panel's height and each card's rows' y.""" + lay, back, loops = loops_of(bl, entry) + order = track_order(bl, lay, loops) + idx = {a: i for i, a in enumerate(order)} + fold = lambda a: hasattr(bl[a], "folded") + split_w = lambda a: (X_OPS + max(len("%x" % (bl[a].rows[-1][4] or 0)) + 2, 10) * A + 17 * A + if len(bl[a].out) == 2 and st["blocks"].get(a, {}).get("count") + and not st["blocks"].get(a, {}).get("cur") else 0) + widths = {a: 520 if fold(a) else max(block_w(bl[a], base, notes_w if st["blocks"].get(a, {}).get("notes") else 0), + split_w(a)) for a in order} + heights = {a: TAG + (ROW if fold(a) else len(fold_rows(bl[a].rows, st["blocks"].get(a, {}).get("cur"))) * ROW) + PAD + for a in order} + arches = [(idx[t], idx[a], (a, t)) for a, t in back] + dips = [(idx[a], idx[t], (a, t)) for a in order for t, _ in bl[a].out + if (a, t) not in back and idx[t] > idx[a] + 1] + al, dl = spans_levels(arches), spans_levels(dips) + cx0 = x + 24 + 48 * max(al.values(), default=0) + 12 + ys, yy = {}, y + TAG + 8 + for a in order: + ys[a] = yy + yy += heights[a] + 10 + yy += 10 # room under the last card for the way out's bar + hook = lambda a: max([28 + len(r[5]) * A for r in bl[a].rows if r[2] == "call" and r[5]] + [0]) if not fold(a) else 0 + chan = max(cx0 + widths[a] + hook(a) for a in order) + 24 + hgt = yy - y + C.tag(g, x, y, w, hgt, title, focus=True, note=note) + R, spine = 16, cx0 + 40 + paths = {} + for a in order: + for t, kind in bl[a].out: + e = (a, t) + ya, yt = ys[a] + heights[a] - 14, ys[t] + 12 + if e in back: + L = cx0 - 48 * al[e] + p = (Path(cx0, ya).to(L + R, ya).arc(L, ya - R, R, True).to(L, yt + R).arc(L + R, yt, R, True) + .to(cx0, yt)) + elif idx[t] == idx[a] + 1: + p = Path(spine, ys[a] + heights[a]).to(spine, ys[t]) + else: + Cx = chan + 32 * (dl[e] - 1) + p = (Path(cx0 + widths[a], ya).to(Cx - R, ya).arc(Cx, ya + R, R, True).to(Cx, yt - R) + .arc(Cx - R, yt, R, True).to(cx0 + widths[t], yt)) + paths[e] = p + for e, p in sorted(paths.items(), key=lambda kv: kv[0] in st.get("edge_trail", ())): + ink, sw, dash = edge_ink(e, st) + draw_path(g, p, ink, sw, dash, hl=10, hw=10) + counts = st.get("edge_counts", {}) + for a, t in back: # the turns, in the lobe + e = (a, t) + n = counts.get(e, 0) + if n: + L = cx0 - 48 * al[e] + g.t(L + 24, (ys[t] + ys[a] + heights[a]) / 2 + 7, "×%d" % n, S, DIM, MONO, "middle") + ats = {} + for a in order: + s0 = dict(st["blocks"].get(a, {})) + if len(bl[a].out) == 2 and not fold(a) and s0.get("count"): # a conditional reached: its two ways counted + (t1, k1), (t2, k2) = bl[a].out + tk, nt = (t1, t2) if k1 == "taken" else (t2, t1) + s0["split"] = (counts.get((a, tk), 0), counts.get((a, nt), 0)) + _, at = draw_block(g, cx0, ys[a], widths[a], bl[a], base, s0) + ats.update(at) + return hgt, ats, paths + + +# ---- rings: the comparison sheet's third form, each loop a circle its blocks sit on ---------------------------- +RING_AT = {0x12: ("o", 180), 0x1e: ("o", 235), 0x24: ("o", 300), 0x5d: ("o", 25), 0x97: ("o", 80), 0x99: ("o", 130), + 0x2f: ("i", 15), 0x56: ("i", 95), 0x5f: ("i", 185)} + + +def rings(g, x, y, w, h, st, title): + """sort as rings: the outer loop a circle of 170, its blocks round it clockwise; the inner loop a circle of 92 + inside it, touching it at its header; the way in and the way out as short tracks at the left; a loop's exit a + chord between the rings. Every edge an arc of its ring or a straight chord.""" + C.tag(g, x, y, w, h, title, focus=True, note="its blocks · the visits · the path · the loops' turns") + R, r = 170, 92 + ox, oy = x + w / 2 + 120, y + TAG + 24 + R + t0 = math.radians(300) + ix, iy = ox + (R - r) * math.cos(t0), oy + (R - r) * math.sin(t0) + ring = {"o": (ox, oy, R), "i": (ix, iy, r)} + pos = {} + for off, (k, deg) in RING_AT.items(): + cx, cy, rr = ring[k] + pos[O(off)] = (cx + rr * math.cos(math.radians(deg)), cy + rr * math.sin(math.radians(deg))) + pos[O(0x0)] = (ox - R - 170, oy) + pos[O(0xa7)] = (ox - R - 170, oy + 96) + texts = {a: ("+%x" % (a - SORT_BASE), "×%d" % st["blocks"][a]["count"] if st["blocks"][a]["count"] else "") + for a in SORT_BL} + pw = {a: 24 + (len(texts[a][0]) + len(texts[a][1]) + 1) * A + 8 for a in SORT_BL} + inside = lambda a, px, py: abs(px - pos[a][0]) < pw[a] / 2 + 4 and abs(py - pos[a][1]) < 16 + + def on_ring(a, t, k): + """The arc of ring k from a's pill to t's, clockwise, cut where each pill ends.""" + cx, cy, rr = ring[k] + a0 = math.atan2(pos[a][1] - cy, pos[a][0] - cx) + a1 = math.atan2(pos[t][1] - cy, pos[t][0] - cx) + while a1 <= a0: + a1 += 2 * math.pi + pt = lambda th: (cx + rr * math.cos(th), cy + rr * math.sin(th)) + s, e = a0, a1 + while inside(a, *pt(s)): + s += 0.005 + while inside(t, *pt(e)): + e -= 0.005 + p = Path(*pt(s)) + p.arc(*pt(e), rr, True) + return p + paths = {} + for a in SORT_BL: + for t, kind in SORT_BL[a].out: + ka, kt = RING_AT.get(a - SORT_BASE, (None,))[0], RING_AT.get(t - SORT_BASE, (None,))[0] + if (a, t) == (O(0x0), O(0x12)): + p = Path(pos[a][0] + pw[a] / 2, oy).to(pos[t][0] - pw[t] / 2, oy) + elif (a, t) == (O(0x12), O(0xa7)): + sx = pos[a][0] - 20 + p = (Path(sx, oy + 12).to(sx, oy + 40).arc(sx - 56, oy + 96, 56, True) + .to(pos[t][0] + pw[t] / 2, oy + 96)) + elif ka and kt and ka == kt or (a - SORT_BASE, t - SORT_BASE) in ((0x24, 0x2f), (0x5f, 0x24)): + p = on_ring(a, t, "i" if (a - SORT_BASE, t - SORT_BASE) in ((0x24, 0x2f), (0x5f, 0x24)) else ka) + else: # between the rings, or across one: a chord + (ax, ay), (tx, ty) = pos[a], pos[t] + d = math.hypot(tx - ax, ty - ay) + ux, uy = (tx - ax) / d, (ty - ay) / d + s, e = 0, d + while inside(a, ax + ux * s, ay + uy * s): + s += 1 + while inside(t, ax + ux * e, ay + uy * e): + e -= 1 + p = Path(ax + ux * s, ay + uy * s).to(ax + ux * e, ay + uy * e) + paths[(a, t)] = p + for e, p in sorted(paths.items(), key=lambda kv: kv[0] in st.get("edge_trail", ())): + ink, sw, dash = edge_ink(e, st) + if len(p.pts) > 2: # an arc: its head on the tangent at its end + draw_arc_head(g, p, ink, sw, dash) + else: + draw_path(g, p, ink, sw, dash) + for (cx, cy, rr), e in ((ring["o"], (O(0x99), O(0x12))), (ring["i"], (O(0x5f), O(0x24)))): + n = st["edge_counts"].get(e, 0) + tx, ty = (cx, cy) if rr < R else (cx - 80, cy + 60) + g.t(tx, ty + 7, "×%d" % n, S, DIM, MONO, "middle") + for a in SORT_BL: + s0 = st["blocks"][a] + n, cur = s0.get("count", 0), s0.get("cur") + px, py = pos[a][0] - pw[a] / 2, pos[a][1] - 12 + pill(g, px, py, pw[a], RAISED if n else PAGE, GOLD if cur else RULE, 3 if cur else 2) + g.t(px + 12, b(py), texts[a][0], S, VELLUM if n else FAINT, MONO) + if texts[a][1]: + g.t(px + pw[a] - 12, b(py), texts[a][1], S, DIM, MONO, "end") + sx, sy = pos[O(0x5f)][0] + 26, pos[O(0x5f)][1] - 12 + g.path(f"M{sx:.1f},{sy:.1f} v-6 a5,5 0 0 1 10,0 v6", DIM, 2) + g.t(sx + 16, sy - 6, "swap", S, VELLUM, MONO) + + +def draw_arc_head(g, p, ink, sw, dash): + """An arc, its stroke ending where its head begins, the head on the arc's tangent.""" + pts, run, cut = p.pts, 0, 7 + k = len(pts) - 1 + while k > 0 and run < cut: + run += math.hypot(pts[k][0] - pts[k - 1][0], pts[k][1] - pts[k - 1][1]) + k -= 1 + d = "M%.1f,%.1f " % pts[0] + " ".join("L%.1f,%.1f" % q for q in pts[1:k + 1]) + g.path(d, ink, sw, dash=dash, join="round") + (x1, y1), (x2, y2) = pts[-2], pts[-1] + l_ = math.hypot(x2 - x1, y2 - y1) + gen.head_tri(g, x2, y2, (x2 - x1) / l_, (y2 - y1) / l_, ink, 8, 8) + + +def frame_forms(name): + """Mock 43: sort's graph four ways, at the same moment and at the lens's scale: the present form, its layers + rounded, rings, and the track (recommended), each in the box it is given and at the size it needs.""" + gen.W, gen.H = 1920, 1600 g = Svg() - st = sort_state(UPTO, 0x4011db, [0x4011d9, 0x4011d6, 0x4011cf], NOTES_370) - pos = silhouette(g, 64, 48, 880, 296, SORT_BL, SB[0], SORT_BASE, {a: c for a, c in SORT_COLS.items()}, st, - "the blocks of sort") - # its view: the disassembly, seven rows round the pc, the block's rows bracketed as the drawing's gold box - C.LX, C.CW = 976, 880 - rows = [(a, ln, mn, [(t, CODE)] if t and mn.startswith("j") else [(ops, VELLUM)], - "cur" if a == 0x4011db else {0x4011d9: "trail0", 0x4011d6: "trail1", 0x4011cf: "trail2"}.get(a), - ("runs", NOTES_370[a]) if a in NOTES_370 else None) - for a, ln, mn, ops, t, callee in SORT if 0x4011c7 <= a <= 0x4011e1] # seven rows: the view's - C.disasm(g, 48, rows, "sort · +84 to +a1", 12) - C.LX, C.CW = 64, 880 - # the program column: the source alone - src = open(HERE + "/../../anim/tools/sort.c").read().split("\n") - C.source(g, 356, 21, src, 1, 12, [14, 13], "sort.c", 22) - # registers and the stack, moment 370 - S_, H_ = STACK, HEAP - E = [(0x7fffffffed00, S_), (0x7fffffffedb0, S_), (0x7fffffffee10, S_)] - regs = [("rax", [], ("int", 5)), ("rbx", [], ("int", 0)), ("rcx", [], ("int", 0x10)), ("rdx", [], ("int", 0x11)), - ("rsi", [(0x404034, DATA)], ("int", 0x1f0000001a)), ("rdi", [(0x404030, DATA)], ("int", 0x1a00000005)), - ("rbp", [(0x7fffffffecf0, S_)] + E, ("int", 0)), ("rsp", [(0x7fffffffecd8, S_)], ("int", 0x800000000)), - ("r8", [(0x7ffff7e19680, DATA)], None), ("r9", [(0x7ffff7e1afa0, DATA)], None), - ("r10", [(0x7fffffffea60, S_)], ("int", 0)), ("r11", [(0x7ffff7ffca90, DATA)], ("int", 0x786843bb9f54c5c1)), - ("r12", [(0x7fffffffee38, S_), (0x7fffffffefea, S_)], ("str", "./sort")), ("r13", [], ("int", 1)), - ("r14", [(0x7ffff7ffd000, DATA), (0x7ffff7ffe3c0, DATA)], ("int", 0)), - ("r15", [(0x403e10, DATA), (0x4010e0, CODE, "__do_global_dtors_aux")], None), - ("rip", [(0x4011db, CODE, "sort+152")], None)] - flags = [("CF", 0, 0), ("PF", 1, 0), ("AF", 1, 0), ("ZF", 0, 0), ("SF", 0, 0), ("IF", 1, 0), ("DF", 0, 0), ("OF", 0, 0)] - C.RX = 976 - C.registers(g, 260, regs, flags, {"rax": {0: "tick"}, "rdx": {0: "tick"}}) - C.stack(g, 712, [(0x7fffffffecd8, ["rsp"], [], ("int", 0x800000000)), (0x7fffffffece0, [], [], ("int", 0)), - (0x7fffffffece8, [], [], ("int", 0x400000006)), (0x7fffffffecf0, ["rbp"], E, ("int", 0)), - (0x7fffffffecf8, [], [(0x4011ff, CODE, "main+14")], None), - (0x7fffffffed00, [], E[1:], ("int", 0))], - [("sort(8)", 0, 4)], rsp=0x7fffffffecd8, - roles={2: ("i, j", VELLUM), 3: ("saved rbp", DIM)}) - C.clock(g, 370, 465) - gen.caption(g, [[("The sixth pass, its third compare: ",), ("17 : 5", "mono"), (", so ",), ("jg", "mono"), - (" goes back to the swap.",)], - [("The swap has run 5 times so far; the outer loop has turned 5.",)]]) + st = sort_state(UPTO, PC, TRAIL_ROWS, NOTES) + g.t(64, 56, "sort's graph, four ways", 36, BRIGHT, "sansm") + g.t(64, 90, "The same moment in each (the 11th compare: 17 > 5, jne about to take the swap); the lens's scale, " + "mono 20. Veiled: what falls outside the box the frame gives the lens.", 20, DIM, "sans") + + def veil(x, y, w, h): + g.o.append(f'') + + def label(x, y, key, title, sub): + g.t(x, y, key, 28, GOLD if key == "4" else BRIGHT, "sansb") + g.t(x + 30, y, title, 28, VELLUM, "sansm") + g.t(x, y + 28, sub, 18, FAINT, "sans") + cols = {a: 0 for a in SORT_BL} + cols[O(0xa7)] = 1 + cols[O(0x5f)] = 1 + for k, (key, title, sub, rounded) in enumerate(( + ("1", "present: layers, boxes, square lanes", "ten layers, 400 high: past the lens's 296 (veiled), so it " + "pans; a third of its width", False), + ("2", "the same layers, rounded", "pills and round corners: smoother, and just as tall", True))): + x = 64 + k * 912 + label(x, 152, key, title, sub) + _, hh = silhouette(Svg(), x, 212, 880, 999, SORT_BL, SB[0], SORT_BASE, cols, st, "", rounded, pitch=330) + silhouette(g, x, 212, 880, hh + 16, SORT_BL, SB[0], SORT_BASE, cols, st, "the blocks of sort", rounded, pitch=330) + veil(x - 2, 212 + 296, 884, hh + 16 - 296 + 2) + label(64, 704, "3", "rings", "each loop a circle its blocks sit on, the inner inside the outer: 420 high, " + "past the band's 200 (veiled)") + rings(g, 64, 764, 880, 420, st, "the blocks of sort") + veil(62, 764 + 200, 884, 222) + nx = 976 + for i, (s, ink) in enumerate(( + ("What each costs", VELLUM), + ("1 The tools' picture. Tall by nature: a layer a block,", DIM), + (" so it pans in a short pane, and leaves the width.", DIM), + ("2 Rounding the corners does not change the shape.", DIM), + ("3 The most circular, and a loop is a ring; but rings", DIM), + (" want a square pane, a loop's way out is a chord", DIM), + (" across them, and pills on its sides sit across it.", DIM), + ("4 The track. A line of blocks as they run, each loop", VELLUM), + (" an arch over its own blocks: a closed shape, its", VELLUM), + (" turns at its centre; a jump past blocks a dip", VELLUM), + (" under them. Wide and short: 11 blocks in 1622", VELLUM), + (" by 150, whole. Its order is the disassembly's,", VELLUM), + (" which is under the source; run down, it is the", VELLUM), + (" map's column with its rows.", VELLUM))): + g.t(nx, 730 + i * 30, s, 22 if i == 0 else 20, ink, "sansm" if i == 0 else "sans") + label(64, 1220, "4", "the track: recommended", "the band across the frame, 1792 by 200: the whole graph, no pan") + paths, y0, xs, pw = track_lens(g, 64, 1280, 1792, 200, SORT_BL, SB[0], SORT_BASE, st, "the blocks of sort") + print("43: the track is %d wide" % (max(xs[a] + pw[a] for a in xs) - min(xs.values()))) + g.t(64, 1530, "Ink in 3 and 4: never taken in the whole run, dashed rule (j > 0 failing); not yet, rule (the " + "way out); taken, dim; the last three, the trail's golds. 1 and 2 keep the layers' ink: never taken, rule.", + 18, DIM, "sans") g.save(name) if __name__ == "__main__": - assert len(SORT_BL) == 8 and len(REV_BL) == 4, (len(SORT_BL), len(REV_BL)) - assert Counter(SORT_PATH)[NAMES["B4"]] == 17 and Counter(SORT_PATH)[NAMES["B2"]] == 10 + assert len(SORT_BL) == 11 and len(REV_BL) == 4, (len(SORT_BL), len(REV_BL)) + assert Counter(SORT_PATH)[O(0x56)] == 17 and Counter(SORT_PATH)[O(0x5f)] == 10 + lay_, back_, loops_ = loops_of(SORT_BL, SB[0]) + assert [a - SORT_BASE for a in track_order(SORT_BL, lay_, loops_)] == \ + [0x0, 0x12, 0x1e, 0x24, 0x2f, 0x56, 0x5f, 0x5d, 0x97, 0x99, 0xa7] frame_sort_map("22-graph-sort") frame_open_map("23-graph-open") frame_strip("24-graph-strip") - frame_lens("25-blocks-lens") + frame_forms("43-graph-forms") diff --git a/design/mock/sort-O0.dis b/design/mock/sort-O0.dis deleted file mode 100644 index c159f50..0000000 --- a/design/mock/sort-O0.dis +++ /dev/null @@ -1,61 +0,0 @@ -0000000000401143 : -sort(): -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:9 - 401143: push rbp - 401144: mov rbp,rsp - 401147: sub rsp,0x18 - 40114b: mov DWORD PTR [rbp-0x14],edi -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:10 - 40114e: mov DWORD PTR [rbp-0x8],0x1 - 401155: jmp 4011e1 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:11 - 40115a: mov eax,DWORD PTR [rbp-0x8] - 40115d: mov DWORD PTR [rbp-0x4],eax -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:12 - 401160: jmp 4011a2 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:13 - 401162: mov eax,DWORD PTR [rbp-0x4] - 401165: cdqe - 401167: lea rdx,[rax*4+0x0] - 40116f: lea rax,[rip+0x2eaa] # 404020 - 401176: add rdx,rax - 401179: mov eax,DWORD PTR [rbp-0x4] - 40117c: sub eax,0x1 - 40117f: cdqe - 401181: lea rcx,[rax*4+0x0] - 401189: lea rax,[rip+0x2e90] # 404020 - 401190: add rax,rcx - 401193: mov rsi,rdx - 401196: mov rdi,rax - 401199: call 401116 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:14 - 40119e: sub DWORD PTR [rbp-0x4],0x1 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:12 (discriminator 1) - 4011a2: cmp DWORD PTR [rbp-0x4],0x0 - 4011a6: jle 4011dd -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:12 (discriminator 2) - 4011a8: mov eax,DWORD PTR [rbp-0x4] - 4011ab: sub eax,0x1 - 4011ae: cdqe - 4011b0: lea rdx,[rax*4+0x0] - 4011b8: lea rax,[rip+0x2e61] # 404020 - 4011bf: mov edx,DWORD PTR [rdx+rax*1] - 4011c2: mov eax,DWORD PTR [rbp-0x4] - 4011c5: cdqe - 4011c7: lea rcx,[rax*4+0x0] - 4011cf: lea rax,[rip+0x2e4a] # 404020 - 4011d6: mov eax,DWORD PTR [rcx+rax*1] - 4011d9: cmp edx,eax - 4011db: jg 401162 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:10 (discriminator 1) - 4011dd: add DWORD PTR [rbp-0x8],0x1 -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:10 (discriminator 2) - 4011e1: mov eax,DWORD PTR [rbp-0x8] - 4011e4: cmp eax,DWORD PTR [rbp-0x14] - 4011e7: jl 40115a -/home/goblin/00-projects/0x4200.cafe/01-computeranim/anim/tools/sort.c:17 - 4011ed: nop - 4011ee: nop - 4011ef: leave - 4011f0: ret - diff --git a/design/mock/sort-clang.dis b/design/mock/sort-clang.dis new file mode 100644 index 0000000..9a6b085 --- /dev/null +++ b/design/mock/sort-clang.dis @@ -0,0 +1,106 @@ +0000000000401120 : +swap(): +anim/tools/sort.c:3 + 401120: push rbp + 401121: mov rbp,rsp + 401124: mov QWORD PTR [rbp-0x8],rdi + 401128: mov QWORD PTR [rbp-0x10],rsi +anim/tools/sort.c:4 + 40112c: mov rax,QWORD PTR [rbp-0x8] + 401130: mov eax,DWORD PTR [rax] + 401132: mov DWORD PTR [rbp-0x14],eax +anim/tools/sort.c:5 + 401135: mov rax,QWORD PTR [rbp-0x10] + 401139: mov ecx,DWORD PTR [rax] + 40113b: mov rax,QWORD PTR [rbp-0x8] + 40113f: mov DWORD PTR [rax],ecx +anim/tools/sort.c:6 + 401141: mov ecx,DWORD PTR [rbp-0x14] + 401144: mov rax,QWORD PTR [rbp-0x10] + 401148: mov DWORD PTR [rax],ecx +anim/tools/sort.c:7 + 40114a: pop rbp + 40114b: ret + 40114c: nop DWORD PTR [rax+0x0] + +0000000000401150 : +sort(): +anim/tools/sort.c:9 + 401150: push rbp + 401151: mov rbp,rsp + 401154: sub rsp,0x10 + 401158: mov DWORD PTR [rbp-0x4],edi +anim/tools/sort.c:10 + 40115b: mov DWORD PTR [rbp-0x8],0x1 + 401162: mov eax,DWORD PTR [rbp-0x8] + 401165: cmp eax,DWORD PTR [rbp-0x4] + 401168: jge 4011f7 +anim/tools/sort.c:11 + 40116e: mov eax,DWORD PTR [rbp-0x8] + 401171: mov DWORD PTR [rbp-0xc],eax +anim/tools/sort.c:12 + 401174: xor eax,eax + 401176: cmp DWORD PTR [rbp-0xc],0x0 + 40117a: mov BYTE PTR [rbp-0xd],al + 40117d: jle 4011a6 + 40117f: mov eax,DWORD PTR [rbp-0xc] + 401182: sub eax,0x1 + 401185: movsxd rcx,eax + 401188: lea rax,[rip+0x2e81] # 404010 + 40118f: mov eax,DWORD PTR [rax+rcx*4] + 401192: movsxd rdx,DWORD PTR [rbp-0xc] + 401196: lea rcx,[rip+0x2e73] # 404010 + 40119d: cmp eax,DWORD PTR [rcx+rdx*4] + 4011a0: setg al + 4011a3: mov BYTE PTR [rbp-0xd],al + 4011a6: mov al,BYTE PTR [rbp-0xd] + 4011a9: test al,0x1 + 4011ab: jne 4011af + 4011ad: jmp 4011e7 +anim/tools/sort.c:13 + 4011af: mov eax,DWORD PTR [rbp-0xc] + 4011b2: sub eax,0x1 + 4011b5: cdqe + 4011b7: lea rdi,[rip+0x2e52] # 404010 + 4011be: shl rax,0x2 + 4011c2: add rdi,rax + 4011c5: movsxd rax,DWORD PTR [rbp-0xc] + 4011c9: lea rsi,[rip+0x2e40] # 404010 + 4011d0: shl rax,0x2 + 4011d4: add rsi,rax + 4011d7: call 401120 +anim/tools/sort.c:14 + 4011dc: mov eax,DWORD PTR [rbp-0xc] + 4011df: add eax,0xffffffff + 4011e2: mov DWORD PTR [rbp-0xc],eax +anim/tools/sort.c:12 + 4011e5: jmp 401174 +anim/tools/sort.c:16 + 4011e7: jmp 4011e9 +anim/tools/sort.c:10 + 4011e9: mov eax,DWORD PTR [rbp-0x8] + 4011ec: add eax,0x1 + 4011ef: mov DWORD PTR [rbp-0x8],eax + 4011f2: jmp 401162 +anim/tools/sort.c:17 + 4011f7: add rsp,0x10 + 4011fb: pop rbp + 4011fc: ret + 4011fd: nop DWORD PTR [rax] + +0000000000401200
: +main(): +anim/tools/sort.c:19 + 401200: push rbp + 401201: mov rbp,rsp + 401204: sub rsp,0x10 + 401208: mov DWORD PTR [rbp-0x4],0x0 +anim/tools/sort.c:20 + 40120f: mov edi,0x8 + 401214: call 401150 +anim/tools/sort.c:21 + 401219: xor eax,eax + 40121b: add rsp,0x10 + 40121f: pop rbp + 401220: ret + diff --git a/design/mock/sort-dbg.txt b/design/mock/sort-dbg.txt new file mode 100644 index 0000000..48eb85c --- /dev/null +++ b/design/mock/sort-dbg.txt @@ -0,0 +1,151 @@ +# ztrace dbg -o sort.ztrace --stack 1024 -- ./sort (clang -O0 -g -no-pie -fno-stack-protector -Wl,-z,now, as anim/build.zig builds it less the +# instrumentation; env -i setarch -R), break at *0x4011ab (the jne after the compare), the 11th stop: a[3] = 17 against a[4] = 5. +# The path its run takes through sort's blocks is in graph.py (ztrace record --by insn --from sort, the block leaders hit). +(ztrace) ctx +moment 11 of 12, 140 events so far + +thread 1565423 anim/tools/sort.c:12:9 + rax 1 + rbx 0 + rcx 404010 ◂— 900000004 + rdx 4 + rsi 404024 ◂— 1f0000001a + rdi 404020 ◂— 1a00000005 + rbp 7fffffffece0 —▸ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + rsp 7fffffffecd0 ◂— 401000000 + r8 7ffff7e19680 + r9 7ffff7e1afa0 + r10 7fffffffea60 ◂— 0 + r11 7ffff7ffca90 ◂— ba55a1098a503203 + r12 7fffffffee38 —▸ 7fffffffefea ◂— "./sort" + r13 1 + r14 7ffff7ffd000 —▸ 7ffff7ffe3c0 ◂— 0 + r15 403e10 —▸ 4010e0 (__do_global_dtors_aux+0) + rip 4011ab (sort+91) + eflags 202 + + 00000040118f mov eax, dword ptr [rax + rcx*4] + 000000401192 movsxd rdx, dword ptr [rbp - 0xc] + 000000401196 lea rcx, [rip + 0x2e73] + 00000040119d cmp eax, dword ptr [rcx + rdx*4] + 0000004011a0 setg al + 0000004011a3 mov byte ptr [rbp - 0xd], al + 0000004011a6 mov al, byte ptr [rbp - 0xd] + 0000004011a9 test al, 1 + ► 0000004011ab jne 0x4011af + 0000004011ad jmp 0x4011e7 + 0000004011af mov eax, dword ptr [rbp - 0xc] + 0000004011b2 sub eax, 1 + 0000004011b5 cdqe + 0000004011b7 lea rdi, [rip + 0x2e52] + 0000004011be shl rax, 2 + 0000004011c2 add rdi, rax + 0000004011c5 movsxd rax, dword ptr [rbp - 0xc] + + 00:0000│ rsp 7fffffffecd0 ◂— 401000000 + 01:0008│ 7fffffffecd8 ◂— 800000006 + 02:0010│ 7fffffffece0 —▸ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + 03:0018│ 7fffffffece8 —▸ 401219 (main+25) + 04:0020│ 7fffffffecf0 ◂— 0 + 05:0028│ 7fffffffecf8 ◂— 0 + 06:0030│ 7fffffffed00 —▸ 7fffffffedb0 —▸ 7fffffffee10 ◂— 0 + 07:0038│ 7fffffffed08 ◂— 7ffff7c27781 + + #0 4011ab sort+91 (sort.c:12) + #1 401219 main+25 (sort.c:20) + #2 7ffff7c27781 + #3 7ffff7c278b9 + #4 401045 _start+37 + +mappings + 7ffff7fb6000-7ffff7fba000 [vvar] + 7ffff7fba000-7ffff7fbc000 [vvar_vclock] + 7ffff7fbc000-7ffff7fbe000 [vdso] + 7ffff7fbe000-7ffff7fbf000 /usr/lib/ld-linux-x86-64.so.2 + 7ffff7fbf000-7ffff7fec000 /usr/lib/ld-linux-x86-64.so.2 + 7ffff7fec000-7ffff7ffb000 /usr/lib/ld-linux-x86-64.so.2 + 7ffff7ffb000-7ffff7ffe000 /usr/lib/ld-linux-x86-64.so.2 + 7ffff7ffe000-7ffff7fff000 + 7ffffffde000-7ffffffff000 [stack] + ffffffffff600000-ffffffffff601000 [vsyscall] +(ztrace) x $rsp 160 +7fffffffecd0 00 00 00 01 04 00 00 00 06 00 00 00 08 00 00 00 ................ +7fffffffece0 00 ed ff ff ff 7f 00 00 19 12 40 00 00 00 00 00 ..........@..... +7fffffffecf0 00 00 00 00 00 00 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 00 12 40 00 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 ab 74 67 bf 5f eb ec bd .........tg._... +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 10 3e 40 00 00 00 00 00 .........>@..... +(ztrace) x a 32 +000000404010 04 00 00 00 09 00 00 00 0c 00 00 00 11 00 00 00 ................ +000000404020 05 00 00 00 1a 00 00 00 1f 00 00 00 14 00 00 00 ................ +(ztrace) bt +#0 4011ab sort+91 (sort.c:12) +#1 401219 main+25 (sort.c:21) +#2 7ffff7c27781 libc.so.6+27781 +#3 7ffff7c278b9 libc.so.6!__libc_start_main+137 +#4 401045 _start+37 +# The same stop in a second run (the same addresses under setarch -R; the random words differ): the stack from 16 words above rsp to its top. +(ztrace) x 0x7fffffffec50 1072 +7fffffffec50 00 00 00 00 00 00 00 00 f1 ef ff ff ff 7f 00 00 ................ +7fffffffec60 00 00 00 00 00 00 00 00 00 c0 fb f7 ff 7f 00 00 ................ +7fffffffec70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffec80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffec90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +7fffffffeca0 00 00 00 00 00 00 00 00 00 00 00 00 1a 00 00 00 ................ +7fffffffecb0 24 40 40 00 00 00 00 00 20 40 40 00 00 00 00 00 $@@..... @@..... +7fffffffecc0 e0 ec ff ff ff 7f 00 00 dc 11 40 00 00 00 00 00 ..........@..... +7fffffffecd0 00 00 00 01 04 00 00 00 06 00 00 00 08 00 00 00 ................ +7fffffffece0 00 ed ff ff ff 7f 00 00 19 12 40 00 00 00 00 00 ..........@..... +7fffffffecf0 00 00 00 00 00 00 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 00 12 40 00 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 06 74 82 47 26 40 5b 45 .........t.G&@[E +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 10 3e 40 00 00 00 00 00 .........>@..... +7fffffffed70 06 74 c2 46 26 40 5b 45 06 74 88 72 5d 50 5b 45 .t.F&@[E.t.r]P[E +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 d8 a2 bb 6c fe 55 91 8...........l.U. +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 10 3e 40 00 00 00 00 00 H........>@..... +7fffffffedd0 00 12 40 00 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 20 10 40 00 00 00 00 00 30 ee ff ff ff 7f 00 00 .@.....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 45 10 40 00 00 00 00 00 ........E.@..... +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 40 00 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 0f 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 20 10 40 00 00 00 00 00 ........ .@..... +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 1f 35 d2 8b 8e 1c f9 ..........5..... +7fffffffefd0 9c f0 c7 c5 bf e3 66 ea a8 78 38 36 5f 36 34 00 ......f..x86_64. +7fffffffefe0 00 00 00 00 00 00 00 00 00 00 2e 2f 73 6f 72 74 .........../sort +7fffffffeff0 00 2e 2f 73 6f 72 74 00 00 00 00 00 00 00 00 00 ../sort......... -- cgit v1.3