diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-12 11:32:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:19:32 -0300 |
| commit | eab50d1c040774351f332a1568fa332c377860bd (patch) | |
| tree | 0e727f9bf323e49aa6a2f55bb4fabd166aa9a492 /anim/src/hexdump.zig | |
| parent | 38971edd9b49a802e6e726fb51d162df1bf58b83 (diff) | |
| download | computeranim-eab50d1c040774351f332a1568fa332c377860bd.tar.gz computeranim-eab50d1c040774351f332a1568fa332c377860bd.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src/hexdump.zig')
| -rw-r--r-- | anim/src/hexdump.zig | 14 |
1 files changed, 7 insertions, 7 deletions
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`), |
