summaryrefslogtreecommitdiff
path: root/src/cli/record.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 16:45:15 -0300
committerGabriel Schneider <[email protected]>2026-11-10 16:45:15 -0300
commit47f43f0f26b08901c1ddd16aacbe50c2c843ab8a (patch)
tree4d2132989b3d551104d3ddfda2bf1f4ce3171338 /src/cli/record.zig
parent165bb6c1344b98de7bef1d3c2b72147b4a40797a (diff)
downloadcomputeranim-47f43f0f26b08901c1ddd16aacbe50c2c843ab8a.tar.gz
computeranim-47f43f0f26b08901c1ddd16aacbe50c2c843ab8a.zip
record: --from runs through to a place before the first stop
By instruction, a dynamic program's loader and C library start are a million moments nobody watches: the list of anim/tools from main to its exit is 3 743. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/cli/record.zig')
-rw-r--r--src/cli/record.zig15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cli/record.zig b/src/cli/record.zig
index a82fa9e..d3fb8a9 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] [--telescope DEPTH] [--steps N]
+ \\ [--from WHERE] [--stack BYTES] [-s BYTES] [--telescope DEPTH] [--steps N]
\\ [--max-size BYTES] [--strace]
\\ [--ring] [--preload LIB] [--alloc] -- PROGRAM [ARGS]
\\
@@ -19,6 +19,8 @@ pub const usage =
\\ syscall every syscall (--syscalls is the same)
\\ break the breakpoints only
\\-b adds a breakpoint, in any of them: a function, file:line or *address.
+ \\--from runs the program through to WHERE first, without a stop: the
+ \\loader and the C library's start are not what one records by instruction.
\\-b usdt:PROVIDER:NAME (* for any) records the program's static probes
\\(USDT) instead, each hit a `probe` event with its arguments, without
\\stopping there.
@@ -48,6 +50,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
var capture: ?usize = null;
var max_bytes: ?u64 = null;
var strace = false;
+ var from: ?[]const u8 = null;
var breaks: std.ArrayList([]const u8) = .empty;
var watches: std.ArrayList([]const u8) = .empty;
var producer: util.Producer = .{};
@@ -76,6 +79,9 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
} else if (std.mem.eql(u8, arg, "-b")) {
try breaks.append(arena, value.?);
i += 1;
+ } else if (std.mem.eql(u8, arg, "--from")) {
+ from = value.?;
+ i += 1;
} else if (std.mem.eql(u8, arg, "-w")) {
try watches.append(arena, value.?);
i += 1;
@@ -132,9 +138,12 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void {
}
// By line, the loader's hundred thousand instructions are run through
- // to a breakpoint at the entry: there are no lines in them.
+ // to a breakpoint at the entry: there are no lines in them. --from
+ // names another place to run through to.
var entry: ?u32 = null;
- if (by == .line) if (d.syms.entryPoint()) |at| if (at != d.regs.rip) {
+ if (from) |where| {
+ entry = try d.breakAt(d.resolve(where) catch fail("{s}: no such place in the program\n", .{where}), null);
+ } else if (by == .line) if (d.syms.entryPoint()) |at| if (at != d.regs.rip) {
entry = try d.breakAt(at, null);
};