Function parseDbiStream [src]

Prototype

pub fn parseDbiStream(self: *Pdb) !void

Parameters

self: *Pdb

Source

pub fn parseDbiStream(self: *Pdb) !void { var stream = self.getStream(pdb.StreamType.dbi) orelse return error.InvalidDebugInfo; const reader = stream.reader(); const header = try reader.readStruct(std.pdb.DbiStreamHeader); if (header.version_header != 19990903) // V70, only value observed by LLVM team return error.UnknownPDBVersion; // if (header.Age != age) // return error.UnmatchingPDB; const mod_info_size = header.mod_info_size; const section_contrib_size = header.section_contribution_size; var modules = std.ArrayList(Module).init(self.allocator); errdefer modules.deinit(); // Module Info Substream var mod_info_offset: usize = 0; while (mod_info_offset != mod_info_size) { const mod_info = try reader.readStruct(pdb.ModInfo); var this_record_len: usize = @sizeOf(pdb.ModInfo); const module_name = try reader.readUntilDelimiterAlloc(self.allocator, 0, 1024); errdefer self.allocator.free(module_name); this_record_len += module_name.len + 1; const obj_file_name = try reader.readUntilDelimiterAlloc(self.allocator, 0, 1024); errdefer self.allocator.free(obj_file_name); this_record_len += obj_file_name.len + 1; if (this_record_len % 4 != 0) { const round_to_next_4 = (this_record_len | 0x3) + 1; const march_forward_bytes = round_to_next_4 - this_record_len; try stream.seekBy(@as(isize, @intCast(march_forward_bytes))); this_record_len += march_forward_bytes; } try modules.append(Module{ .mod_info = mod_info, .module_name = module_name, .obj_file_name = obj_file_name, .populated = false, .symbols = undefined, .subsect_info = undefined, .checksum_offset = null, }); mod_info_offset += this_record_len; if (mod_info_offset > mod_info_size) return error.InvalidDebugInfo; } // Section Contribution Substream var sect_contribs = std.ArrayList(pdb.SectionContribEntry).init(self.allocator); errdefer sect_contribs.deinit(); var sect_cont_offset: usize = 0; if (section_contrib_size != 0) { const version = reader.readEnum(std.pdb.SectionContrSubstreamVersion, .little) catch |err| switch (err) { error.InvalidValue => return error.InvalidDebugInfo, else => |e| return e, }; _ = version; sect_cont_offset += @sizeOf(u32); } while (sect_cont_offset != section_contrib_size) { const entry = try sect_contribs.addOne(); entry.* = try reader.readStruct(pdb.SectionContribEntry); sect_cont_offset += @sizeOf(pdb.SectionContribEntry); if (sect_cont_offset > section_contrib_size) return error.InvalidDebugInfo; } self.modules = try modules.toOwnedSlice(); self.sect_contribs = try sect_contribs.toOwnedSlice(); }