summaryrefslogtreecommitdiff
path: root/anim/src/objects.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/objects.zig')
-rw-r--r--anim/src/objects.zig11
1 files changed, 9 insertions, 2 deletions
diff --git a/anim/src/objects.zig b/anim/src/objects.zig
index 0c4f48a..6ee2b4c 100644
--- a/anim/src/objects.zig
+++ b/anim/src/objects.zig
@@ -15,6 +15,8 @@ pub const Object = struct {
slot: ?usize,
/// Its allocation is gone: something still points at freed memory.
freed: bool,
+ /// Its type's name, where the debug info names it (`struct node`).
+ name: []const u8 = "",
pub fn holds(o: Object, addr: u64) bool {
return addr >= o.addr and addr - o.addr < o.type.record.size;
@@ -60,9 +62,14 @@ fn follow(scratch: std.mem.Allocator, rec: *const Recording, m: Recording.Moment
if (t != .record) return;
const addr = (Recording.word(m, at, 8) catch return) orelse return;
if (addr == 0) return;
- for (found.items) |o| if (o.addr == addr) return;
+ const name = if (pointee == .named) pointee.named else "";
+ // Met again through a pointer that names it as C does (`struct node`, not a typedef): that name.
+ for (found.items) |*o| if (o.addr == addr) {
+ if (std.mem.startsWith(u8, name, "struct ") or std.mem.startsWith(u8, name, "union ")) o.name = name;
+ return;
+ };
const live = (m.allocation(addr) catch null) != null;
- found.append(scratch, .{ .addr = addr, .type = t, .slot = slotOf(rec, addr, m), .freed = !live and wasAllocated(rec, addr, m.index) }) catch {};
+ found.append(scratch, .{ .addr = addr, .type = t, .slot = slotOf(rec, addr, m), .freed = !live and wasAllocated(rec, addr, m.index), .name = name }) catch {};
}
/// The place of the allocation at `addr` among every allocation of its