Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › debug/ › Pdb.zig › parseInfoStream
parseInfoStream
Pdb.parseInfoStream
pub fn parseInfoStream (self : *Pdb ) !void
File
Code
pub fn parseInfoStream (self : *Pdb ) !void {
var stream = self .getStream (pdb .StreamType .pdb ) orelse return error .InvalidDebugInfo ;
const reader = &stream .interface ;
const version = try reader .takeInt (u32 , .little );
const signature = try reader .takeInt (u32 , .little );
_ = signature ;
const age = try reader .takeInt (u32 , .little );
const guid = try reader .takeArray (16 );
if (version != 20000404 )
return error .UnknownPDBVersion ;
self .guid = guid .*;
self .age = age ;
const gpa = self .allocator ;
const string_table_index = str_tab_index : {
const name_bytes_len = try reader .takeInt (u32 , .little );
const name_bytes = try reader .readAlloc (gpa , name_bytes_len );
defer gpa .free (name_bytes );
const HashTableHeader = extern struct {
size : u32 ,
capacity : u32 ,
fn maxLoad (cap : u32 ) u32 {
return cap * 2 / 3 + 1 ;
}
};
const hash_tbl_hdr = try reader .takeStruct (HashTableHeader , .little );
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 (reader , gpa );
defer gpa .free (present );
if (present .len != hash_tbl_hdr .size )
return error .InvalidDebugInfo ;
const deleted = try readSparseBitVector (reader , gpa );
defer gpa .free (deleted );
for (present ) |_ | {
const name_offset = try reader .takeInt (u32 , .little );
const name_index = try reader .takeInt (u32 , .little );
if (name_offset > name_bytes .len )
return error .InvalidDebugInfo ;
const name = std .mem .sliceTo (name_bytes [name_offset ..], 0 );
if (std .mem .eql (u8 , name , "/names" )) {
break :str_tab_index name_index ;
}
}
return error .MissingDebugInfo ;
};
self .string_table = self .getStreamById (string_table_index ) orelse
return error .MissingDebugInfo ;
}