From dbfab7b5cdd76787b6cca72f792acfa3cebcbab5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 20:28:33 -0300 Subject: debugger: what a write gives the kernel is memory too; --from passes other stops A write's buffer was recorded as the syscall's payload only: a reader of the moment's memory found there what an earlier stop had seen of it (zeros, in SQLite's page). And record --from with --by syscall took the loader's first syscall for the place and gave up its breakpoint. Both found by the first animation of a real program. Co-Authored-By: Claude Fable 5.2 --- src/cli/record.zig | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/cli/record.zig') diff --git a/src/cli/record.zig b/src/cli/record.zig index d3fb8a9..7c1371a 100644 --- a/src/cli/record.zig +++ b/src/cli/record.zig @@ -41,6 +41,20 @@ pub const usage = \\ ++ util.Producer.usage; +/// Runs the target to the breakpoint `id`, or its end, and clears it: +/// what else stops it on the way (a syscall, a signal) is recorded and passed. +fn runTo(d: *zt.Debugger, id: u32) !zt.Debugger.Stop { + defer d.clear(id); + while (true) { + const stop = try d.cont(); + switch (stop) { + .breakpoint => |at| if (at == id) return stop, + .exited, .killed => return stop, + else => {}, + } + } +} + pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { const arena = init.arena.allocator(); var out: []const u8 = "out.ztrace"; @@ -152,9 +166,8 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { var full = false; while (rec.moments < max_moments) { const stop = (if (entry) |id| stop: { - defer d.clear(id); entry = null; - break :stop d.cont(); + break :stop runTo(&d, id); } else switch (by) { .insn => d.stepi(), .line => d.step(), -- cgit v1.3