From 5922ee911b9a6604f60dc83be36ba9e6c9abac98 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 02:11:12 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/context.zig | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'anim/src/context.zig') diff --git a/anim/src/context.zig b/anim/src/context.zig index 6123d26..f551aa8 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -168,7 +168,7 @@ pub const Registers = struct { if (std.mem.eql(u8, carried, name) and value_was == made.args[k - 1]) break k; } else null else null; if (carrier) |k| if (crossing) |made| { - const framed = now.time - syscalls.Plan.of(made).registers - @as(f32, @floatFromInt(k - 1)) * time.flight.second; + const framed = now.time - syscalls.Plan.in(now, made).registers - @as(f32, @floatFromInt(k - 1)) * time.flight.second; marks.read = 0; marks.read_shows = @min(std.math.clamp(framed / time.read.in, 0, 1), now.reading(.cpu, 0)); // A descriptor says what it is open on: the `value` class `fd`. @@ -178,7 +178,7 @@ pub const Registers = struct { if (if (std.mem.eql(u8, name, "rax")) crossing else null) |made| { // rax: what was there, then the result, once the kernel's rows // have said it (the call's number went in at the wrapper). - const back = now.time - syscalls.Plan.of(made).struck; + const back = now.time - syscalls.Plan.in(now, made).struck; const result = back >= time.strike.in / 2.0; const value: u64 = if (result) value_now else value_was; if (back >= -time.strike.arm) { @@ -309,11 +309,15 @@ pub const Stack = struct { cursor: cursors.Cursor, stage: *const Stage, focus: bool = false, - /// On the map: the window from this many words above rsp, not scrolled. - above: u32 = 0, + /// On the map: the window from this many words above rsp, not scrolled + /// (negative: below it, the stack going on in another column's rest). + above: i32 = 0, + /// Which box of its stage it is in: the map's `more` holds the stack continued. + part: @import("stage.zig").Part = .stack, pub fn draw(k: *const Stack, f: *sk.Frame, placed: anim.Placed) void { - const box = k.stage.box(placed, .stack); + const box = k.stage.box(placed, k.part); + if (box.h < m.tag + m.row) return; const u = at(f, placed, box); const now = k.cursor.now(placed); const rec = k.cursor.rec; @@ -329,7 +333,7 @@ pub const Stack = struct { const hold = placed.value(k.stage.hold); const held = hold >= 0; const held_at: u64 = if (held) rec.register(@intFromFloat(hold), "rsp") -% 8 * @as(u64, @intFromFloat(placed.value(k.stage.hold_free))) else 0; - var window = if (held) [2]u64{ held_at, held_at } else if (k.above > 0) [2]u64{ is.rsp -% 8 * @as(u64, k.above), was.rsp -% 8 * @as(u64, k.above) } else [2]u64{ windowAt(now, is, slots, 0), windowAt(now, was, slots, 1) }; + var window = if (held) [2]u64{ held_at, held_at } else if (k.above != 0) [2]u64{ is.rsp -% @as(u64, @bitCast(@as(i64, 8 * k.above))), was.rsp -% @as(u64, @bitCast(@as(i64, 8 * k.above))) } else [2]u64{ windowAt(now, is, slots, 0), windowAt(now, was, slots, 1) }; // A window that goes farther than its own height (a continue to a // stop deeper or shallower than a call is) does not scroll: the old // rows fade out before memory strikes and the new ones in after, @@ -360,7 +364,7 @@ pub const Stack = struct { }; // The first word shown and the last. const range = if (from_rsp == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, from_rsp), offset(u, from_rsp + 8 * (@as(i64, @intCast(slots)) - 1)) }); - const body = u.panel(box.w, box.h, "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) }); + const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) }); const p = cursors.glide(now.moving(.memory, 0, time.move)); const moved = @as(f32, @floatFromInt(@as(i64, @bitCast(window[0] -% window[1])))) / 8; const slide: f32 = (if (jumped) 0 else moved * (1 - p)) + hold_scroll; @@ -402,7 +406,11 @@ pub const Stack = struct { return @as(f32, @floatFromInt(@as(i64, @bitCast(addr -% base)))) / 8; } }.at; - const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool }; + const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool, was: ?[]const u8 = null }; + // A frame whose name changes in place (on through a stub) crossfades over the 12 f before the advance. + const renamed = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1); + const calls_was = rec.stack(u.f.scratch, now.stops[1]); + const calls_is = rec.stack(u.f.scratch, now.stops[0]); var spans: [16]Span = undefined; var n_spans: usize = 0; for (chain, 0..) |frame, i| { @@ -414,6 +422,14 @@ pub const Stack = struct { const open = last >= @as(f32, @floatFromInt(slots)); const y1 = top + (@min(last, @as(f32, @floatFromInt(slots)) - 1) + 1) * m.row; spans[n_spans] = .{ .y0 = top + @max(first, 0) * m.row, .y1 = y1, .name = spanName(u, rec, open_calls, i, if (i < named.len) named[i].pc else frame.pc), .newest = i == 0, .open = open }; + if (now.walking() and !jumped and i < old_chain.len and old_chain[i].lo == frame.lo) { + const was_name = spanName(u, rec, calls_was, i, old_chain[i].pc); + const is_name = spanName(u, rec, calls_is, i, frame.pc); + if (!std.mem.eql(u8, was_name, is_name)) { + spans[n_spans].name = is_name; + spans[n_spans].was = was_name; + } + } n_spans += 1; } // rsp or rbp travelling alone keeps its place in the pin it leaves and @@ -455,7 +471,7 @@ pub const Stack = struct { marks.read_shows = now.reading(.memory, 0); } const below_rsp: i64 = @bitCast(addr -% rsp_shown); - map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); + if (k.part == .stack) map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); // `free`: above rsp, not yet reached: its address at 60%, its word faint. if (held and addr < rsp_shown) { rows.free(v, y, memory, addr, below_rsp, lead); @@ -478,7 +494,7 @@ pub const Stack = struct { const k_role = (addr -% roles_from) / 8; const what: zt.telescope.Role = if (k_role < roles.len) roles[k_role].role else .none; const role = roleName(u, what, (Recording.word(memory, addr, 8) catch null) orelse 1); - const hops = rows.slot(v, y, room_w, memory, addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local); + const hops = rows.slot(v, y, room_w, now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local); at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {}; pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, what == .saved and std.mem.eql(u8, what.saved, "rbp") }) catch {}; // Only a row on show is a place a tie can land. @@ -515,7 +531,10 @@ pub const Stack = struct { const x = if (lone != null) std.math.lerp(pinPlace(u, pins(u, now, is, was, was.named(name) orelse 0, travel).names, name), pinPlace(u, pins(u, now, is, was, is.named(name) orelse 0, travel).names, name), goes(now, was, is, name)) else theme.metric.slot.lane; u.pinRow(x, top + place * m.row, if (both) &.{ "rsp", "rbp" } else &.{name}, theme.color.region.stack); } - for (spans[0..n_spans]) |sp| rows.span(v, box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open); + for (spans[0..n_spans]) |sp| if (sp.was) |was_name| { + rows.span(v.faded(1 - renamed), box.w, sp.y0, sp.y1, was_name, sp.newest, sp.open); + rows.span(v.faded(renamed), box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open); + } else rows.span(v, box.w, sp.y0, sp.y1, sp.name, sp.newest, sp.open); veiled(u, box, now.veil); } @@ -527,7 +546,7 @@ pub const Stack = struct { return switch (role) { .none, .return_address => .{ .name = "" }, .saved => |r| .{ .name = u.print("saved {s}", .{r}) }, - .local => |l| .{ .name = if (l.offset > 0) u.print("{s}+{x}", .{ l.name, @as(u32, @intCast(l.offset)) }) else l.name, .local = true }, + .local => |l| .{ .name = if (l.offset > 0) u.print("{s}+{x}", .{ l.name, @as(u32, @intCast(l.offset)) }) else if (l.offset == -4 and l.size == 4) u.print("{s}, high half", .{l.name}) else if (l.offset < 0) u.print("{s}, from byte {d}", .{ l.name, -l.offset }) else l.name, .local = true }, .argc => .{ .name = "argc" }, .argv => |i| .{ .name = if (word == 0) "argv end" else u.print("argv[{d}]", .{i}) }, .envp => |i| .{ .name = if (word == 0) "envp end" else u.print("envp[{d}]", .{i}) }, @@ -663,6 +682,7 @@ pub const Backtrace = struct { const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1); const room = rowsOf(box); const total = chains[if (slide >= 0.5) 1 else 0].len; + map.measure(.backtrace, @max(chains[0].len, chains[1].len)); const body = u.panel(box.w, box.h, "backtrace", .{ .focus = b.focus, .note = newestAtBottom(u, total, room) }); clipBody(u, box); defer u.unclip(); -- cgit v1.3