summaryrefslogtreecommitdiff
path: root/anim/src/Recording.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/Recording.zig')
-rw-r--r--anim/src/Recording.zig16
1 files changed, 15 insertions, 1 deletions
diff --git a/anim/src/Recording.zig b/anim/src/Recording.zig
index 833d17b..1a4d859 100644
--- a/anim/src/Recording.zig
+++ b/anim/src/Recording.zig
@@ -218,6 +218,14 @@ pub fn ownLine(r: *const Recording, i: u64) ?u32 {
return l.line;
}
+/// Whether the pc at moment `i` is in the program's own source: not in a
+/// library's code, a PLT stub, the vDSO (where `own` keeps the last line).
+pub fn sourced(r: *const Recording, i: u64) bool {
+ var buf: [256]u8 = undefined;
+ const here = r.instruction(i, r.register(i, "rip"), &buf) orelse return r.ownLine(i) != null;
+ return here.line != null;
+}
+
/// The first line a source panel of `fit` lines shows when the program is
/// on `line`: the whole file when it fits; else a window that has the line
/// in its middle third, and is the same window for every line of that
@@ -425,7 +433,13 @@ fn index(r: *Recording) !void {
try touch_list.append(arena, touched);
pending = touched;
try branch_list.append(arena, branched);
- if (ours and regs != null) try code_lines.put(gpa, regs.?.rip, line.line);
+ // Not where the instruction says it has no line: a library's code (a
+ // PLT stub, libc) keeps the last line of ours in `lines`, and is not of it.
+ if (ours and regs != null) {
+ var text: [256]u8 = undefined;
+ const here = zt.telescope.instruction(m, regs.?.rip, &text) catch null;
+ if (here == null or here.?.line != null) try code_lines.put(gpa, regs.?.rip, line.line);
+ }
try registers.append(arena, regs orelse before orelse .{});
if (!told and stepped and regs != null and before != null) {