summaryrefslogtreecommitdiff
path: root/anim/src/hexdump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/hexdump.zig')
-rw-r--r--anim/src/hexdump.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig
index d1c363c..3ef1ac9 100644
--- a/anim/src/hexdump.zig
+++ b/anim/src/hexdump.zig
@@ -30,7 +30,7 @@ pub const Kind = enum { number, pointer, loose, unread };
/// a field of a struct the program's pointers reach (by its type), other
/// allocated bytes, `loose` (the allocator's own between allocations), or
/// never observed.
-pub fn kindOf(things: []const objects.Object, moment: Recording.Moment, addr: u64) struct { Kind, ?Recording.types.Type } {
+pub fn kindOf(rec: *const Recording, things: []const objects.Object, moment: Recording.Moment, addr: u64) struct { Kind, ?Recording.types.Type } {
for (things) |o| {
if (!o.holds(addr)) continue;
for (o.type.record.fields) |field| if (o.addr + field.offset == addr) return .{ if (field.type == .pointer) .pointer else .number, field.type };
@@ -40,7 +40,7 @@ pub fn kindOf(things: []const objects.Object, moment: Recording.Moment, addr: u6
var known: [8]bool = undefined;
moment.read(addr, &bytes, &known) catch return .{ .unread, null };
if (std.mem.indexOfScalar(bool, &known, true) == null) return .{ .unread, null };
- return .{ if ((moment.allocation(addr) catch null) != null) .number else .loose, null };
+ return .{ if (rec.allocated(moment, addr)) .number else .loose, null };
}
/// The rows of a region (`lo .. hi`, sixteen-aligned) a dump of `count`
@@ -207,7 +207,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
if (of.array) |arr| if (here < arr.addr and arr.addr < here + run.len) {
run.len = @intCast(arr.addr - here);
};
- const word, kind = kindOf(of.things, moment, here);
+ const word, kind = kindOf(now.rec, of.things, moment, here);
run.kind = switch (word) {
.number => .number,
.pointer => .pointer,
@@ -240,7 +240,7 @@ pub fn drawArcs(u: ui.Ui, now: cursors.Now, x: f32, y: f32, first: u64, count: u
const end = readingIn(v, ry, shift, moment, &values, &known, readings[0..n], room);
// The size word of the chunk after: malloc's, a note after the reading.
const last = runs[n - 1];
- if (last.kind == .loose and last.first == 8 and last.len == 8 and std.mem.indexOfScalar(bool, known[8..], false) == null and chunkAfter(moment, addr + 8)) {
+ if (last.kind == .loose and last.first == 8 and last.len == 8 and std.mem.indexOfScalar(bool, known[8..], false) == null and chunkAfter(now.rec, moment, addr + 8)) {
const size = std.mem.readInt(u64, values[8..16], .little) & ~@as(u64, 7);
v.text(.sans, theme.size.sans.micro, end, rows.baseline(ry) - 1, v.print("malloc's: a chunk of {d}", .{size}), t.faint);
}
@@ -419,9 +419,9 @@ fn aim(arcs: *rows.Arcs, now: cursors.Now, field: u64, target: u64, from: f32, s
/// Whether an allocation the recording has begins just after the word at
/// `word` (the chunk's size word, glibc's and musl's alike): only there are
/// bytes between allocations the allocator's own, to be read as its.
-fn chunkAfter(moment: Recording.Moment, word: u64) bool {
- const a = (moment.allocation(word + 8) catch return false) orelse return false;
- return a.ptr == word + 8;
+fn chunkAfter(rec: *const Recording, moment: Recording.Moment, word: u64) bool {
+ if ((moment.allocation(word + 8) catch null)) |a| return a.ptr == word + 8;
+ return rec.allocated(moment, word + 8) and !rec.allocated(moment, word);
}
/// What a field of a region reads as: a number (little-endian, or `big`),