summaryrefslogtreecommitdiff
path: root/src/trace/debugger_test.zig
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/trace/debugger_test.zig
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/trace/debugger_test.zig')
-rw-r--r--src/trace/debugger_test.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/trace/debugger_test.zig b/src/trace/debugger_test.zig
index 512dc6f..5d43d8c 100644
--- a/src/trace/debugger_test.zig
+++ b/src/trace/debugger_test.zig
@@ -173,6 +173,31 @@ test "step walks the source lines, in and out of calls, as gdb does" {
try std.testing.expectEqualStrings("main", d2.syms.symbolAt(chain[1]).?.name);
}
+test "the telescope records the region round what a pointer leads to" {
+ var log: Log = .{};
+ defer log.deinit();
+ var d = try spawn(targets.list, "3", log.sink());
+ defer d.deinit();
+ d.telescope = 1;
+ d.telescope_around = 16;
+ // The heap is a mapping the debugger learns of from the program's brk.
+ d.syscalls = .record;
+ // At `list_done(head)`: rdi leads to a node on the heap, malloc's header before it.
+ _ = try d.breakAt(try d.resolve("list_done"), null);
+ _ = try d.cont();
+ const node = d.regs.rdi;
+ // Sixteen bytes before it to sixteen past its 32, in however many writes.
+ var seen: u64 = 0;
+ for (log.events.items) |e| {
+ if (e.ev.kind != .mem_write) continue;
+ for (0..64) |i| {
+ const at = node - 16 + i;
+ if (at >= e.ev.a[0] and at < e.ev.a[0] + e.payload.len) seen |= @as(u64, 1) << @intCast(i);
+ }
+ }
+ try std.testing.expectEqual(~@as(u64, 0), seen);
+}
+
test "a hook snapshots the linked list; the recording's last moment has what the program built" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();