Function getModule [src]

Prototype

pub fn getModule(self: *Pdb, index: usize) !?*Module

Parameters

self: *Pdbindex: usize

Source

pub fn getModule(self: *Pdb, index: usize) !?*Module { if (index >= self.modules.len) return null; const mod = &self.modules[index]; if (mod.populated) return mod; // At most one can be non-zero. if (mod.mod_info.c11_byte_size != 0 and mod.mod_info.c13_byte_size != 0) return error.InvalidDebugInfo; if (mod.mod_info.c13_byte_size == 0) return error.InvalidDebugInfo; const stream = self.getStreamById(mod.mod_info.module_sym_stream) orelse return error.MissingDebugInfo; const reader = &stream.interface; const signature = try reader.takeInt(u32, .little); if (signature != 4) return error.InvalidDebugInfo; const gpa = self.allocator; mod.symbols = try reader.readAlloc(gpa, mod.mod_info.sym_byte_size - 4); mod.subsect_info = try reader.readAlloc(gpa, mod.mod_info.c13_byte_size); var sect_offset: usize = 0; var skip_len: usize = undefined; while (sect_offset != mod.subsect_info.len) : (sect_offset += skip_len) { const subsect_hdr: *align(1) pdb.DebugSubsectionHeader = @ptrCast(&mod.subsect_info[sect_offset]); skip_len = subsect_hdr.length; sect_offset += @sizeOf(pdb.DebugSubsectionHeader); switch (subsect_hdr.kind) { .file_checksums => { mod.checksum_offset = sect_offset; break; }, else => {}, } if (sect_offset > mod.subsect_info.len) return error.InvalidDebugInfo; } mod.populated = true; return mod; }