summaryrefslogtreecommitdiff
path: root/anim/src/hexdump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 02:11:12 -0300
committerGabriel Schneider <[email protected]>2026-11-11 04:20:25 -0300
commit5922ee911b9a6604f60dc83be36ba9e6c9abac98 (patch)
tree310b983f5205709e5db173f9f1bc8e8d499d24fe /anim/src/hexdump.zig
parent64e64c74be6a3e46abeae8a30dd42efff91aaf91 (diff)
downloadcomputeranim-5922ee911b9a6604f60dc83be36ba9e6c9abac98.tar.gz
computeranim-5922ee911b9a6604f60dc83be36ba9e6c9abac98.zip
canim: what the second review found, fixed
A system call stepped over plays in order: the registers set, the crossing from the call row with the kernel's window under it, the stores after rax. A strike covers the bytes that changed. The band's view changes with the argument framing. In the descent a callee sits under its caller's return row, and rows fade before others glide. The heap scene follows the storyboard's nine captions: pushes at a run without marks, each free and the malloc that takes the head back walked, the tcache's loupe over the stack and closed with each advance, a chunk in neither list drawn, the freed node travelling to malloc's row. In the dive the map falls into the corner and becomes the minimap; on the map boxes are as long as their rows. A narrow read is shown at its width. The chart checks captions and one-frame changes. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src/hexdump.zig')
-rw-r--r--anim/src/hexdump.zig66
1 files changed, 55 insertions, 11 deletions
diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig
index cbd8f7f..3abd052 100644
--- a/anim/src/hexdump.zig
+++ b/anim/src/hexdump.zig
@@ -155,16 +155,18 @@ pub fn draw(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: usize
}
pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: usize, of: Of, loud: bool, rule: [2]f32) void {
- const v = u.moved(x, 0);
+ const dump = u.moved(x, 0);
var arcs: rows.Arcs = .{};
var at_rows: [64]RowAt = undefined;
for (at_rows[0..@min(count, at_rows.len)], 0..) |*r, i| r.* = .{ .addr = first + 16 * i, .y = y + @as(f32, @floatFromInt(i)) * m.row };
const shown_rows = at_rows[0..@min(count, at_rows.len)];
- const moment = now.shown(.memory);
const lead = ui.shared(&.{ first, first + 16 * @as(u64, count -| 1) });
// Room for the addresses, once for the dump: by its widest.
const shift = rows.addressRoom(first + 16 * @as(u64, count -| 1));
- for (0..count) |i| {
+ // At a run the values crossfade (8 f), unmarked: the rows twice, the arcs once.
+ const passes = crossfade(now);
+ for (passes.moments[0..passes.n], passes.shows[0..passes.n], 0..) |moment, shows, pass| for (0..count) |i| {
+ const v = dump.faded(shows);
const addr = first + 16 * i;
const ry = y + @as(f32, @floatFromInt(i)) * m.row;
var values: [16]u8 = undefined;
@@ -203,6 +205,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
};
}
run.heat = now.written(here, run.len, .memory, 0);
+ run.changed = now.changedBytes(here, run.len);
if (now.wasRead(here, run.len) and now.writeAge(here, run.len) != 0) run.read = now.reading(.memory, 0);
if (run.kind == .number or run.kind == .pointer) ties.anchor(v, .{ .dump_run = here }, .{ .x = shift + rows.byteX(run.first) - 4, .y = ry, .w = rows.byteX(run.first + run.len - 1) + 28 - rows.byteX(run.first) + 4, .h = m.row });
readings[n] = .{ .at = run.first, .len = run.len, .reads = switch (run.kind) {
@@ -216,7 +219,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
}
@import("map.zig").row(.view, addr, v, .{ .x = 0, .y = ry, .w = theme.layout.state.w, .h = m.row });
rows.bytesAt(v, ry, addr, &values, &known, runs[0..n], of.region, lead, holds_drawn, moment, shift);
- for (runs[0..n]) |run| if (run.kind == .pointer and run.len == 8) pointerArcs(&arcs, now, addr + run.first, ry, shown_rows, 16, rule, loud, false);
+ if (pass + 1 == passes.n) for (runs[0..n]) |run| if (run.kind == .pointer and run.len == 8) pointerArcs(&arcs, now, addr + run.first, ry, shown_rows, 16, rule, loud, false);
const end = reading(v, ry, shift, moment, &values, &known, readings[0..n]);
// The size word of the chunk after: malloc's, a note after the reading.
const last = runs[n - 1];
@@ -224,8 +227,19 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
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);
}
+ };
+ arcs.draw(dump, theme.metric.arc.lanes.len);
+}
+
+/// The memory a dump draws now, and how much each shows: at a run, what
+/// the step changed crossfades over 8 f, unmarked; otherwise memory's state.
+const Passes = struct { moments: [2]Recording.Moment, shows: [2]f32, n: usize };
+fn crossfade(now: cursors.Now) Passes {
+ if (now.plan.gait == .run and !now.resting()) {
+ const q = std.math.clamp(now.since(.memory, 0) / (8.0 / 60.0), 0, 1);
+ if (q > 0 and q < 1) return .{ .moments = .{ now.before(), now.moment() }, .shows = .{ 1 - q, q }, .n = 2 };
}
- arcs.draw(v, theme.metric.arc.lanes.len);
+ return .{ .moments = .{ now.shown(.memory), undefined }, .shows = .{ 1, 0 }, .n = 1 };
}
/// A row of a panel: its first byte's address and its top.
@@ -270,6 +284,8 @@ fn aim(arcs: *rows.Arcs, now: cursors.Now, field: u64, target: u64, from: f32, s
const moment = now.moment();
var arc = state;
arc.from = from;
+ // A run draws no arcs: they fade in, settled, as it ends.
+ arc.shows *= 1 - now.hurried;
arc.ink = rows.ink(rows.regionOf(moment, target));
for (shown) |r| if (target >= r.addr and target < r.addr + size) {
if (r.y == from) return;
@@ -342,7 +358,14 @@ pub const Fields = struct {
marks: []const f32 = &.{},
/// Bytes known from elsewhere than the moment's memory (what a syscall
/// was given, as the kernel took them), and how much they show (0 to 1).
- given: ?struct { addr: u64, bytes: []const u8, shows: f32 } = null,
+ given: ?struct {
+ addr: u64,
+ bytes: []const u8,
+ shows: f32,
+ /// What a read fills: seconds since the kernel's work reached the
+ /// first byte; they land a byte every 2 f from the low address (null: all at once).
+ since: ?f32 = null,
+ } = null,
/// How much a frame round every field shows: the kernel reading them.
read: f32 = 0,
/// The part of the region the recording read at the stop shown (null:
@@ -353,6 +376,9 @@ pub const Fields = struct {
/// How many of the newest steps it has been on screen through: only
/// their changes are marked.
watched: usize = std.math.maxInt(usize),
+ /// Seconds since its strikes began, a field 6 f after the one before
+ /// (a loupe's, once it has opened); null: memory's slot.
+ struck: ?f32 = null,
};
/// The region's rows in view `v`, from `y`, sixteen bytes a row from its
@@ -392,7 +418,8 @@ pub fn fielded(v: View, now: cursors.Now, y: f32, of: Fields) void {
ry += m.row;
}
last = r;
- fieldRow(u, now, ry, of.base + 16 * r, moment, of, lead, shift);
+ const passes = crossfade(now);
+ for (passes.moments[0..passes.n], passes.shows[0..passes.n]) |mm, shows| fieldRow(u.faded(shows), now, ry, of.base + 16 * r, if (passes.n == 2) mm else moment, of, lead, shift);
at_rows.append(u.f.scratch, .{ .addr = of.base + 16 * r, .y = ry }) catch {};
ry += m.row;
}
@@ -479,6 +506,7 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
if (of.given) |g| for (0..16) |i| {
const a = addr + i;
if (a < g.addr or a >= g.addr + g.bytes.len) continue;
+ if (g.since) |since| if (since < @as(f32, @floatFromInt(a - g.addr)) * @import("syscalls.zig").Plan.byte) continue;
given_values[i] = g.bytes[a - g.addr];
given_known[i] = true;
gives = true;
@@ -491,8 +519,12 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
var at: u8 = 0;
while (at < 16 and addr + at < of.base + of.len) {
const here = addr + at;
- const field = for (of.fields) |field| {
- if (of.base + field.at <= here and here < of.base + field.at + field.len) break field;
+ var field_k: usize = 0;
+ const field = for (of.fields, 0..) |field, fk| {
+ if (of.base + field.at <= here and here < of.base + field.at + field.len) {
+ field_k = fk;
+ break field;
+ }
} else null;
var run: rows.Run = .{ .first = at, .len = 1, .kind = .loose };
if (field) |fl| {
@@ -503,6 +535,10 @@ fn fieldRow(u: ui.Ui, now: cursors.Now, y: f32, addr: u64, moment: Recording.Mom
.text => .text,
};
run.heat = now.writtenWatched(here, run.len, .memory, 0, 0, of.watched);
+ run.changed = now.changedBytes(here, run.len);
+ if (of.struck) |since| run.heat = now.writtenAt(here, run.len, since - @as(f32, @floatFromInt(field_k)) * cursors.write_apart);
+ // What the kernel fills lands a byte every 2 f.
+ if (@import("syscalls.zig").filledAt(now, here) != null) run.apart = 2;
var framed: f32 = 0;
if (fl.mark) |k| if (k < of.marks.len) {
framed = of.marks[k];
@@ -556,8 +592,16 @@ pub fn reading(u: ui.Ui, y: f32, shift: f32, moment: Recording.Moment, values: *
const len: usize = @intCast(if (fl.type) |ty| @min(fl.len, ty.size() orelse fl.len) else fl.len);
if (len == 0 or std.mem.indexOfScalar(bool, known[first..][0..len], false) != null) continue;
defer if (fl.note.len > 0) {
- u.text(.sans, theme.size.sans.micro, x, base - 1, fl.note, t.faint);
- x += u.width(.sans, theme.size.sans.micro, fl.note) + adv;
+ // Cut where the panel ends, at a word, with `…`; never mid-word without it.
+ var note = fl.note;
+ while (note.len > 0 and x + u.width(.sans, theme.size.sans.micro, if (note.len == fl.note.len) note else u.print("{s}\u{2026}", .{note})) > room) {
+ note = std.mem.trimEnd(u8, note[0 .. std.mem.lastIndexOfScalar(u8, note, ' ') orelse 0], " \u{00b7}");
+ }
+ if (note.len > 0) {
+ const said = if (note.len == fl.note.len) note else u.print("{s}\u{2026}", .{note});
+ u.text(.sans, theme.size.sans.micro, x, base - 1, said, t.faint);
+ x += u.width(.sans, theme.size.sans.micro, said) + adv;
+ }
};
if (fl.reads == .bytes) continue;
const bytes = values[first..][0..len];