pub fn getFileName(self: *Pdb, gpa: Allocator, mod: *Module, file_id: u32) ![]const u8 653
654
655
656
657
658
659
660
661
662
663
664
665
666pub fn getFileName(self: *Pdb, gpa: Allocator, mod: *Module, file_id: u32) ![]const u8 {
const checksum_offset = mod.checksum_offset orelse return error.MissingDebugInfo;
const subsect_index = checksum_offset + file_id;
const chksum_hdr: *align(1) pdb.FileChecksumEntryHeader = @ptrCast(&mod.subsect_info[subsect_index]);
const strtab_offset = @sizeOf(pdb.StringTableHeader) + chksum_hdr.file_name_offset;
self.string_table.?.seekTo(strtab_offset) catch return error.InvalidDebugInfo;
const string_reader = &self.string_table.?.interface;
var source_file_name: Io.Writer.Allocating = .init(gpa);
defer source_file_name.deinit();
_ = try string_reader.streamDelimiterLimit(&source_file_name.writer, 0, .limited(1024));
assert(string_reader.buffered()[0] == 0); // TODO change streamDelimiterLimit API
string_reader.toss(1);
return try source_file_name.toOwnedSlice();
}