diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 20:41:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 20:41:07 -0300 |
| commit | 147cc03a90af3782936787bf1da54314a2a4e385 (patch) | |
| tree | ce1fa13ee05c69f6b9464ebb6d00fc56e27bb1b5 /anim/src/context.zig | |
| parent | dbfab7b5cdd76787b6cca72f792acfa3cebcbab5 (diff) | |
| download | computeranim-147cc03a90af3782936787bf1da54314a2a4e385.tar.gz computeranim-147cc03a90af3782936787bf1da54314a2a4e385.zip | |
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 <[email protected]>
Diffstat (limited to 'anim/src/context.zig')
| -rw-r--r-- | anim/src/context.zig | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/anim/src/context.zig b/anim/src/context.zig index 2e86399..7740792 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -245,12 +245,22 @@ pub fn callArguments(u: ui.Ui, rec: *const Recording, open: []const Recording.Ca /// Where frame `i` is in the program's source, `file:line`: the newest at /// the moment's own line, when the moment is on one (in a library it is -/// not); an older one where the recording knows its return address's. +/// not); an older one on its call's line, or where the recording only +/// knows a line near its return address, that one. pub fn frameWhere(u: ui.Ui, rec: *const Recording, moment: u64, i: usize, pc: u64) []const u8 { - const line = if (i == 0) rec.ownLine(moment) else rec.lineOf(pc); + const line = if (i == 0) rec.ownLine(moment) else callLine(rec, moment, pc) orelse rec.lineOf(pc); return if (line) |l| u.print("{s}:{d}", .{ rec.file, l }) else ""; } +/// The line of the call that returns to `ret`, where the recording has it: +/// an outer frame is on its call's line, not on the one it returns to. +fn callLine(rec: *const Recording, moment: u64, ret: u64) ?u32 { + var buf: [256]u8 = undefined; + const after = rec.instruction(moment, ret, &buf) orelse return null; + if (after.back == 0) return null; + return (rec.instruction(moment, ret - after.back, &buf) orelse return null).line; +} + /// A frame's name: its function's (no offset), or its module's and offset where there is no symbol. pub fn frameName(u: ui.Ui, rec: *const Recording, pc: u64) []const u8 { const name = rec.strings.get(pc) orelse return u.print("{x}", .{pc}); |
