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/cli/dbg.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cli') diff --git a/src/cli/dbg.zig b/src/cli/dbg.zig index 5fcf88e..c60bff2 100644 --- a/src/cli/dbg.zig +++ b/src/cli/dbg.zig @@ -24,7 +24,7 @@ pub const usage = \\ watch WHAT [LEN] record a region at every stop: an address or a symbol \\ regs the registers \\ x WHAT [LEN] memory at an address, a symbol or $register (64 bytes) - \\ bt the call chain, by frame pointer + \\ bt the call chain, by the unwind tables or the frame pointer \\ context, ctx everything at once, pwndbg's way: registers followed \\ as pointers, the instructions at the pc, the stack \\ back [N] look N moments back in the recording: regs, x @@ -301,6 +301,11 @@ const Session = struct { mem.s.fetch(mem.m, addr, buf, known[0..buf.len]) catch return 0; return std.mem.indexOfScalar(bool, known[0..buf.len], false) orelse buf.len; } + + /// The program's call frame information, the same now as at any moment. + pub fn cfi(mem: Memory, pc: u64) ?zt.Symbols.Cfi { + return mem.s.d.cfi(pc); + } }; /// The stop the program is at now. -- cgit v1.3