diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 13:36:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 14:12:08 -0300 |
| commit | 02aa51a6f54235cf18e627dbbfe21f21e502eb0b (patch) | |
| tree | a53416bdf0e5bb0ce80da63176fe13393c502a2c /src/trace/event.zig | |
| parent | 16895292becf82f493aaced2b10f889bad436156 (diff) | |
| download | computeranim-02aa51a6f54235cf18e627dbbfe21f21e502eb0b.tar.gz computeranim-02aa51a6f54235cf18e627dbbfe21f21e502eb0b.zip | |
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.
Diffstat (limited to 'src/trace/event.zig')
| -rw-r--r-- | src/trace/event.zig | 8 |
1 files changed, 8 insertions, 0 deletions
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); |
