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) {
19491949 addr_table: std.StringHashMap(u64),
19501950 };
19511951
1952 fn deinit(self: *@This(), allocator: mem.Allocator) void {
1952 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
19531953 var it = self.ofiles.iterator();
19541954 while (it.next()) |entry| {
19551955 const ofile = entry.value_ptr;
......@@ -2148,7 +2148,7 @@ pub const ModuleDebugInfo = switch (native_os) {
21482148 /// Only used if debug_data is .pdb
21492149 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 {
21522152 self.debug_data.deinit(allocator);
21532153 if (self.debug_data == .pdb) {
21542154 allocator.free(self.coff_section_headers);
......@@ -2221,7 +2221,7 @@ pub const ModuleDebugInfo = switch (native_os) {
22212221 mapped_memory: []align(mem.page_size) const u8,
22222222 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 {
22252225 self.dwarf.deinit(allocator);
22262226 os.munmap(self.mapped_memory);
22272227 if (self.external_mapped_memory) |m| os.munmap(m);
......@@ -2240,7 +2240,7 @@ pub const ModuleDebugInfo = switch (native_os) {
22402240 }
22412241 },
22422242 .wasi => struct {
2243 fn deinit(self: *@This(), allocator: mem.Allocator) void {
2243 pub fn deinit(self: *@This(), allocator: mem.Allocator) void {
22442244 _ = self;
22452245 _ = allocator;
22462246 }