diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-11 00:06:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-11 01:16:48 -0300 |
| commit | c3d9f7ba5effd615374b1359ad98ecf801559f83 (patch) | |
| tree | 07f85932abc1df23c722bcd1bd1b3b65bca28f2e /anim/src/loupe.zig | |
| parent | c94ade9e77a811d3ff75ffc2889a65375262ab1f (diff) | |
| download | computeranim-c3d9f7ba5effd615374b1359ad98ecf801559f83.tar.gz computeranim-c3d9f7ba5effd615374b1359ad98ecf801559f83.zip | |
canim: a call followed down to the kernel; rows that say what they do; the heap from the inside
From the user. The disassembly can descend: the syscalls scene is glibc's
hello by instruction, and open is followed from main through its PLT
stub, whose jmp reads the GOT, into libc's wrapper to the syscall row,
which crosses to the kernel's window under it, and back up. The band
keeps the calls so far as strace writes them. Operands lose their size
words and show a width as byte cells only where nothing else says it. A
compare shows its values and the flags it leaves, a jump the flags it
reads, lea its result, an indirect jump its target and the slot it read,
a call that has run its C form. The backtrace has its newest frame at
the bottom. A new scene shows glibc 2.44's heap from blocks that exist:
chunks read by fields (a size with its bits, a protected pointer), the
free list as arcs, the tcache in a loupe, the program's list over
malloc's own.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src/loupe.zig')
| -rw-r--r-- | anim/src/loupe.zig | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig index 99dae71..623e966 100644 --- a/anim/src/loupe.zig +++ b/anim/src/loupe.zig @@ -40,7 +40,14 @@ pub const Loupe = struct { stage: *const Stage, /// What it opens from: a register, by name; or a pointer field (its /// address) of the loupe it hangs under. - from: union(enum) { register: []const u8, field: struct { loupe: *const Loupe, at: u64 } }, + /// Or the bytes of a dump's row (`at`, a field the view publishes as a + /// `dump_run`), opening on `fields` (the region it reads them as): a + /// struct the debug info does not type (malloc's tcache), named `name`. + from: union(enum) { + register: []const u8, + field: struct { loupe: *const Loupe, at: u64 }, + row: struct { at: u64, name: []const u8, note: []const u8, fields: hexdump.Fields }, + }, /// 0 to 1 as it opens (`time.loupe.open`) and as it closes (`close`). opening: anim.Value = undefined, closing: anim.Value = undefined, @@ -85,6 +92,14 @@ pub const Loupe = struct { target = (Recording.word(moment, field.at, 8) catch null) orelse return null; right = parent.box.x + 120; }, + .row => |row| { + const px = ties.find(.{ .dump_run = row.at }) orelse return null; + const back = u.at.xf.invert(); + const a = back.apply(.{ px[0], px[1] }); + const b = back.apply(.{ px[2], px[3] }); + pointer = .{ .x = a[0], .y = a[1], .w = b[0] - a[0], .h = b[1] - a[1] }; + target = row.fields.base; + }, } if (target == 0) return null; // shortcut: it keeps to the stage and does not yet move past the current marks or a changed row; the scene picks a pointer whose loupe covers neither. @@ -135,6 +150,10 @@ pub const Loupe = struct { x += v.width(.mono, size, name) + 6; }, .field => |field| x = v.address(x, base, field.at, .{ .ink = ui.rgb(rows.ink(rows.regionOf(moment, field.at))) }) + 6, + .row => |row| { + v.text(.mono, size, x, base, row.name, t.dim); + x += v.width(.mono, size, row.name) + 6; + }, } x = v.arrow(x, m.tag / 2, .points) + 8; _ = v.address(x, base, p.target, .{ .ink = ui.rgb(p.ink) }); @@ -146,16 +165,17 @@ pub const Loupe = struct { .rodata => "read-only", .none => "", }; - const note = if (object) |o| v.print("{s} \u{00b7} {s}, {d} bytes", .{ region, if (o.name.len > 0) o.name else "a struct", o.type.record.size }) else region; + const note = if (l.from == .row) l.from.row.note else if (object) |o| v.print("{s} \u{00b7} {s}, {d} bytes", .{ region, if (o.name.len > 0) o.name else "a struct", o.type.record.size }) else region; v.text(.sans, theme.size.sans.micro, b.w - 10 - v.width(.sans, theme.size.sans.micro, note), base, note, t.dim); // Its rows, typed where the recording types them, its own pointers as arcs at full ink. const top = m.tag + m.pad; v.clip(.{ .x = 0, .y = m.tag, .w = b.w, .h = b.h - m.tag }); - hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); + // By the scene's fields: the rows that hold them, the rest `more`. + if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, l.from.row.fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); v.unclip(); // Its target, framed bright: each field of the struct, or the word. const framed = std.math.clamp((since - time.stem - time.frame) / time.frame, 0, 1); - if (framed > 0) { + if (framed > 0 and l.from != .row) { const row_y = top + @as(f32, @floatFromInt((p.target - p.first) / 16)) * m.row; const shift = rows.addressRoom(p.first + 16 * (k.rows - 1)); const w = v.faded(framed); |
