Skip to content
MachoCacheInit

MachoCacheInit

Description

Initialise an empty Mach-O symbol cache. The allocator argument is optional inside a Scope block (defaults to MisraScope) and backs both the entries Vec and every Mach-O / DWARF table the cache grows lazily.

Success

Yields a MachoCache whose entries Vec is empty and ready for use.

Failure

Cannot fail at construction; first allocator OOM surfaces from later entries growth.

Usage example (Cross-references)

Usage examples (Cross-references)
    #    if FEATURE_PARSER_MACHO
        bool       cache_ok = (alloc != NULL);
        MachoCache cache    = cache_ok ? MachoCacheInit(alloc) : (MachoCache) {0};
    #    else
        (void)alloc;
        }
    
        MachoCache cache = MachoCacheInit(base);
    
        // slide chosen so runtime_ip - slide = 0x100000110 (10 bytes past
        }
    
        MachoCache cache = MachoCacheInit(base);
    
        const u64 slide      = 0;
        write_file(dsym_path, dsym_buf, dsym_size);
    
        MachoCache cache = MachoCacheInit(base);
    
        Zstr name = NULL;
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache      = MachoCacheInit(base);
        Zstr       name       = NULL;
        u32        offset     = 0;
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache = MachoCacheInit(base);
    
        Zstr name = NULL;
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache    = MachoCacheInit(base);
        Zstr       name     = NULL;
        u32        offset   = 0;
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache = MachoCacheInit(base);
        Zstr       name  = NULL;
        // Resolve must fail: stripped main + UUID-mismatched dSYM.
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache  = MachoCacheInit(base);
        Zstr       name   = NULL;
        u32        offset = 0;
        bool      ok       = mc_write_file(bin_path, mc_bin_buf, bin_size);
    
        MachoCache cache = MachoCacheInit(base);
        Zstr       name  = NULL;
        u32        off   = 0;
        bool      ok       = mc_write_file(bin_path, mc_bin_buf, bin_size);
    
        MachoCache cache = MachoCacheInit(base);
    
        Str mod = StrInit(base);
        ok                  = ok && bl_write_file(dsym_path, bl_dsym_buf, dsym_size);
    
        MachoCache cache    = MachoCacheInit(base);
        Zstr       name     = NULL;
        u32        offset   = 0;
        ok                  = ok && bl_write_file(dsym_path, bl_dsym_buf, dsym_size);
    
        MachoCache cache = MachoCacheInit(base);
    
        Zstr name1 = NULL;
        size baseline = DebugAllocatorLiveCount(&dbg);
    
        MachoCache cache    = MachoCacheInit(base);
        Zstr       name     = NULL;
        u32        offset   = 0;
Last updated on