From eab50d1c040774351f332a1568fa332c377860bd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 12 Nov 2026 11:32:59 -0300 Subject: canim: the introduction as one video, with a chapter on registers From the user. One scene, intro, in four chapters: memory, registers, the stack, code and meaning (210 s). The registers chapter builds the panel before the stack needs it: sixteen rows with their chains, rip pinned on the code band and rsp and rbp on the stack's, rdi opened into its parts as mov edi changes one byte, a call to malloc stepped over with its result in rax, the registers a scene never changes folded. The chapters join at seams that say their title and keep it as the clock's label; one recording (from push(9), no agent, the heap from --heap) and one clock. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/hexdump.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'anim/src/hexdump.zig') diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig index d1c363c..3ef1ac9 100644 --- a/anim/src/hexdump.zig +++ b/anim/src/hexdump.zig @@ -30,7 +30,7 @@ pub const Kind = enum { number, pointer, loose, unread }; /// a field of a struct the program's pointers reach (by its type), other /// allocated bytes, `loose` (the allocator's own between allocations), or /// never observed. -pub fn kindOf(things: []const objects.Object, moment: Recording.Moment, addr: u64) struct { Kind, ?Recording.types.Type } { +pub fn kindOf(rec: *const Recording, things: []const objects.Object, moment: Recording.Moment, addr: u64) struct { Kind, ?Recording.types.Type } { for (things) |o| { if (!o.holds(addr)) continue; for (o.type.record.fields) |field| if (o.addr + field.offset == addr) return .{ if (field.type == .pointer) .pointer else .number, field.type }; @@ -40,7 +40,7 @@ pub fn kindOf(things: []const objects.Object, moment: Recording.Moment, addr: u6 var known: [8]bool = undefined; moment.read(addr, &bytes, &known) catch return .{ .unread, null }; if (std.mem.indexOfScalar(bool, &known, true) == null) return .{ .unread, null }; - return .{ if ((moment.allocation(addr) catch null) != null) .number else .loose, null }; + return .{ if (rec.allocated(moment, addr)) .number else .loose, null }; } /// The rows of a region (`lo .. hi`, sixteen-aligned) a dump of `count` @@ -207,7 +207,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u if (of.array) |arr| if (here < arr.addr and arr.addr < here + run.len) { run.len = @intCast(arr.addr - here); }; - const word, kind = kindOf(of.things, moment, here); + const word, kind = kindOf(now.rec, of.things, moment, here); run.kind = switch (word) { .number => .number, .pointer => .pointer, @@ -240,7 +240,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u const end = readingIn(v, ry, shift, moment, &values, &known, readings[0..n], room); // The size word of the chunk after: malloc's, a note after the reading. const last = runs[n - 1]; - if (last.kind == .loose and last.first == 8 and last.len == 8 and std.mem.indexOfScalar(bool, known[8..], false) == null and chunkAfter(moment, addr + 8)) { + if (last.kind == .loose and last.first == 8 and last.len == 8 and std.mem.indexOfScalar(bool, known[8..], false) == null and chunkAfter(now.rec, moment, addr + 8)) { const size = std.mem.readInt(u64, values[8..16], .little) & ~@as(u64, 7); v.text(.sans, theme.size.sans.micro, end, rows.baseline(ry) - 1, v.print("malloc's: a chunk of {d}", .{size}), t.faint); } @@ -419,9 +419,9 @@ fn aim(arcs: *rows.Arcs, now: cursors.Now, field: u64, target: u64, from: f32, s /// Whether an allocation the recording has begins just after the word at /// `word` (the chunk's size word, glibc's and musl's alike): only there are /// bytes between allocations the allocator's own, to be read as its. -fn chunkAfter(moment: Recording.Moment, word: u64) bool { - const a = (moment.allocation(word + 8) catch return false) orelse return false; - return a.ptr == word + 8; +fn chunkAfter(rec: *const Recording, moment: Recording.Moment, word: u64) bool { + if ((moment.allocation(word + 8) catch null)) |a| return a.ptr == word + 8; + return rec.allocated(moment, word + 8) and !rec.allocated(moment, word); } /// What a field of a region reads as: a number (little-endian, or `big`), -- cgit v1.3