authorgravatar for davidgm94.work@protonmail.comDavid Gonzalez Martin <davidgm94.work@protonmail.com> 2023-07-24 23:49:44-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-29 14:20:16-07:00
log199e0c8ffed87761763f2459550bcf591bce22d8
tree687938d3bc59fc4642c89dcaf6c496bac860c8f0
parent413a6b40969277ad5aca00d258daa105c653b7d2

debug: expose module debug info deinitialization

Before this commit, you could use readElfDebugInfo independently with one catch: the data is not freed since the deinitialization functions for ModuleDebugInfo are private. This change makes them public so the users of such function and similar can free the memory after the debug symbols have been used.

1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/debug.zig+4-4
...@@ -1949,7 +1949,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -1949,7 +1949,7 @@ pub const ModuleDebugInfo = switch (native_os) {
1949 addr_table: std.StringHashMap(u64),1949 addr_table: std.StringHashMap(u64),
1950 };1950 };
19511951
1952 fn deinit(self: *@This(), allocator: mem.Allocator) void {1952 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
1953 var it = self.ofiles.iterator();1953 var it = self.ofiles.iterator();
1954 while (it.next()) |entry| {1954 while (it.next()) |entry| {
1955 const ofile = entry.value_ptr;1955 const ofile = entry.value_ptr;
...@@ -2148,7 +2148,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -2148,7 +2148,7 @@ pub const ModuleDebugInfo = switch (native_os) {
2148 /// Only used if debug_data is .pdb2148 /// Only used if debug_data is .pdb
2149 coff_section_headers: []coff.SectionHeader,2149 coff_section_headers: []coff.SectionHeader,
21502150
2151 fn deinit(self: *@This(), allocator: mem.Allocator) void {2151 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
2152 self.debug_data.deinit(allocator);2152 self.debug_data.deinit(allocator);
2153 if (self.debug_data == .pdb) {2153 if (self.debug_data == .pdb) {
2154 allocator.free(self.coff_section_headers);2154 allocator.free(self.coff_section_headers);
...@@ -2221,7 +2221,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -2221,7 +2221,7 @@ pub const ModuleDebugInfo = switch (native_os) {
2221 mapped_memory: []align(mem.page_size) const u8,2221 mapped_memory: []align(mem.page_size) const u8,
2222 external_mapped_memory: ?[]align(mem.page_size) const u8,2222 external_mapped_memory: ?[]align(mem.page_size) const u8,
22232223
2224 fn deinit(self: *@This(), allocator: mem.Allocator) void {2224 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
2225 self.dwarf.deinit(allocator);2225 self.dwarf.deinit(allocator);
2226 os.munmap(self.mapped_memory);2226 os.munmap(self.mapped_memory);
2227 if (self.external_mapped_memory) |m| os.munmap(m);2227 if (self.external_mapped_memory) |m| os.munmap(m);
...@@ -2240,7 +2240,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -2240,7 +2240,7 @@ pub const ModuleDebugInfo = switch (native_os) {
2240 }2240 }
2241 },2241 },
2242 .wasi => struct {2242 .wasi => struct {
2243 fn deinit(self: *@This(), allocator: mem.Allocator) void {2243 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
2244 _ = self;2244 _ = self;
2245 _ = allocator;2245 _ = allocator;
2246 }2246 }