summaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 22:02:01 -0300
committerGabriel Schneider <[email protected]>2026-11-10 22:02:01 -0300
commit36bb1c332a124cb4d437dd8386b267ee58310a5d (patch)
treec6760488e17ab443c63b730e6ec70ed43a010634 /src/cli
parent0a13f5210756e5a42ebf983943d87a1922cda0e3 (diff)
downloadcomputeranim-36bb1c332a124cb4d437dd8386b267ee58310a5d.tar.gz
computeranim-36bb1c332a124cb4d437dd8386b267ee58310a5d.zip
record: how much of the context a stop keeps is asked for
--around BYTES of memory each side of what a pointer leads to, for a viewer that shows the region and not the word; --disasm ROWS above and below the pc; and every word of the --stack bytes is followed as a pointer, not the first sixteen. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/record.zig22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/cli/record.zig b/src/cli/record.zig
index 7c1371a..91b17d2 100644
--- a/src/cli/record.zig
+++ b/src/cli/record.zig
@@ -8,7 +8,8 @@ const fail = util.fail;
pub const usage =
\\usage: ztrace record [-o FILE] [--by insn|line|syscall|break] [-b WHERE]... [-w WHAT[,LEN]]...
- \\ [--from WHERE] [--stack BYTES] [-s BYTES] [--telescope DEPTH] [--steps N]
+ \\ [--from WHERE] [--stack BYTES] [-s BYTES] [--telescope DEPTH]
+ \\ [--around BYTES] [--disasm ROWS] [--steps N]
\\ [--max-size BYTES] [--strace]
\\ [--ring] [--preload LIB] [--alloc] -- PROGRAM [ARGS]
\\
@@ -33,9 +34,10 @@ pub const usage =
\\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.
+ \\lead to is recorded with --around bytes each side of it (default 0:
+ \\the 32 at the place), code they lead to is named, and the instructions
+ \\at the pc are disassembled, --disasm rows above it and below (default
+ \\8), 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.
\\
@@ -69,6 +71,8 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
var watches: std.ArrayList([]const u8) = .empty;
var producer: util.Producer = .{};
var telescope: u8 = 3;
+ var around: usize = 0;
+ var disasm_rows: usize = 8;
var i: usize = 0;
while (i < args.len) : (i += 1) {
const arg = args[i];
@@ -102,6 +106,12 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
} 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, "--around")) {
+ around = std.fmt.parseIntSizeSuffix(value.?, 10) catch fail("--around needs a size\n", .{});
+ i += 1;
+ } else if (std.mem.eql(u8, arg, "--disasm")) {
+ disasm_rows = std.fmt.parseInt(usize, value.?, 10) catch fail("--disasm needs a number of rows\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;
@@ -130,6 +140,10 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
d.disasm = disasm.one;
d.syms.demangle = util.demangle;
d.telescope = telescope;
+ d.telescope_around = around;
+ d.disasm_around = disasm_rows;
+ // Every word of the stack that is recorded is followed, not the first sixteen only.
+ d.telescope_words = @max(d.telescope_words, stack_bytes / 8);
d.syscalls = if (by == .syscall) .stop else .record;
d.stack_watch = stack_bytes;
if (capture) |n| d.capture = n;