aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug/SelfInfo/DarwinModule.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-09-02 18:47:31 +0100
committermlugg <mlugg@mlugg.co.uk>2025-09-30 13:44:50 +0100
commit665f13b0cde4b9c2e69b139a87d272a67a9489e1 (patch)
tree88598b5eb7d17a86ea15a93ca15dbab5be6594d2 /lib/std/debug/SelfInfo/DarwinModule.zig
parentba3f38959a31ace9af1816f16cda6c0717518b7f (diff)
downloadzig-665f13b0cde4b9c2e69b139a87d272a67a9489e1.tar.gz
zig-665f13b0cde4b9c2e69b139a87d272a67a9489e1.zip
SelfInfo deinit magic
Diffstat (limited to 'lib/std/debug/SelfInfo/DarwinModule.zig')
-rw-r--r--lib/std/debug/SelfInfo/DarwinModule.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/std/debug/SelfInfo/DarwinModule.zig b/lib/std/debug/SelfInfo/DarwinModule.zig
index d0cb47281f..976893e0af 100644
--- a/lib/std/debug/SelfInfo/DarwinModule.zig
+++ b/lib/std/debug/SelfInfo/DarwinModule.zig
@@ -578,9 +578,7 @@ fn unwindFrameMachO(
return new_ip;
}
/// No cache needed, because `_dyld_get_image_header` etc are already fast.
-pub const LookupCache = struct {
- pub const init: LookupCache = .{};
-};
+pub const LookupCache = void;
pub const DebugInfo = struct {
unwind: ?struct {
// Backed by the in-memory sections mapped by the loader
@@ -601,22 +599,24 @@ pub const DebugInfo = struct {
.full = null,
};
+ pub fn deinit(di: *DebugInfo, gpa: Allocator) void {
+ if (di.full) |*full| {
+ for (full.ofiles.values()) |*ofile| {
+ ofile.dwarf.deinit(gpa);
+ ofile.addr_table.deinit(gpa);
+ }
+ full.ofiles.deinit(gpa);
+ gpa.free(full.symbols);
+ posix.munmap(full.mapped_memory);
+ }
+ }
+
const OFile = struct {
dwarf: Dwarf,
// MLUGG TODO: this could use an adapter to just index straight into the strtab!
addr_table: std.StringArrayHashMapUnmanaged(u64),
};
- fn deinit(di: *DebugInfo, gpa: Allocator) void {
- for (di.full.ofiles.values()) |*ofile| {
- ofile.dwarf.deinit(gpa);
- ofile.addr_table.deinit(gpa);
- }
- di.full.ofiles.deinit();
- gpa.free(di.full.symbols);
- posix.munmap(di.full.mapped_memory);
- }
-
fn loadOFile(gpa: Allocator, o_file_path: []const u8) !OFile {
const mapped_mem = try mapDebugInfoFile(o_file_path);
errdefer posix.munmap(mapped_mem);