diff options
Diffstat (limited to 'anim/src')
| -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}); |
