diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 23:04:17 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 23:25:40 -0300 |
| commit | 58643dab07a803dbb579d84f68419911f5a2a16d (patch) | |
| tree | b97c9ab4f5ccd27448ecb609ea8879a42a8fe992 /src/trace/Debugger.zig | |
| parent | b4ab1d770edb06d3eeebfd290bbf97725e55b7fa (diff) | |
| download | computeranim-58643dab07a803dbb579d84f68419911f5a2a16d.tar.gz computeranim-58643dab07a803dbb579d84f68419911f5a2a16d.zip | |
trace: glibc's heap, read from a recording at any moment
record --heap keeps the arena, the tcache and, of every chunk, its size
word and the links of those on a list: free chunks stay readable, which
--alloc dropped at the free. zt.heap.glibc gives the chunks in address
order, the tcache's and the bins' chains (safe-linking as the stored
value and the pointer it protects), the top; each with the address of
the word it was read from, each chain saying how it ended. ztrace show
prints it. Layouts for glibc 2.44 (no fastbins; a tcache made at the
first free, counting the slots left) and 2.40; the arena found by symbol
or by the struct whose next points at itself. Against pwndbg on 2.40:
the same at every stop. Three bytes a moment and a sixth slower on the
list by instruction.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'src/trace/Debugger.zig')
| -rw-r--r-- | src/trace/Debugger.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/trace/Debugger.zig b/src/trace/Debugger.zig index 5310ad3..f4f945b 100644 --- a/src/trace/Debugger.zig +++ b/src/trace/Debugger.zig @@ -66,6 +66,8 @@ allocations: std.ArrayList(Watch) = .empty, /// The most read of them at a stop, in bytes: a stop's cost must not grow /// with the target's heap. allocation_watch: usize = 256 << 10, +/// glibc's heap, recorded at every stop as `heap.zig` reads it (`--heap`): null for not at all. +heap: ?@import("heap.zig").Watch = null, breakpoints: std.ArrayList(Breakpoint) = .empty, /// The current thread's registers at its last stop. regs: Regs = .{}, @@ -490,6 +492,7 @@ fn report(d: *Debugger, stop: Stop) !Stop { for (d.watches.items) |w| try d.snapshot(w.addr, w.len); for (d.declared.items) |w| try d.snapshot(w.addr, w.len); try d.snapshotAllocations(); + if (d.heap) |*h| try h.atStop(d); try d.emitCode(); try d.emitTelescope(); } @@ -1136,7 +1139,7 @@ pub fn cfi(d: *Debugger, pc: u64) ?Symbols.Cfi { /// The target's memory as a walk of the call chain reads it, every word it /// reads recorded, and the frame of every function it goes through /// (`emitFunction`): so a reader walks the same chain from the recording. -const Recorded = struct { +pub const Recorded = struct { d: *Debugger, failed: ?anyerror = null, /// The stack as last read, a page at a time: a walk goes up it. |
