summaryrefslogtreecommitdiff
path: root/anim/src/disasm.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/disasm.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/disasm.zig')
-rw-r--r--anim/src/disasm.zig29
1 files changed, 25 insertions, 4 deletions
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig
index 0b6f931..e871cc6 100644
--- a/anim/src/disasm.zig
+++ b/anim/src/disasm.zig
@@ -81,6 +81,8 @@ pub const Disasm = struct {
const going = now.advancing();
const from = listing(u, rec, now.marks[0], room, above);
const to = listing(u, rec, now.marks[1], room, above);
+ // On the map its box is as long as the instructions the recording has round the pc.
+ if (ui.mapping) map.measure(.disasm, listing(u, rec, now.marks[1], theme.map.disasm_rows, (theme.map.disasm_rows - 1) / 2).rows.len);
const pc = [2]u64{ rec.register(now.marks[0], "rip"), rec.register(now.marks[1], "rip") };
const name = rec.strings.get(pc[if (going >= 0.5) 1 else 0]) orelse "";
@@ -274,7 +276,8 @@ pub const Disasm = struct {
var x = room + gap;
if (need.drawn) x = annotationX(operandsWidth(u, row, ops, stub), room, need.end - c.annotation);
operands(u, row, ops, stub, base_y, (if (covered) @min(x, c.annotation) else x) - gap - c.operands, if (pad) t.faint else theme.color.code.plain);
- return if (need.drawn) d.annotation(u, now, row, y, x, room, state, base, window, echo).hangs else 0;
+ // Its annotation column holds the arguments of a call above: its own gives way.
+ return if (need.drawn and !covered) d.annotation(u, now, row, y, x, room, state, base, window, echo).hangs else 0;
}
const Note = struct { drawn: bool = false, end: f32 = 0, hangs: usize = 0 };
@@ -427,6 +430,8 @@ pub const Disasm = struct {
marks.changed_heat = now.written(touch.addr, touch.len, .memory, 0);
}
};
+ // Narrower than a word, it is read at its width.
+ if (touch.len < 8) return .{ .drawn = true, .end = rows.narrow(u, x, y, shown, touch.addr, touch.len, room, marks).end };
return .{ .drawn = true, .end = rows.chain(u, x, y, shown, touch.addr, room, marks).end };
}
// Only a register: a small `reg` of what it left there.
@@ -481,9 +486,7 @@ const Say = struct {
/// its name), three when none says. How many rows they take.
fn arguments(a: Say, row: Insn, to: u64, moment: u64) usize {
const name = a.functionName(to, moment);
- const count = @min(row.params orelse for (a.rec.functions) |fun| {
- if (std.mem.eql(u8, fun.name, name)) break fun.params;
- } else argumentCount(a.rec, row, name) orelse 3, 6);
+ const count = a.argumentRows(row, to, moment);
const shown = a.rec.moment(moment);
// Flags by name, where a system call of its name says which argument they are.
const nr: ?u64 = if (std.meta.stringToEnum(std.os.linux.SYS, name)) |sys| @intFromEnum(sys) else null;
@@ -499,6 +502,14 @@ const Say = struct {
return count;
}
+ /// How many argument rows hang under a call to `to`.
+ fn argumentRows(a: Say, row: Insn, to: u64, moment: u64) usize {
+ const name = a.functionName(to, moment);
+ return @min(row.params orelse for (a.rec.functions) |fun| {
+ if (std.mem.eql(u8, fun.name, name)) break fun.params;
+ } else argumentCount(a.rec, row, name) orelse 3, 6);
+ }
+
/// The call at `row` (to `to`, made at `moment`) in C's form, its
/// arguments as the source wrote that many and as the system call of its
/// name types them; with ` = result` when it has returned.
@@ -601,6 +612,16 @@ const Say = struct {
}
};
+/// How many rows of arguments hang under `row` while it is current at
+/// `moment`: a direct call's, a `syscall`'s; 0 for anything else.
+pub fn hanging(u: ui.Ui, rec: *const Recording, row: Insn, moment: u64) usize {
+ const a: Say = .{ .u = u, .rec = rec, .y = 0, .x = 0, .room = 0 };
+ if (std.mem.eql(u8, row.mnemonic(), "syscall")) return @min(zt.syscalls.signature(rec.register(moment, "rax")).len, 6);
+ const b = rec.insn_branches[moment] orelse return 0;
+ if (b.kind != .call or target(row) == null) return 0;
+ return a.argumentRows(row, b.to, moment);
+}
+
/// A call's argument registers, in order; a system call's.
const carriers = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9" };
const carriers_sys = [_][]const u8{ "rdi", "rsi", "rdx", "r10", "r8", "r9" };