From 147cc03a90af3782936787bf1da54314a2a4e385 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 20:41:07 -0300 Subject: backtrace: an outer frame is on its call's line The debugger records the call each frame returns from, as an instruction with its line; canim reads it. main is at list.c:41 while reverse() runs, not at 42, and the rows of a stop deep in SQLite have their lines. Co-Authored-By: Claude Fable 5.2 --- src/trace/debugger_test.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/trace/debugger_test.zig') diff --git a/src/trace/debugger_test.zig b/src/trace/debugger_test.zig index 370876a..512dc6f 100644 --- a/src/trace/debugger_test.zig +++ b/src/trace/debugger_test.zig @@ -130,6 +130,18 @@ test "a recording by `ztrace record` has the line of each instruction round the } else return error.NoCall; try std.testing.expectEqual(@as(?u8, 1), call.params); try std.testing.expectEqual(@as(u32, 5), call.line.?.line); + // The frame that called fib is on its call's line: the call is recorded, `back` from where it returns. + const tids = try m.threads(gpa); + defer gpa.free(tids); + const regs = (try m.regs(tids[0])).?; + var chain: [4]u64 = undefined; + const frames = try zt.telescope.backtrace(m, ®s, &chain); + try std.testing.expect(frames.len >= 2); + const after = (try zt.telescope.instruction(m, frames[1], &text)).?; + try std.testing.expect(after.back != 0); + const caller = (try zt.telescope.instruction(m, frames[1] - after.back, &text)).?; + try std.testing.expect(std.mem.startsWith(u8, caller.text, "call")); + try std.testing.expect(caller.line != null); } test "step walks the source lines, in and out of calls, as gdb does" { -- cgit v1.3