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/ › SelfInfo/ › MachO.zig › getModuleSlide
getModuleSlide
MachO.getModuleSlide
pub fn getModuleSlide (si : *SelfInfo , io : Io , address : usize ) Error !usize
File
Code
pub fn getModuleSlide (si : *SelfInfo , io : Io , address : usize ) Error !usize {
const gpa = std .debug .getDebugInfoAllocator ();
const module = try si .findModule (gpa , io , address );
defer si .mutex .unlock (io );
const header : *std .macho .mach_header_64 = @ptrFromInt (module .text_base );
const raw_macho : [*]u8 = @ptrCast (header );
var it = macho .LoadCommandIterator .init (header , raw_macho [@sizeOf (macho .mach_header_64 )..][0 ..header .sizeofcmds ]) catch unreachable ;
const text_vmaddr = while (it .next () catch unreachable ) |load_cmd | {
if (load_cmd .hdr .cmd != .SEGMENT_64 ) continue ;
const segment_cmd = load_cmd .cast (macho .segment_command_64 ).?;
if (!mem .eql (u8 , segment_cmd .segName (), "__TEXT" )) continue ;
break segment_cmd .vmaddr ;
} else unreachable ;
return module .text_base - text_vmaddr ;
}