summaryrefslogtreecommitdiff
path: root/src/trace/Debugger.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 11:26:59 -0300
committerGabriel Schneider <[email protected]>2026-11-11 11:27:09 -0300
commitdcbe8941df205fa8c8805b022f025e1012dede19 (patch)
tree9b4df7f904077c07eab979cb10aba9d6a3becf10 /src/trace/Debugger.zig
parent6142fa676731e158622ca7956c150c58bc57f1f2 (diff)
downloadcomputeranim-dcbe8941df205fa8c8805b022f025e1012dede19.tar.gz
computeranim-dcbe8941df205fa8c8805b022f025e1012dede19.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'src/trace/Debugger.zig')
-rw-r--r--src/trace/Debugger.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/trace/Debugger.zig b/src/trace/Debugger.zig
index d312dec..2cef5ca 100644
--- a/src/trace/Debugger.zig
+++ b/src/trace/Debugger.zig
@@ -794,6 +794,20 @@ fn emitTelescope(d: *Debugger) !void {
}
}
+/// A module's build id and where its debug info came from, recorded once as
+/// the string `event.moduleId` of its path: a byte (`Symbols.Debug`), then
+/// the id: which library a recording is of, and whether its names and
+/// lines come from debug info that is its own.
+fn emitModule(d: *Debugger, m: *const Symbols.Module) !void {
+ const id = event.moduleId(m.path);
+ if ((try d.described.getOrPut(d.gpa, id)).found_existing) return;
+ var text: [1 + 64]u8 = undefined;
+ text[0] = @intFromEnum(m.debug);
+ const n = @min(m.build_id.len, 64);
+ @memcpy(text[1..][0..n], m.build_id[0..n]);
+ try d.emit(.{ .kind = .string, .a = .{ id, 0, 0, 0, 0, 0 } }, text[0 .. 1 + n]);
+}
+
/// The call that returns to `ret`, the instruction before it and the one
/// at `ret`, recorded as instructions, once: a caller's rows in a descent,
/// and an outer frame is on its call's line, `back` from `ret`.
@@ -893,8 +907,9 @@ pub fn decode(d: *Debugger, nr: u16) ![]const u8 {
/// The string id of a line's file: its path, recorded the first time.
fn fileId(d: *Debugger, l: Symbols.Line) !u64 {
if (d.file_ids.get(l.key)) |id| return id;
- // A file compiled by its full path names itself whole.
- const path = if (std.fs.path.isAbsolute(l.name)) try d.gpa.dupe(u8, l.name) else try std.fs.path.join(d.gpa, &.{ l.dir, l.name });
+ // As the compilation saw it: its directory, the file's, its name, each
+ // relative to the one before (glibc's: /usr/src/debug/glibc/glibc/csu/../sysdeps/...).
+ const path = try std.fs.path.resolveAlloc(d.gpa, &.{ l.base, l.dir, l.name });
const named = d.files.getOrPut(d.gpa, path) catch |err| {
d.gpa.free(path);
return err;
@@ -922,6 +937,7 @@ pub fn refreshMaps(d: *Debugger) !void {
defer d.syms.free(old);
d.unwound.clearRetainingCapacity();
if (d.sink == null) return;
+ for (d.syms.modules.items) |*m| try d.emitModule(m);
const now = d.syms.maps.list;
for (old.list) |o| {
for (now) |m| {