diff options
Diffstat (limited to 'anim/src/segments.zig')
| -rw-r--r-- | anim/src/segments.zig | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/anim/src/segments.zig b/anim/src/segments.zig index d28d2dd..db9d28f 100644 --- a/anim/src/segments.zig +++ b/anim/src/segments.zig @@ -69,11 +69,18 @@ pub fn read(rec: *const Recording, at: u64, arena: std.mem.Allocator) Space { const maps = mo.mappings(arena) catch &.{}; var bands: std.ArrayList(Band) = .empty; var path_buf: [512]u8 = undefined; + // The tracer's own (its ring, its preloaded agent, and an agent's bss + // after it) are not the program's: left out, as mock 34 has them. + var tracers_end: u64 = 0; for (maps) |mp| { if (mp.addr >= user_end) continue; var path: []const u8 = ""; _ = mo.mapping(mp.addr, &path, &path_buf) catch null; const name = arena.dupe(u8, nameOf(path)) catch ""; + if (std.mem.indexOf(u8, name, "ztrace") != null or (name.len == 0 and mp.addr == tracers_end)) { + tracers_end = mp.addr + mp.len; + continue; + } if (bands.items.len > 0) { const last = &bands.items[bands.items.len - 1]; if (last.hi == mp.addr and last.prot == mp.prot and (std.mem.eql(u8, last.name, name) or (name.len == 0 and last.name.len > 0 and last.name[0] != '['))) { @@ -163,6 +170,12 @@ pub fn size(buf: []u8, bytes: u64) []const u8 { return std.fmt.bufPrint(buf, "{d} {s}", .{ @as(u64, @intFromFloat(@round(v))), units[u] }) catch ""; } +/// `name` cut with `…` to fit `room` (a library's long file name in the program column). +fn cut(u: ui.Ui, name: []const u8, room: f32) []const u8 { + const most: usize = @intFromFloat(@max(room / ui.advance(m.mono), 2)); + return if (name.len > most) u.print("{s}\u{2026}", .{name[0 .. most - 1]}) else name; +} + fn perms(prot: u64) [3]u8 { return .{ if (prot & 1 != 0) 'r' else '-', if (prot & 2 != 0) 'w' else '-', if (prot & 4 != 0) 'x' else '-' }; } @@ -433,9 +446,9 @@ pub const Segments = struct { out.append(arena, .{ .kind = .unit, .addr = un.lo, .unit = k, .target = std.math.clamp((yh + yl) / 2, box.y, box.y + box.h), .ink = un.ink }) catch {}; out.append(arena, .{ .kind = .edge, .addr = un.lo, .unit = k, .target = yl, .ink = un.ink }) catch {}; } - // An edge two units share takes the ink of the one that starts there. - for (out.items, 0..) |*r, j| if (r.kind == .edge and j + 1 < out.items.len and out.items[j + 1].kind == .unit) { - r.ink = l.space.units[out.items[j + 1].unit].ink; + // An edge two units share takes the ink of the one that starts there (its lowest address). + for (out.items) |*r| if (r.kind == .edge) for (l.space.units[c.units[0]..c.units[1]]) |un| if (un.lo == r.addr) { + r.ink = un.ink; }; return out.items; } @@ -484,7 +497,7 @@ pub const Segments = struct { if (un.program) { if (first_program == null) first_program = k; last_program = k; - } else v.text(.mono, m.mono, g.x + m.name, y + 7.2, un.name, t.primary); + } else v.text(.mono, m.mono, g.x + m.name, y + 7.2, cut(v, un.name, theme.layout.program.w - 12 - m.name), t.primary); // A file whose permissions differ: each part's written inside its band, where it is 28 tall. if (un.prot == null) g.insides(v, l, i, un, scale); }, |
