authorgravatar for davidgm94.work@protonmail.comDavid Gonzalez Martin <davidgm94.work@protonmail.com> 2023-07-24 23:49:44-06:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-08-04 09:24:11+02:00
log9c05810be60756e07bd7fee09633671bbaa8cda6
tree5cb47bace64690c2f738057037361e22441a1017
parent516eb33442bb6711ec62bf66c941696de9dca5b5

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 }