From 02aa51a6f54235cf18e627dbbfe21f21e502eb0b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 13:36:32 -0300 Subject: context: disassembly, telescopes and names in every stop; strings as one table For a viewer to show what pwndbg's context shows, the debugger records it while the memory is there: each register and the top of the stack followed as pointers three deep (--telescope), every code address met named, eight instructions from the pc disassembled by capstone (built from source for x86, into the command only; pinned as in 03-codenomicom). zt.telescope reads a chain back with the kind of memory each link points into, and ztrace show prints the context, coloured on a terminal as pwndbg colours. The thirty thousand strings of a small run showed that a string map in each keyframe costs 700 bytes of tree a string: strings are now one table for the recording, appended a batch and read whole at open. fib(12) by instruction with everything on: 9 MB, 71 000 moments/s. --- src/trace/event.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/trace/event.zig') diff --git a/src/trace/event.zig b/src/trace/event.zig index 9ce8e94..7830979 100644 --- a/src/trace/event.zig +++ b/src/trace/event.zig @@ -168,6 +168,14 @@ pub fn stringId(text: []const u8) u64 { return std.hash.Wyhash.hash(0, text) | 1 << 63; } +/// The id of the string that describes the instruction at `addr`: a byte +/// for its length, then its text ("mov rbp, rsp"). The string whose id is +/// `addr` itself is the address's name ("main+4"). Addresses stay below +/// bit 47 and hashed ids have bit 63: bit 62 keeps the two apart. +pub fn codeId(addr: u64) u64 { + return addr | 1 << 62; +} + pub fn now() u64 { var ts: std.os.linux.timespec = undefined; _ = std.os.linux.clock_gettime(.MONOTONIC, &ts); -- cgit v1.3