summaryrefslogtreecommitdiff
path: root/anim
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 20:41:07 -0300
committerGabriel Schneider <[email protected]>2026-11-10 20:41:07 -0300
commit147cc03a90af3782936787bf1da54314a2a4e385 (patch)
treece1fa13ee05c69f6b9464ebb6d00fc56e27bb1b5 /anim
parentdbfab7b5cdd76787b6cca72f792acfa3cebcbab5 (diff)
downloadcomputeranim-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')
-rw-r--r--anim/src/context.zig14
-rw-r--r--anim/test/gallery/none.pngbin223411 -> 223173 bytes
2 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});
diff --git a/anim/test/gallery/none.png b/anim/test/gallery/none.png
index 098b50a..e4e3cb4 100644
--- a/anim/test/gallery/none.png
+++ b/anim/test/gallery/none.png
Binary files differ