From a10e1691dbe5b944812dc8761a450636bc247e3d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 12:07:53 -0300 Subject: agent: bench-agent and its numbers, hooks with names, an archive cc can link zig build bench-agent runs each capability against its native loop and prints what it costs and writes; README has the table. ztrace run looks at the ring a little longer before sleeping (a target that finds the tracer asleep pays a futex wake an event). A hooked function's name is defined as the string of its address, so the recorder's call stack reads fib. A static link without libc's malloc says which -u to add. The archive carries no stack probes, so cc links it in debug builds too. Tests for --wrap (musl, zig cc) and for a recording that fills. Co-Authored-By: Claude Fable 5.2 --- src/agent/agent.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/agent/agent.zig') diff --git a/src/agent/agent.zig b/src/agent/agent.zig index 22b4f8d..bc53336 100644 --- a/src/agent/agent.zig +++ b/src/agent/agent.zig @@ -66,7 +66,13 @@ pub fn init() void { if (client.getenv(env, "ZTRACE_HOOKS")) |list| { var specs = std.mem.tokenizeScalar(u8, list, ','); while (specs.next()) |spec| { - if (symbols.find(null, spec)) |function| hook.add(function.addr) else complain(&.{ "nothing called ", spec }); + const function = symbols.find(null, spec) orelse { + complain(&.{ "nothing called ", spec }); + continue; + }; + // A call names its callee by address: the string of that id is its name. + emit(.string, 0, .{ function.addr, 0, 0, 0, 0, 0 }, text(spec, max_payload)); + hook.add(function.addr); } } allocations = client.getenv(env, "ZTRACE_ALLOC") != null; -- cgit v1.3