diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 20:16:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 20:27:13 -0300 |
| commit | dc3b58781420be6070fca896e55776bc27db905d (patch) | |
| tree | f77ebd77edf5a360df0ea9255f55daf47e5baf34 /anim/src/disasm.zig | |
| parent | 13fe4003276daf884da4e29112fb4db8630ad46a (diff) | |
| download | computeranim-dc3b58781420be6070fca896e55776bc27db905d.tar.gz computeranim-dc3b58781420be6070fca896e55776bc27db905d.zip | |
canim: a scene from a real program: SQLite's row on its way to disk
Three inserts stopped at sqlite3BtreeInsert with their payloads read off
the caller's stack, the commit's backtrace from unixWrite up to main, the
pwrite64 crossing into the kernel, and page 2 as the kernel took it: its
header, its cell pointers and the three rows, read by field. The scene
is built only where SQLite's source is (-Dsqlite=DIR); its recording is
181 moments, 95 KB.
What a real program asked of the blocks: a dump read by the fields a
scene gives it, with the rows between collapsed; addresses of twelve
digits and line numbers of six; the backtrace as a lens's drawing; a
continue's motion (shared frames slide, a far window fades); memory drawn
only where the stop read it. In the kernel lens a register is framed as
carrying an argument only while it holds it at the stop shown, and an
allocator row is read only where an allocation follows the word.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'anim/src/disasm.zig')
| -rw-r--r-- | anim/src/disasm.zig | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig index efdb80e..6faaade 100644 --- a/anim/src/disasm.zig +++ b/anim/src/disasm.zig @@ -158,6 +158,11 @@ pub const Disasm = struct { }; var last_line: ?u32 = null; + // A source of many lines (SQLite's) has wider numbers: what is + // right of them moves right by as much. + var widest: u32 = 0; + for (merged) |row| widest = @max(widest, row.line orelse 0); + const widen = rows.numberRoom(widest); // The thread's runs: of the line the mark leaves and of the one it // goes to, each a span of rows; published sliding from the one to // the other with the advance (`threadRuns`). @@ -182,7 +187,7 @@ pub const Disasm = struct { const is_pc = row.addr == pc[if (going >= 0.5) 1 else 0]; const was = if (is_pc) null else ran[j]; if (was) |r| lit.trail(c.mark, y, r.k); - const hangs = d.insn(lit, now, row, y, box.w, line, line != last_line, current_line, lead, if (is_pc) .current else if (was) |r| .{ .ran = r } else .ahead, base, covered > 0); + const hangs = d.insn(lit, now, row, y, box.w, widen, line, line != last_line, current_line, lead, if (is_pc) .current else if (was) |r| .{ .ran = r } else .ahead, base, covered > 0); covered = @max(covered -| 1, hangs); last_line = if (above_body) null else line; if (jumped == row.addr and !is_pc) lanes[0] = y; @@ -209,15 +214,17 @@ pub const Disasm = struct { /// where the annotation carries the address they name. `covered`: a /// call's arguments above hang in this row's annotation column. Returns /// how many rows under it its own arguments hang in. - fn insn(d: *const Disasm, u: ui.Ui, now: cursors.Now, row: Insn, y: f32, w: f32, line: ?u32, first_of_line: bool, current_line: u32, lead: usize, state: State, base: usize, covered: bool) usize { + fn insn(d: *const Disasm, at: ui.Ui, now: cursors.Now, row: Insn, y: f32, w: f32, widen: f32, line: ?u32, first_of_line: bool, current_line: u32, lead: usize, state: State, base: usize, covered: bool) usize { const rec = d.cursor.rec; const base_y = rows.baseline(y); const code_ink = theme.color.region.code_; - const room = w - m.side; + // Right of the line's column, all of it moved by `widen`. + const u = at.moved(widen, 0); + const room = w - m.side - widen; if (row.outside) { // The function ends: a rule, and the next one's name. u.fill(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = theme.stroke.rule }, theme.color.rule); - _ = u.address(c.address, base_y, row.addr, .{ .ink = ui.mix(code_ink, theme.color.page, theme.metric.context.lead_alpha) }); + _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.mix(code_ink, theme.color.page, theme.metric.context.lead_alpha) }); u.text(.mono, size, c.mnemonic, base_y, row.mnemonic(), t.faint); const name = if (rec.strings.get(row.addr)) |n| n[0 .. std.mem.lastIndexOfScalar(u8, n, '+') orelse n.len] else ""; const x = if (name.len > 0) annotationX(operandsWidth(row, row.operands()), room, @as(f32, @floatFromInt(name.len)) * adv) else room + gap; @@ -225,7 +232,7 @@ pub const Disasm = struct { u.text(.mono, size, x, base_y, name, t.faint); return 0; } - _ = u.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(code_ink), .lead = lead }); + _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(code_ink), .lead = lead }); if (first_of_line) if (line) |l| { const num = u.print("{d}", .{l}); const now_line = l == current_line; |
