From 6a7a87b8ecb7902de5640cad00028997825024d2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 10:38:30 -0300 Subject: trace: a function's basic blocks; ASan's shadow memory For a graph of a function's blocks: at the first stop inside it a function's blocks are recorded once (bounds, how each ends, where its edges go), with every instruction's text up to 2048 of them; telescope.blocks reads them, and a branch event ties a run to the edge it took. Stripped libraries get blocks from their unwind bounds. For a plain build seen against an ASan one: record --asan keeps the shadow of every region it records, the offset found from the process; telescope.shadow gives an address's shadow byte. The report functions are named and the chain holds from inside the report to main. Tested on an overflowing target built plain, with gcc's ASan and with clang's. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- src/trace/event.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/trace/event.zig') diff --git a/src/trace/event.zig b/src/trace/event.zig index 02deb51..24caff4 100644 --- a/src/trace/event.zig +++ b/src/trace/event.zig @@ -198,6 +198,13 @@ pub fn frameId(addr: u64) u64 { return addr | 1 << 61; } +/// The id of the string that holds the basic blocks of the function that +/// begins at `addr` (`Debugger.emitBlocks`), found as a frame's is: the +/// greatest at or below the pc's. Bits 61 and 62 both. +pub fn blocksId(addr: u64) u64 { + return addr | 3 << 61; +} + pub fn now() u64 { var ts: std.os.linux.timespec = undefined; _ = std.os.linux.clock_gettime(.MONOTONIC, &ts); -- cgit v1.3