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/trace/debugger_test.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/trace/debugger_test.zig') diff --git a/src/trace/debugger_test.zig b/src/trace/debugger_test.zig index bfee1d6..370876a 100644 --- a/src/trace/debugger_test.zig +++ b/src/trace/debugger_test.zig @@ -329,12 +329,23 @@ test "the same program under glibc and under musl: the syscalls tell them apart" try std.testing.expectEqual(@as(usize, 1), glibc.calls(.write)); try std.testing.expectEqual(@as(usize, 0), glibc.calls(.writev)); var opened_libc = false; + var buffer: u64 = 0; for (glibc.events.items) |e| { if (e.ev.kind != .syscall_enter) continue; if (e.ev.aux == @backingInt(linux.SYS.openat) and std.mem.endsWith(u8, e.payload, "libc.so.6")) opened_libc = true; - if (e.ev.aux == @backingInt(linux.SYS.write)) try std.testing.expectEqualStrings("small b\n", e.payload); + if (e.ev.aux == @backingInt(linux.SYS.write)) { + try std.testing.expectEqualStrings("small b\n", e.payload); + buffer = e.ev.a[1]; + } } try std.testing.expect(opened_libc); + // What is written is memory too, as it was when the kernel took it. + var in_memory = false; + for (glibc.events.items) |e| { + if (e.ev.kind != .mem_write or e.ev.a[0] > buffer or buffer + 8 > e.ev.a[0] + e.payload.len) continue; + in_memory = std.mem.eql(u8, "small b\n", e.payload[buffer - e.ev.a[0] ..][0..8]); + } + try std.testing.expect(in_memory); // The library and its mappings are known as they appear. var mapped_libc = false; for (glibc.events.items) |e| { -- cgit v1.3