Skip to content
DwarfCfiFindFde

DwarfCfiFindFde

Description

Find the FDE whose [pc_begin, pc_begin + pc_range) range contains vaddr (file-relative).

Success

Returns a pointer to the matching FDE, borrowed from self (valid until DwarfCfiDeinit).

Failure

Returns NULL when no FDE covers vaddr.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        u64             file_relative = addr - load_base;
        const DwarfFde *fde           = DwarfCfiFindFde(&cache_entry->cfi, file_relative);
        if (!fde)
            return false;
    }
    
    const DwarfFde *DwarfCfiFindFde(const DwarfCfi *self, u64 vaddr) {
        if (!self)
            return NULL;
        bool     ok = DwarfCfiBuildFromElf(&cfi, &elf, base);
        if (ok) {
            const DwarfFde *fde = DwarfCfiFindFde(&cfi, target_pc);
            ok                  = fde != NULL && DwarfCfiBuildRow(&cfi, fde, target_pc, out_row);
            DwarfCfiDeinit(&cfi);
        bool     ok = DwarfCfiBuildFromElf(&cfi, &elf, base);
        if (ok) {
            const DwarfFde *fde = DwarfCfiFindFde(&cfi, target_pc);
            ok                  = fde != NULL && DwarfCfiBuildRow(&cfi, fde, target_pc, out_row);
            DwarfCfiDeinit(&cfi);
        bool     ok = DwarfCfiBuildFromElf(&cfi, &elf, base);
        if (ok) {
            const DwarfFde *fde = DwarfCfiFindFde(&cfi, target_pc);
            ok                  = fde != NULL && DwarfCfiBuildRow(&cfi, fde, target_pc, out_row);
            DwarfCfiDeinit(&cfi);
        bool     ok = DwarfCfiBuildFromElf(&cfi, &elf, base);
        if (ok) {
            const DwarfFde *fde = DwarfCfiFindFde(&cfi, target_pc);
            ok                  = fde != NULL && DwarfCfiBuildRow(&cfi, fde, target_pc, out_row);
            DwarfCfiDeinit(&cfi);
            DwarfCfi cfi;
            if (DwarfCfiBuildFromElf(&cfi, &elf, base)) {
                const DwarfFde *fde = DwarfCfiFindFde(&cfi, 0x5000);
                DwarfUnwindRow  row;
                // eh_frame_addr must record the .debug_frame section's address (the
            DwarfCfi cfi;
            if (DwarfCfiBuildFromElf(&cfi, &elf, base)) {
                ok = DwarfCfiFindFde(&cfi, 0x10ff) != NULL  // last in-range address
                  && DwarfCfiFindFde(&cfi, 0x1100) == NULL; // == end: exclusive -> miss
                DwarfCfiDeinit(&cfi);
            if (DwarfCfiBuildFromElf(&cfi, &elf, base)) {
                ok = DwarfCfiFindFde(&cfi, 0x10ff) != NULL  // last in-range address
                  && DwarfCfiFindFde(&cfi, 0x1100) == NULL; // == end: exclusive -> miss
                DwarfCfiDeinit(&cfi);
            }
            DwarfCfi cfi;
            if (DwarfCfiBuildFromElf(&cfi, &elf, base)) {
                const DwarfFde *fde = DwarfCfiFindFde(&cfi, 0x1000);
                DwarfUnwindRow  row;
                ok = fde != NULL && DwarfCfiBuildRow(&cfi, fde, 0x1080, &row) // in range -> ok
            DwarfCfi cfi;
            if (DwarfCfiBuildFromElf(&cfi, &elf, base)) {
                const DwarfFde *fde = DwarfCfiFindFde(&cfi, 0x1000);
                ok                  = fde != NULL && fde->offset == fde_off;
                DwarfCfiDeinit(&cfi);
        // parsed now, so a "no FDE" outcome means the unwinder is broken on this
        // toolchain (the historic clang .debug_frame gap), not correct behaviour.
        const DwarfFde *fde = built ? DwarfCfiFindFde(&cfi, file_relative) : NULL;
        bool            ok  = built && fde != NULL;
        if (ok) {
Last updated on