From b4ab1d770edb06d3eeebfd290bbf97725e55b7fa Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 22:51:17 -0300 Subject: trace: the call chain by the unwind tables; what each word of the stack is backtrace and frames follow .debug_frame or .eh_frame where there is one (PLT entries expanded into exact rows) and the frame pointer where there is none: the caller is no longer lost in a prologue, in a function that keeps no frame, in a PLT entry or inside libc's syscall wrappers. Against gdb: the same chains on fib and on SQLite, where the old walk lost __sbrk and unixSync. A recording holds, once a function, its unwind rows and its locals on the stack (DW_OP_fbreg, with the block each lives in), and the process's first stack pointer. telescope.slots says of each word what it is: a saved register and which, a return address, a local by name, argc, argv, envp, auxv. Four bytes a moment on the list by instruction, and no slower. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- src/trace/event.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/trace/event.zig') diff --git a/src/trace/event.zig b/src/trace/event.zig index dcd4aa9..02deb51 100644 --- a/src/trace/event.zig +++ b/src/trace/event.zig @@ -187,6 +187,17 @@ pub fn codeId(addr: u64) u64 { return addr | 1 << 62; } +/// The id of the string that describes the frame of the function that +/// begins at `addr`: how to walk through it to its caller (its call frame +/// information) and where its locals are (`Debugger.emitFunction`). A +/// reader finds the one that holds a pc as the greatest id at or below the +/// pc's (`Trace.stringBelow`). `frameId(0)`, where no function begins, is +/// the process's first stack (`Debugger.Start`). Bit 61 keeps these apart +/// from names, instructions and hashed ids. +pub fn frameId(addr: u64) u64 { + return addr | 1 << 61; +} + pub fn now() u64 { var ts: std.os.linux.timespec = undefined; _ = std.os.linux.clock_gettime(.MONOTONIC, &ts); -- cgit v1.3