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.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/cli/record.zig b/src/cli/record.zig
index f508ddc..f5281ca 100644
--- a/src/cli/record.zig
+++ b/src/cli/record.zig
@@ -3,11 +3,13 @@
const std = @import("std");
const zt = @import("ztrace");
const util = @import("util.zig");
+const disasm = @import("disasm.zig");
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]
+ \\ [--stack BYTES] [-s BYTES] [--telescope DEPTH] [--steps N]
+ \\ [--max-size BYTES] [--strace]
\\ [--ring] [--preload LIB] [--alloc] -- PROGRAM [ARGS]
\\
\\Runs PROGRAM under ptrace into a recording (default out.ztrace). --by
@@ -27,6 +29,11 @@ pub const usage =
\\that changed since the stop before: the --stack bytes above the stack
\\pointer (default 128) and each -w region, an address or a symbol, as
\\long as the symbol unless LEN says.
+ \\At every stop the registers and the top of the stack are also followed
+ \\as pointers, --telescope deep (default 3, 0 for not at all): what they
+ \\lead to is recorded, code they lead to is named, and the instructions
+ \\at the pc are disassembled, so that a viewer can show what pwndbg's
+ \\context shows.
\\--steps ends the recording after N moments, and --max-size when the
\\file is that large (default 1G). Sizes take a suffix: 64K, 4G.
\\
@@ -44,6 +51,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
var breaks: std.ArrayList([]const u8) = .empty;
var watches: std.ArrayList([]const u8) = .empty;
var producer: util.Producer = .{};
+ var telescope: u8 = 3;
var i: usize = 0;
while (i < args.len) : (i += 1) {
const arg = args[i];
@@ -71,6 +79,9 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
} else if (std.mem.eql(u8, arg, "-w")) {
try watches.append(arena, value.?);
i += 1;
+ } else if (std.mem.eql(u8, arg, "--telescope")) {
+ telescope = std.fmt.parseInt(u8, value.?, 10) catch fail("--telescope needs a depth\n", .{});
+ i += 1;
} else if (std.mem.eql(u8, arg, "--steps")) {
max_moments = std.fmt.parseInt(u64, value.?, 0) catch fail("--steps needs a number\n", .{});
i += 1;
@@ -96,6 +107,8 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
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.disasm = disasm.one;
+ d.telescope = telescope;
d.syscalls = if (by == .syscall) .stop else .record;
d.stack_watch = stack_bytes;
if (capture) |n| d.capture = n;