summaryrefslogtreecommitdiff
path: root/src/cli/record.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/record.zig')
-rw-r--r--src/cli/record.zig11
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;