authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-02 13:13:16+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:49+01:00
log55ae6747e2ad85f9f92919cab174efadc40ea002
tree0d38a3fd0cc0dd83637499e340657455aad67bbf
parent3f6a90766c7ababdaaca629cc5165c5ff5b5dcd7
signaturelock-open Commit is signed but in an unrecognized format.

names


1 files changed, 11 insertions(+), 12 deletions(-)

lib/std/debug/SelfInfo.zig+11-12
......@@ -28,9 +28,10 @@ const SelfInfo = @This();
2828
2929modules: std.AutoHashMapUnmanaged(usize, struct {
3030 di: Module.DebugInfo,
31 loaded_debug: bool,
31 // MLUGG TODO: okay actually these should definitely go on the impl so it can share state. e.g. loading unwind info might require lodaing debug info in some cases
32 loaded_locations: bool,
3233 loaded_unwind: bool,
33 const init: @This() = .{ .di = .init, .loaded_debug = false, .loaded_unwind = false };
34 const init: @This() = .{ .di = .init, .loaded_locations = false, .loaded_unwind = false };
3435}),
3536lookup_cache: Module.LookupCache,
3637
......@@ -88,11 +89,9 @@ pub fn getSymbolAtAddress(self: *SelfInfo, gpa: Allocator, address: usize) !std.
8889 const module: Module = try .lookup(&self.lookup_cache, gpa, address);
8990 const gop = try self.modules.getOrPut(gpa, module.key());
9091 if (!gop.found_existing) gop.value_ptr.* = .init;
91 if (!gop.value_ptr.loaded_debug) {
92 // MLUGG TODO: this overloads the name 'debug info' with including vs excluding unwind info
93 // figure out a better name for one or the other (i think the inner one is maybe 'symbol info' or something idk)
94 try module.loadDebugInfo(gpa, &gop.value_ptr.di);
95 gop.value_ptr.loaded_debug = true;
92 if (!gop.value_ptr.loaded_locations) {
93 try module.loadLocationInfo(gpa, &gop.value_ptr.di);
94 gop.value_ptr.loaded_locations = true;
9695 }
9796 return module.getSymbolAtAddress(gpa, &gop.value_ptr.di, address);
9897}
......@@ -168,8 +167,8 @@ const Module = switch (native_os) {
168167 }
169168 return error.MissingDebugInfo;
170169 }
171 fn loadDebugInfo(module: *const Module, gpa: Allocator, di: *Module.DebugInfo) !void {
172 return loadMachODebugInfo(gpa, module, di);
170 fn loadLocationInfo(module: *const Module, gpa: Allocator, di: *Module.DebugInfo) !void {
171 try loadMachODebugInfo(gpa, module, di); // MLUGG TODO inline
173172 }
174173 fn loadUnwindInfo(module: *const Module, gpa: Allocator, di: *Module.DebugInfo) !void {
175174 // MLUGG TODO HACKHACK
......@@ -381,7 +380,7 @@ const Module = switch (native_os) {
381380 _ = address;
382381 unreachable;
383382 }
384 fn loadDebugInfo(module: *const Module, gpa: Allocator, di: *DebugInfo) !void {
383 fn loadLocationInfo(module: *const Module, gpa: Allocator, di: *DebugInfo) !void {
385384 _ = module;
386385 _ = gpa;
387386 _ = di;
......@@ -479,7 +478,7 @@ const Module = switch (native_os) {
479478 };
480479 return error.MissingDebugInfo;
481480 }
482 fn loadDebugInfo(module: *const Module, gpa: Allocator, di: *Module.DebugInfo) !void {
481 fn loadLocationInfo(module: *const Module, gpa: Allocator, di: *Module.DebugInfo) !void {
483482 const filename: ?[]const u8 = if (module.name.len > 0) module.name else null;
484483 const mapped_mem = mapFileOrSelfExe(filename) catch |err| switch (err) {
485484 error.FileNotFound => return error.MissingDebugInfo,
......@@ -550,7 +549,7 @@ const Module = switch (native_os) {
550549 }
551550 return null;
552551 }
553 fn loadDebugInfo(module: *const Module, gpa: Allocator, di: *DebugInfo) !void {
552 fn loadLocationInfo(module: *const Module, gpa: Allocator, di: *DebugInfo) !void {
554553 const mapped_ptr: [*]const u8 = @ptrFromInt(module.base_address);
555554 const mapped = mapped_ptr[0..module.size];
556555 var coff_obj = coff.Coff.init(mapped, true) catch return error.InvalidDebugInfo;