aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-08-15 02:44:34 -0400
committerkcbanner <kcbanner@gmail.com>2023-08-15 10:20:11 -0400
commit8a5f331ec832201c6e4bdf211cdd37ca5eb4347b (patch)
tree06edb434b2d1df8d7de41c07b8f631ff8c7fb550 /lib/std/debug.zig
parent5b86180ae3b451288bbc1aed5cf8040d4fcb65fd (diff)
downloadzig-8a5f331ec832201c6e4bdf211cdd37ca5eb4347b.tar.gz
zig-8a5f331ec832201c6e4bdf211cdd37ca5eb4347b.zip
coff: handle the case of there being no PDB path
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index a59630385a..3296f8190a 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -1024,12 +1024,8 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_obj: *coff.Coff) !ModuleDebu
di.dwarf = dwarf;
}
- // Only used by the pdb path
- di.coff_section_headers = try coff_obj.getSectionHeadersAlloc(allocator);
- errdefer allocator.free(di.coff_section_headers);
-
var path_buf: [windows.MAX_PATH]u8 = undefined;
- const len = try coff_obj.getPdbPath(path_buf[0..]);
+ const len = try coff_obj.getPdbPath(path_buf[0..]) orelse return di;
const raw_path = path_buf[0..len];
const path = try fs.path.resolve(allocator, &[_][]const u8{raw_path});
@@ -1038,8 +1034,6 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_obj: *coff.Coff) !ModuleDebu
di.pdb = pdb.Pdb.init(allocator, path) catch |err| switch (err) {
error.FileNotFound, error.IsDir => {
if (di.dwarf == null) return error.MissingDebugInfo;
- allocator.free(di.coff_section_headers);
- di.coff_section_headers = undefined;
return di;
},
else => return err,
@@ -1050,6 +1044,10 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_obj: *coff.Coff) !ModuleDebu
if (!mem.eql(u8, &coff_obj.guid, &di.pdb.?.guid) or coff_obj.age != di.pdb.?.age)
return error.InvalidDebugInfo;
+ // Only used by the pdb path
+ di.coff_section_headers = try coff_obj.getSectionHeadersAlloc(allocator);
+ errdefer allocator.free(di.coff_section_headers);
+
return di;
}
}