coff: handle the case of there being no PDB path

This commit is contained in:
kcbanner
2023-08-15 02:44:34 -04:00
parent 5b86180ae3
commit 8a5f331ec8
2 changed files with 11 additions and 12 deletions

View File

@@ -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;
}
}