From e63b0624f57472d40af32a006c32cc47d403b822 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 18:06:30 -0300 Subject: canim: what the review found; the band as two panels; list and sort by instruction The first videos were reviewed frame by frame and the catalogue changed with them. A lens is a drawing over the program column and its view over the state column, so the stack keeps six slots, its window on the whole frame. Operands are whole. list and sort are recorded by instruction from main (record --from), so their registers strike, links reach nodes and cells, rows that ran are marked and jumps are drawn. A call's node is a projection of its return address; pins travel and keep their side; a mark covers the bytes that changed, at the element's width; a syscall's result is stored after the kernel returns it and every panel is of one moment; fast passes are veiled; the clock stands still during a step; captions get their reading time and a scene's first step comes by four seconds. Co-Authored-By: Claude Fable 5.2 --- anim/build.zig | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'anim/build.zig') diff --git a/anim/build.zig b/anim/build.zig index 2f50e4a..5646f1a 100644 --- a/anim/build.zig +++ b/anim/build.zig @@ -25,7 +25,11 @@ pub fn build(b: *std.Build) void { const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize }); const zt = b.dependency("ztrace", .{ .target = target, .optimize = optimize }); const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .@"tree-sitter" = .minimal }); - const ztrace = zt.artifact("ztrace"); + // The tools a recording is made with, always optimized: a step through + // the agent's or the runtime's code is a moment of the recording, and + // a slow tracer stretches the clock's retry loops it steps through. + const tools = b.dependency("ztrace", .{ .target = target, .optimize = .ReleaseFast }); + const ztrace = tools.artifact("ztrace"); const imports: []const std.Build.Module.Import = &.{ .{ .name = "anim", .module = sb.modules.anim }, @@ -44,8 +48,8 @@ pub fn build(b: *std.Build) void { var table: std.ArrayList(u8) = .empty; // The pass and the agent to preload, as ztrace's own build makes and names them. - const plugin = zt.namedLazyPath("ztrace-pass"); - const agent = zt.namedLazyPath("ztrace-agent"); + const plugin = tools.namedLazyPath("ztrace-pass"); + const agent = tools.namedLazyPath("ztrace-agent"); const musl = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }); const Recording = struct { @@ -56,10 +60,15 @@ pub fn build(b: *std.Build) void { /// they point at, and the instructions at the pc. by: []const u8, /// Compiled by `ztrace cc` to tell these of itself as well (its - /// calls, its variables with their types, every store and load); - /// null for the program as the compiler alone makes it (static, - /// unoptimised), whose instructions are then all its own. + /// variables with their types), for the functions and globals + /// `only` names: everything else is the compiler's alone. Null for + /// the program as the compiler alone makes it (static, unoptimised), + /// whose instructions are then all its own. instr: ?[]const u8 = null, + only: []const u8 = "*", + /// Run through to here before the first stop: the loader, the C + /// library's start, and what the scene does not show. + from: ?[]const u8 = null, /// With the agent preloaded: `malloc` and `free` too. alloc: bool = false, /// A file of tools/ it reads, by its bare name. @@ -68,20 +77,27 @@ pub fn build(b: *std.Build) void { for ([_]Recording{ .{ .name = "steps", .source = "fib.c", .by = "insn" }, .{ .name = "hello", .source = "hello.c", .by = "line", .reads = "note" }, - .{ .name = "sort", .source = "sort.c", .by = "line", .instr = "calls,vars,stores,loads" }, - .{ .name = "list", .source = "list.c", .by = "line", .instr = "calls,vars,stores,loads", .alloc = true }, + // By instruction, as `steps` is: the registers are the program's + // own, so they strike and link. Only the variables the scenes name + // are told by the instrumentation (each a call into its runtime, + // stepped like any other); `list` starts at `reverse`, its pushes + // (the agent's and the runtime's first calls) run through. + .{ .name = "sort", .source = "sort.c", .by = "insn", .instr = "vars", .only = "sort,a", .from = "main" }, + .{ .name = "list", .source = "list.c", .by = "insn", .instr = "vars", .only = "push,reverse,head", .from = "reverse", .alloc = true }, }) |r| { const source = b.path(b.fmt("tools/{s}", .{r.source})); var program: std.Build.LazyPath = undefined; if (r.instr) |instr| { const cc = b.addRunArtifact(ztrace); - cc.addArgs(&.{ "cc", "--instr", instr, "--plugin" }); + cc.addArgs(&.{ "cc", "--instr", instr, "--only", r.only, "--plugin" }); cc.addFileArg(plugin); cc.addArg("--rt"); - cc.addArtifactArg(zt.artifact("ztrace-rt")); + cc.addArtifactArg(tools.artifact("ztrace-rt")); // Not position-independent: code and heap at short addresses, as // the design's columns are drawn for (seven digits, not twelve). - cc.addArgs(&.{ "--", "clang", "-O0", "-g", "-no-pie" }); + // Bound at load and with no canary: no resolver and no check is + // stepped through that the source does not say. + cc.addArgs(&.{ "--", "clang", "-O0", "-g", "-no-pie", "-fno-stack-protector", "-Wl,-z,now" }); cc.addFileArg(source); cc.addArg("-o"); program = cc.addOutputFileArg(r.name); @@ -99,6 +115,7 @@ pub fn build(b: *std.Build) void { const run = b.addSystemCommand(&.{ "env", "-i", "setarch", "-R" }); run.addArtifactArg(ztrace); run.addArgs(&.{ "record", "--by", r.by, "--stack", "256", "-s", "64" }); + if (r.from) |place| run.addArgs(&.{ "--from", place }); // What an instrumented program tells of itself comes through a ring. if (r.instr != null) run.addArg("--ring"); if (r.alloc) { @@ -205,7 +222,7 @@ pub fn build(b: *std.Build) void { \\mkdir -p out \\"$0" --state "$1" --export - --size "$2" --fps 60 | \\ ffmpeg -loglevel error -y -f rawvideo -pix_fmt rgba -s "$2" -r 60 -i - \ - \\ -c:v libx264 -crf 14 -preset slow -pix_fmt yuv420p \ + \\ -c:v libx264 -crf 14 -preset slow -g 600 -pix_fmt yuv420p \ \\ -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range tv "$3" }); video.addArtifactArg(exe); -- cgit v1.3