Skip to content
DwarfFunctions

DwarfFunctions

Description

Function-name index built from .debug_info + .debug_abbrev (+ .debug_str for indirect names). Entries are sorted by low_pc to allow a binary-search lookup.

Fields

Name Description
allocator Allocator backing entries + string_pool.
entries Sorted-by-low_pc list of DwarfFunction rows.
string_pool Owned buffer holding function-name strings that entries.name borrows from. We copy because DWARF strings can come from either inline byte-strings or the separately-located .debug_str section.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        // (4) DwarfFunctions on the stripped copy MUST find the name.
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromElf(&fns, &stripped, base);
        bool           ok    = false;
        }
    
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromElf(&fns, &elf, base);
        bool           ok    = false;
    
    bool DwarfFunctionsBuildFromSlices(
        DwarfFunctions *out,
        const u8       *info_bytes,
        u64             info_size,
    }
    
    bool DwarfFunctionsBuildFromElf(DwarfFunctions *out, const ElfFile *elf, Allocator *alloc) {
        if (!out || !elf || !alloc) {
            LOG_ERROR("DwarfFunctionsBuildFromElf: NULL argument");
    }
    
    const DwarfFunction *DwarfFunctionsResolve(const DwarfFunctions *self, u64 vaddr) {
        if (!self || self->entries.length == 0)
            return NULL;
    }
    
    void DwarfFunctionsDeinit(DwarfFunctions *self) {
        if (!self)
            return;
        MachoFile      dsym;
        bool           dsym_open;
        DwarfFunctions fns;
        bool           fns_built;
        bool           fns_ok;
        // when .symtab and .dynsym yield no name. Built for both main and
        // sidecar if either lookup misses.
        DwarfFunctions functions;
        bool           functions_built;
        bool           functions_ok;
        bool           functions_built;
        bool           functions_ok;
        DwarfFunctions sidecar_functions;
        bool           sidecar_functions_built;
        bool           sidecar_functions_ok;
        DwarfFunctionEntries entries;
        Str                  string_pool;
    } DwarfFunctions;
    
    ///
    /// TAGS: Parser, DWARF, Info
    ///
    bool DwarfFunctionsBuildFromElf(DwarfFunctions *out, const ElfFile *elf, Allocator *alloc);
    
    ///
    ///
    bool DwarfFunctionsBuildFromSlices(
        DwarfFunctions *out,
        const u8       *info_bytes,
        u64             info_size,
    /// TAGS: Parser, DWARF, Lookup
    ///
    const DwarfFunction *DwarfFunctionsResolve(const DwarfFunctions *self, u64 vaddr);
    
    void DwarfFunctionsDeinit(DwarfFunctions *self);
    const DwarfFunction *DwarfFunctionsResolve(const DwarfFunctions *self, u64 vaddr);
    
    void DwarfFunctionsDeinit(DwarfFunctions *self);
    
    #endif // MISRA_PARSERS_DWARF_H
Last updated on