From dcbe8941df205fa8c8805b022f025e1012dede19 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 11:26:59 -0300 Subject: symbols: a library's separate debug info, when it is of the same build The system glibc stays dynamically linked and is symbolized from the debug file in the debuginfod client's cache or under /usr/lib/debug, used only when its own build id equals the mapped library's; nothing is downloaded. Static functions get names (the loader's resolver is _dl_runtime_resolve_xsavec; main_arena is found by symbol), libc's frames their file and line as the build saw them, and locals, blocks and parameter counts follow. A recording says of each module its build id and where its names came from; ztrace show prints it. Read only when an address in the module needs a name: 44 ms and 25 MB at the first one. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- src/cli/show.zig | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/cli') diff --git a/src/cli/show.zig b/src/cli/show.zig index 7019113..ef05e7a 100644 --- a/src/cli/show.zig +++ b/src/cli/show.zig @@ -135,7 +135,16 @@ pub fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io. if (chain.len > 1) try w.writeAll("\n"); if (chain.len > 1) for (chain, 0..) |pc, depth| { var text: [256]u8 = undefined; - try w.print(" #{d} {x} {s}\n", .{ depth, pc, (try m.string(pc, &text)) orelse "" }); + try w.print(" #{d} {x} {s}", .{ depth, pc, (try m.string(pc, &text)) orelse "" }); + // Its line, as `bt` gives it: the pc's, a caller's call's (recorded `back` from where it returns). + var at = pc; + if (depth > 0) if (try zt.telescope.instruction(m, pc, &text)) |after| { + at -= after.back; + }; + if (try zt.telescope.instruction(m, at, &text)) |insn| if (insn.line) |l| { + try w.print(" ({s}:{d})", .{ std.fs.path.basename(try name(m, arena, l.file)), l.line }); + }; + try w.writeAll("\n"); }; } for (try m.stack(arena, tid), 0..) |frame, depth| { @@ -169,10 +178,22 @@ pub fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io. const mappings = try m.mappings(arena); if (mappings.len > 0) try w.writeAll("\nmappings\n"); + var last: []const u8 = ""; for (mappings) |region| { var path: []const u8 = ""; var path_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; _ = try m.mapping(region.addr, &path, &path_buf); - try w.print(" {x:0>12}-{x:0>12} {s}\n", .{ region.addr, region.addr + region.len, path }); + try w.print(" {x:0>12}-{x:0>12} {s}", .{ region.addr, region.addr + region.len, path }); + // A module, once: which build it is, and whether its names come from its own debug info. + if (!std.mem.eql(u8, path, last)) if (zt.telescope.module(m, path)) |module| { + if (module.build_id.len > 0) try w.print(" build-id {x},", .{module.build_id}) else try w.writeAll(" no build id,"); + try w.print(" debug info {s}", .{switch (module.debug) { + .none => "none", + .own => "in the file", + .separate => "separate, of the same build", + } }); + }; + last = try arena.dupe(u8, path); + try w.writeAll("\n"); } } -- cgit v1.3