committed by
Andrew Kelley
parent
8e9a1ac364
commit
a9b505fa77
@@ -517,15 +517,15 @@ fn populateModule(di: *ModuleDebugInfo, mod: *Module) !void {
|
||||
|
||||
const modi = di.pdb.getStreamById(mod.mod_info.ModuleSymStream) orelse return error.MissingDebugInfo;
|
||||
|
||||
const signature = try modi.inStream().readIntLittle(u32);
|
||||
const signature = try modi.reader().readIntLittle(u32);
|
||||
if (signature != 4)
|
||||
return error.InvalidDebugInfo;
|
||||
|
||||
mod.symbols = try allocator.alloc(u8, mod.mod_info.SymByteSize - 4);
|
||||
try modi.inStream().readNoEof(mod.symbols);
|
||||
try modi.reader().readNoEof(mod.symbols);
|
||||
|
||||
mod.subsect_info = try allocator.alloc(u8, mod.mod_info.C13ByteSize);
|
||||
try modi.inStream().readNoEof(mod.subsect_info);
|
||||
try modi.reader().readNoEof(mod.subsect_info);
|
||||
|
||||
var sect_offset: usize = 0;
|
||||
var skip_len: usize = undefined;
|
||||
@@ -704,11 +704,11 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
try di.pdb.openFile(di.coff, path);
|
||||
|
||||
var pdb_stream = di.pdb.getStream(pdb.StreamType.Pdb) orelse return error.InvalidDebugInfo;
|
||||
const version = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const signature = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const age = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const version = try pdb_stream.reader().readIntLittle(u32);
|
||||
const signature = try pdb_stream.reader().readIntLittle(u32);
|
||||
const age = try pdb_stream.reader().readIntLittle(u32);
|
||||
var guid: [16]u8 = undefined;
|
||||
try pdb_stream.inStream().readNoEof(&guid);
|
||||
try pdb_stream.reader().readNoEof(&guid);
|
||||
if (version != 20000404) // VC70, only value observed by LLVM team
|
||||
return error.UnknownPDBVersion;
|
||||
if (!mem.eql(u8, &di.coff.guid, &guid) or di.coff.age != age)
|
||||
@@ -716,9 +716,9 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
// We validated the executable and pdb match.
|
||||
|
||||
const string_table_index = str_tab_index: {
|
||||
const name_bytes_len = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const name_bytes_len = try pdb_stream.reader().readIntLittle(u32);
|
||||
const name_bytes = try allocator.alloc(u8, name_bytes_len);
|
||||
try pdb_stream.inStream().readNoEof(name_bytes);
|
||||
try pdb_stream.reader().readNoEof(name_bytes);
|
||||
|
||||
const HashTableHeader = packed struct {
|
||||
Size: u32,
|
||||
@@ -728,17 +728,17 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
return cap * 2 / 3 + 1;
|
||||
}
|
||||
};
|
||||
const hash_tbl_hdr = try pdb_stream.inStream().readStruct(HashTableHeader);
|
||||
const hash_tbl_hdr = try pdb_stream.reader().readStruct(HashTableHeader);
|
||||
if (hash_tbl_hdr.Capacity == 0)
|
||||
return error.InvalidDebugInfo;
|
||||
|
||||
if (hash_tbl_hdr.Size > HashTableHeader.maxLoad(hash_tbl_hdr.Capacity))
|
||||
return error.InvalidDebugInfo;
|
||||
|
||||
const present = try readSparseBitVector(&pdb_stream.inStream(), allocator);
|
||||
const present = try readSparseBitVector(&pdb_stream.reader(), allocator);
|
||||
if (present.len != hash_tbl_hdr.Size)
|
||||
return error.InvalidDebugInfo;
|
||||
const deleted = try readSparseBitVector(&pdb_stream.inStream(), allocator);
|
||||
const deleted = try readSparseBitVector(&pdb_stream.reader(), allocator);
|
||||
|
||||
const Bucket = struct {
|
||||
first: u32,
|
||||
@@ -746,8 +746,8 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
};
|
||||
const bucket_list = try allocator.alloc(Bucket, present.len);
|
||||
for (present) |_| {
|
||||
const name_offset = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const name_index = try pdb_stream.inStream().readIntLittle(u32);
|
||||
const name_offset = try pdb_stream.reader().readIntLittle(u32);
|
||||
const name_index = try pdb_stream.reader().readIntLittle(u32);
|
||||
const name = mem.spanZ(std.meta.assumeSentinel(name_bytes.ptr + name_offset, 0));
|
||||
if (mem.eql(u8, name, "/names")) {
|
||||
break :str_tab_index name_index;
|
||||
@@ -762,7 +762,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
const dbi = di.pdb.dbi;
|
||||
|
||||
// Dbi Header
|
||||
const dbi_stream_header = try dbi.inStream().readStruct(pdb.DbiStreamHeader);
|
||||
const dbi_stream_header = try dbi.reader().readStruct(pdb.DbiStreamHeader);
|
||||
if (dbi_stream_header.VersionHeader != 19990903) // V70, only value observed by LLVM team
|
||||
return error.UnknownPDBVersion;
|
||||
if (dbi_stream_header.Age != age)
|
||||
@@ -776,7 +776,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
// Module Info Substream
|
||||
var mod_info_offset: usize = 0;
|
||||
while (mod_info_offset != mod_info_size) {
|
||||
const mod_info = try dbi.inStream().readStruct(pdb.ModInfo);
|
||||
const mod_info = try dbi.reader().readStruct(pdb.ModInfo);
|
||||
var this_record_len: usize = @sizeOf(pdb.ModInfo);
|
||||
|
||||
const module_name = try dbi.readNullTermString(allocator);
|
||||
@@ -814,14 +814,14 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
|
||||
var sect_contribs = ArrayList(pdb.SectionContribEntry).init(allocator);
|
||||
var sect_cont_offset: usize = 0;
|
||||
if (section_contrib_size != 0) {
|
||||
const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.inStream().readIntLittle(u32));
|
||||
const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.reader().readIntLittle(u32));
|
||||
if (ver != pdb.SectionContrSubstreamVersion.Ver60)
|
||||
return error.InvalidDebugInfo;
|
||||
sect_cont_offset += @sizeOf(u32);
|
||||
}
|
||||
while (sect_cont_offset != section_contrib_size) {
|
||||
const entry = try sect_contribs.addOne();
|
||||
entry.* = try dbi.inStream().readStruct(pdb.SectionContribEntry);
|
||||
entry.* = try dbi.reader().readStruct(pdb.SectionContribEntry);
|
||||
sect_cont_offset += @sizeOf(pdb.SectionContribEntry);
|
||||
|
||||
if (sect_cont_offset > section_contrib_size)
|
||||
|
||||
Reference in New Issue
Block a user