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) {
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 }