Skip to content
DwarfFunctionsBuildFromSlices

DwarfFunctionsBuildFromSlices

Description

Container-agnostic builder. Same parser, but takes the three section payloads directly. The Mach-O backtrace path uses this to feed bytes from __DWARF,__debug_* sections inside a dSYM bundle.

Any of info_bytes / abbrev_bytes / str_bytes may be NULL when the corresponding section is absent; an empty info_bytes is treated as “no debug info” (success with empty table).

Success

Returns true. *out is populated; empty when there is no .debug_info to parse.

Failure

Returns false on allocator OOM or malformed DWARF. *out is left in the partial state it had reached; caller should DwarfFunctionsDeinit to release it.

Usage example (Cross-references)

Usage examples (Cross-references)
        u64       str_n    = str_sec ? str_sec->size : 0;
    
        e->fns_ok = DwarfFunctionsBuildFromSlices(&e->fns, info_b, info_n, abbrev_b, abbrev_n, str_b, str_n, alloc);
        return e->fns_ok;
    }
    // ---------------------------------------------------------------------------
    
    bool DwarfFunctionsBuildFromSlices(
        DwarfFunctions *out,
        const u8       *info_bytes,
    ) {
        if (!out || !alloc) {
            LOG_FATAL("DwarfFunctionsBuildFromSlices: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
        const u8 *str_b    = str_sec ? BufData(ElfBuf(elf)) + str_sec->offset : NULL;
        u64       str_n    = str_sec ? str_sec->size : 0;
        return DwarfFunctionsBuildFromSlices(out, info_b, info_n, abbrev_b, abbrev_n, str_b, str_n, alloc);
    }
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, info, info_len, kAbbrev, sizeof(kAbbrev), NULL, 0, base);
        bool           ok    = built && VecLen(&fns.entries) == 1;
    
        DwarfFunctions fns;
        bool built = DwarfFunctionsBuildFromSlices(&fns, info, sizeof(info), kAbbrev, sizeof(kAbbrev), NULL, 0, base);
        bool ok    = !built; // rejected
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, info, info_len, NULL, 0, NULL, 0, base);
        bool           ok    = !built;
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, info, info_len, kAbbrev, sizeof(kAbbrev), NULL, 0, base);
        bool           ok    = !built;
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, info, info_len, kAbbrev, sizeof(kAbbrev), NULL, 0, base);
        bool           ok    = !built;
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, NULL, 0, NULL, 0, NULL, 0, base);
        bool           ok    = built && VecLen(&fns.entries) == 0 && DwarfFunctionsResolve(&fns, 0x4000) == NULL;
Last updated on