From a7504c6bb2ec9e906891e42bc3df28b276e67143 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 12:09:27 -0300 Subject: the backends together: a ring under the debugger, strings that do not collide ztrace record and dbg take --ring, --preload and --alloc: the target gets the ring ztrace run gives it, and the debugger drains it while the target runs (polling for the stop, so a full ring cannot hold both) and before it reports a stop. A program compiled by ztrace cc, with the agent preloaded, stopped at breakpoints, is one recording in order; test-together checks it. Recording such a program showed the debugger's file names and the pass's strings both counted from 1: event.stringId (a hash, top bit set) is now what every producer without a table of its own uses. --- build.zig | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 7569650..e7dd08a 100644 --- a/build.zig +++ b/build.zig @@ -91,7 +91,24 @@ pub fn build(b: *std.Build) void { // Each area adds its own artifacts, targets and test step. @import("build/debugger.zig").add(ctx); - @import("build/agent.zig").add(ctx); - @import("build/llvm.zig").add(ctx); + const agent = @import("build/agent.zig").add(ctx); + const instrumented_list = @import("build/llvm.zig").add(ctx); + + // The backends at once: a program compiled by `ztrace cc`, the agent + // preloaded into it, the debugger stopping it at breakpoints. One + // recording holds the stops, the allocations and the program's own calls. + const together = b.addRunArtifact(exe); + together.addArgs(&.{ "record", "--by", "break", "-b", "push", "-b", "reverse", "--alloc", "--preload" }); + together.addArtifactArg(agent); + together.addArg("-o"); + const recording = together.addOutputFileArg("together.ztrace"); + together.addArg("--"); + together.addFileArg(instrumented_list); + together.expectStdErrMatch("exit 55"); + const shown = b.addRunArtifact(exe); + shown.addArg("show"); + shown.addFileArg(recording); + inline for (.{ "6 breakpoint", "5 alloc", "7 call", "7 ret", " variable", " line" }) |part| shown.expectStdOutMatch(part); + ctx.areaTest("test-together", "A debugger, the agent and instrumentation on one program").dependOn(&shown.step); @import("build/kernel.zig").add(ctx); } -- cgit v1.3