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 standard library.
std › debug › ElfFile › loadSeparateDebugFile Private Function loadSeparateDebugFile Doc Source Private Function std.debug.ElfFile.loadSeparateDebugFile
fn loadSeparateDebugFile (
arena : Allocator ,
io : Io ,
main_loaded : *LoadInnerResult ,
opt_crc : ?u32 ,
comptime fmt : []const u8 ,
args : anytype ,
) Allocator .Error !?[]align (std .heap .page_size_min ) const u8 Params File debug/ElfFile.zig: 373
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420 fn loadSeparateDebugFile (
arena : Allocator ,
io : Io ,
main_loaded : *LoadInnerResult ,
opt_crc : ?u32 ,
comptime fmt : []const u8 ,
args : anytype ,
) Allocator .Error !?[]align (std .heap .page_size_min ) const u8 {
const path = try std .fmt .allocPrint (arena , fmt , args );
const elf_file = Io .Dir .cwd ().openFile (io , path , .{}) catch return null ;
defer elf_file .close (io );
const result = loadInner (arena , io , elf_file , opt_crc ) catch |err | switch (err ) {
error .OutOfMemory => |e | return e ,
error .CrcMismatch => return null ,
else => return null ,
};
errdefer comptime unreachable ;
const have_debug_sections = inline for (@as ([]const []const u8 , &.{
"debug_info" ,
"debug_abbrev" ,
"debug_str" ,
"debug_line" ,
})) |name | {
const s = @field (Section .Id , name );
if (main_loaded .sections .get (s ) == null and result .sections .get (s ) == null ) {
break false ;
}
} else true ;
if (result .is_64 != main_loaded .is_64 or
result .endian != main_loaded .endian or
!have_debug_sections )
{
std .posix .munmap (result .mapped_mem );
return null ;
}
inline for (@typeInfo (Dwarf .Section .Id ).@"enum" .field_names ) |f_name | {
const id = @field (Section .Id , f_name );
if (main_loaded .sections .get (id ) == null ) {
main_loaded .sections .set (id , result .sections .get (id ));
}
}
return result .mapped_mem ;
}