diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 12:09:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 12:15:20 -0300 |
| commit | a7504c6bb2ec9e906891e42bc3df28b276e67143 (patch) | |
| tree | c13e680499badf341b17960341386b8199637671 /src/cli/record.zig | |
| parent | 937b6314c4cd6fa73daeac308fbfcf69b89add56 (diff) | |
| download | computeranim-a7504c6bb2ec9e906891e42bc3df28b276e67143.tar.gz computeranim-a7504c6bb2ec9e906891e42bc3df28b276e67143.zip | |
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.
Diffstat (limited to 'src/cli/record.zig')
| -rw-r--r-- | src/cli/record.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cli/record.zig b/src/cli/record.zig index 7b44522..8a30761 100644 --- a/src/cli/record.zig +++ b/src/cli/record.zig @@ -8,7 +8,7 @@ const fail = util.fail; pub const usage = \\usage: ztrace record [-o FILE] [--by insn|line|syscall|break] [-b WHERE]... [-w WHAT[,LEN]]... \\ [--stack BYTES] [-s BYTES] [--steps N] [--max-size BYTES] [--strace] - \\ -- PROGRAM [ARGS] + \\ [--ring] [--preload LIB] [--alloc] -- PROGRAM [ARGS] \\ \\Runs PROGRAM under ptrace into a recording (default out.ztrace). --by \\says where it stops, each stop a moment: @@ -27,7 +27,7 @@ pub const usage = \\--steps ends the recording after N moments, and --max-size when the \\file is that large (default 1G). Sizes take a suffix: 64K, 4G. \\ -; +++ util.Producer.usage; pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { const arena = init.arena.allocator(); @@ -40,6 +40,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { var strace = false; var breaks: std.ArrayList([]const u8) = .empty; var watches: std.ArrayList([]const u8) = .empty; + var producer: util.Producer = .{}; var i: usize = 0; while (i < args.len) : (i += 1) { const arg = args[i]; @@ -51,6 +52,8 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { by = .syscall; } else if (std.mem.eql(u8, arg, "--strace")) { strace = true; + } else if (producer.take(args, &i)) { + // Its own argument, when it has one, is taken. } else if (value == null) { fail(usage, .{}); } else if (std.mem.eql(u8, arg, "-o")) { @@ -86,8 +89,10 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { var stderr = std.Io.File.stderr().writer(init.io, &stderr_buf); var printer: zt.syscalls.Printer = .{ .w = &stderr.interface, .next = rec.sink() }; - var d = try zt.Debugger.spawn(init.gpa, init.io, path, argv, init.minimal.environ.block.slice.ptr, if (strace) printer.sink() else rec.sink()); + const produced = try producer.start(arena, init.minimal.environ.block.slice); + var d = try zt.Debugger.spawn(init.gpa, init.io, path, argv, if (produced) |p| p.envp.ptr else init.minimal.environ.block.slice.ptr, if (strace) printer.sink() else rec.sink()); defer d.deinit(); + if (produced) |p| d.ring = p.ring; d.syscalls = if (by == .syscall) .stop else .record; d.stack_watch = stack_bytes; if (capture) |n| d.capture = n; |
