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. --- src/trace/event.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/trace/event.zig') diff --git a/src/trace/event.zig b/src/trace/event.zig index 4a9f6f7..9ce8e94 100644 --- a/src/trace/event.zig +++ b/src/trace/event.zig @@ -159,6 +159,15 @@ pub const Regs = extern struct { } }; +/// The id of a string, for a producer that keeps no table: its text's +/// hash, with the top bit set. The instrumentation counts its strings from +/// 1, and a symbol's name is the string whose id is its address; a hash up +/// here meets neither, so the producers of one recording (a debugger, an +/// agent and instrumentation at once) never define an id twice. +pub fn stringId(text: []const u8) u64 { + return std.hash.Wyhash.hash(0, text) | 1 << 63; +} + pub fn now() u64 { var ts: std.os.linux.timespec = undefined; _ = std.os.linux.clock_gettime(.MONOTONIC, &ts); -- cgit v1.3