summaryrefslogtreecommitdiff
path: root/src/trace/Debugger.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.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.zig')
-rw-r--r--src/trace/Debugger.zig11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/trace/Debugger.zig b/src/trace/Debugger.zig
index a38c337..bdcc4cc 100644
--- a/src/trace/Debugger.zig
+++ b/src/trace/Debugger.zig
@@ -93,6 +93,10 @@ functions: std.AutoHashMapUnmanaged(u64, []const u32) = .empty,
/// default: not at all (the commands ask for 3).
telescope: u8 = 0,
telescope_words: usize = 16,
+/// The bytes recorded each side of a place the telescope reaches, beside
+/// the 32 at it and no further than its mapping: the region a viewer
+/// shows round what a pointer leads to.
+telescope_around: usize = 0,
/// The addresses already named, and the instructions already recorded
/// with the length of each.
described: std.AutoHashMapUnmanaged(u64, void) = .empty,
@@ -605,7 +609,7 @@ fn emitTelescope(d: *Debugger) !void {
if (d.telescope == 0) return;
const r = &d.regs;
for ([_]u64{ r.rip, r.rax, r.rbx, r.rcx, r.rdx, r.rsi, r.rdi, r.rbp, r.rsp, r.r8, r.r9, r.r10, r.r11, r.r12, r.r13, r.r14, r.r15 }) |value| try d.chase(value);
- var words: [64]u64 = undefined;
+ var words: [256]u64 = undefined;
const n = d.read(r.rsp, std.mem.sliceAsBytes(words[0..@min(words.len, d.telescope_words)])) / 8;
for (words[0..n]) |value| try d.chase(value);
// The call chain: each frame's saved pointer and return address
@@ -651,8 +655,9 @@ fn chase(d: *Debugger, value: u64) !void {
const m = d.syms.mappingAt(v) orelse return;
if (m.prot & 1 == 0) return;
if (m.prot & 4 != 0) return d.nameAddress(v);
- const bytes = try d.snap(v, 32);
- const off: usize = @intCast(v & 7);
+ const lo = @max(m.start, v -| d.telescope_around) & ~@as(u64, 7);
+ const bytes = try d.snap(lo, @min(m.end, v + 32 + d.telescope_around) - lo);
+ const off: usize = @intCast(v - lo);
if (bytes.len < off + 8) return;
v = std.mem.readInt(u64, bytes[off..][0..8], .little);
}