diff options
Diffstat (limited to 'src/trace/Debugger.zig')
| -rw-r--r-- | src/trace/Debugger.zig | 20 |
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| { |
