Skip to content
DwarfFunctionsResolve

DwarfFunctionsResolve

Description

Find the function whose [low_pc, high_pc) range contains vaddr (file-relative).

Success

Returns a pointer to the matching entry. Valid until DwarfFunctionsDeinit.

Failure

Returns NULL when no entry covers vaddr.

Usage example (Cross-references)

Usage examples (Cross-references)
            const DwarfFunction *f = NULL;
            if (cache_entry->functions_ok) {
                f = DwarfFunctionsResolve(&cache_entry->functions, file_relative);
            }
            if (!f && cache_entry->has_sidecar) {
                }
                if (cache_entry->sidecar_functions_ok) {
                    f = DwarfFunctionsResolve(&cache_entry->sidecar_functions, file_relative);
                }
            }
            // (3) dSYM's DWARF .debug_info function table.
            if (entry_build_dwarf(entry, self->allocator)) {
                const DwarfFunction *f = DwarfFunctionsResolve(&entry->fns, file_relative);
                if (f && f->name) {
                    *out_name = f->name;
    }
    
    const DwarfFunction *DwarfFunctionsResolve(const DwarfFunctions *self, u64 vaddr) {
        if (!self || VecLen(&self->entries) == 0)
            return NULL;
        bool           ok    = false;
        if (built && VecLen(&fns.entries) > 0) {
            const DwarfFunction *f = DwarfFunctionsResolve(&fns, file_relative);
            ok                     = f && f->name && ZstrFindSubstring(f->name, expect_name) != NULL;
            DwarfFunctionsDeinit(&fns);
        bool           ok    = false;
        if (built && VecLen(&fns.entries) > 0) {
            const DwarfFunction *f = DwarfFunctionsResolve(&fns, file_relative);
            ok = f != NULL && f->name != NULL && ZstrFindSubstring(f->name, "dwarf_marker_helper") != NULL;
            DwarfFunctionsDeinit(&fns);
        if (ok) {
            // Inside the range -> the known name comes back.
            const DwarfFunction *f = DwarfFunctionsResolve(&fns, 0x4000);
            ok                     = ok && f && f->name && ZstrCompare(f->name, "widget_init") == 0;
            f                      = DwarfFunctionsResolve(&fns, 0x4000 + 0x3f); // last byte in range
            const DwarfFunction *f = DwarfFunctionsResolve(&fns, 0x4000);
            ok                     = ok && f && f->name && ZstrCompare(f->name, "widget_init") == 0;
            f                      = DwarfFunctionsResolve(&fns, 0x4000 + 0x3f); // last byte in range
            ok                     = ok && f && f->name && ZstrCompare(f->name, "widget_init") == 0;
            // Below low_pc and at/above high_pc -> no match.
            ok                     = ok && f && f->name && ZstrCompare(f->name, "widget_init") == 0;
            // Below low_pc and at/above high_pc -> no match.
            ok = ok && DwarfFunctionsResolve(&fns, 0x3fff) == NULL;
            ok = ok && DwarfFunctionsResolve(&fns, 0x4040) == NULL;
        }
            // Below low_pc and at/above high_pc -> no match.
            ok = ok && DwarfFunctionsResolve(&fns, 0x3fff) == NULL;
            ok = ok && DwarfFunctionsResolve(&fns, 0x4040) == NULL;
        }
        DwarfFunctions fns;
        bool           built = DwarfFunctionsBuildFromSlices(&fns, NULL, 0, NULL, 0, NULL, 0, base);
        bool           ok    = built && VecLen(&fns.entries) == 0 && DwarfFunctionsResolve(&fns, 0x4000) == NULL;
    
        if (built)
Last updated on