summaryrefslogtreecommitdiff
path: root/anim/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/build.zig')
-rw-r--r--anim/build.zig13
1 files changed, 11 insertions, 2 deletions
diff --git a/anim/build.zig b/anim/build.zig
index 9c7d63e..63d962e 100644
--- a/anim/build.zig
+++ b/anim/build.zig
@@ -107,6 +107,10 @@ pub fn build(b: *std.Build) void {
glibc: bool = false,
/// Stops after `from` before the recording ends: main's return, not the exit's.
steps: ?[]const u8 = null,
+ /// Ends the recording at the first stop here (`--until`).
+ until: ?[]const u8 = null,
+ /// The name it runs by (argv[0], its mapping), where not the recording's.
+ program: ?[]const u8 = null,
/// Also glibc's heap at every stop (`--heap`), and memory watched (`-w`).
heap: bool = false,
watch: []const []const u8 = &.{},
@@ -130,6 +134,9 @@ pub fn build(b: *std.Build) void {
// (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 },
+ // The introduction's: the same program from main's call of reverse
+ // (its push of the way back, reverse's prologue) to line 22, past the load.
+ .{ .name = "intro", .source = "list.c", .by = "insn", .instr = "vars", .only = "push,reverse,head", .from = "list.c:41", .until = "list.c:22", .alloc = true, .program = "list" },
// `hello` again, built by Zig against musl, static: no PLT; musl's
// own source (`open.c`, `syscall_cp`) on the way down to the kernel.
.{ .name = "musl", .source = "hello.c", .by = "insn", .from = "main", .steps = "166", .reads = "note" },
@@ -164,7 +171,8 @@ pub fn build(b: *std.Build) void {
// environment: the strings on its stack (its name, its variables)
// end up on screen, and should say nothing of the machine it was made on.
const where = b.addWriteFiles();
- _ = where.addCopyFile(program, r.name);
+ const runs_as = r.program orelse r.name;
+ _ = where.addCopyFile(program, runs_as);
if (r.reads) |name| _ = where.addCopyFile(b.path(b.fmt("tools/{s}", .{name})), name);
// A dynamic program's libraries are named by their debug info in
// the debuginfod cache: the recorder finds it by DEBUGINFOD_CACHE_PATH,
@@ -196,6 +204,7 @@ pub fn build(b: *std.Build) void {
run.addArgs(&.{ "--by", r.by, "--stack", r.stack, "--around", "256", "--disasm", "69", "-s", "64" });
if (r.from) |place| run.addArgs(&.{ "--from", place });
if (r.steps) |n| run.addArgs(&.{ "--steps", n });
+ if (r.until) |place| run.addArgs(&.{ "--until", place });
if (r.heap) run.addArg("--heap");
for (r.watch) |what| run.addArgs(&.{ "-w", what });
// What an instrumented program tells of itself comes through a ring.
@@ -206,7 +215,7 @@ pub fn build(b: *std.Build) void {
}
run.addArg("-o");
const trace = run.addOutputFileArg(b.fmt("{s}.ztrace", .{r.name}));
- run.addArgs(&.{ "--", b.fmt("./{s}", .{r.name}) });
+ run.addArgs(&.{ "--", b.fmt("./{s}", .{runs_as}) });
run.setCwd(where.getDirectory());
run.expectExitCode(0);
run.expectStdErrMatch("exit 0");