struct frame_info * block_innermost_frame (struct block *block) { struct frame_info *frame; CORE_ADDR calling_pc; if (block == NULL) return NULL; frame = NULL; while (1) { frame = get_prev_frame (frame); if (frame == NULL) return NULL; calling_pc = get_frame_address_in_block (frame); /* APPLE LOCAL begin address ranges */ if (block_contains_pc (block, calling_pc)) /* APPLE LOCAL end address ranges */ return frame; } }
struct blockvector * blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section, int *pindex, struct symtab *symtab) { struct block *b; struct block *static_block; int bot, top, half; struct blockvector *bl; if (pindex) *pindex = 0; /* APPLE LOCAL begin cache lookup values for improved performance */ if ((pc == last_blockvector_lookup_pc) && (pc == last_mapped_section_lookup_pc) && (section == cached_mapped_section) && cached_blockvector && (pindex != NULL)) { *pindex = cached_blockvector_index; return cached_blockvector; } last_blockvector_lookup_pc = pc; /* APPLE LOCAL end cache lookup values for improved performance */ if (symtab == 0) /* if no symtab specified by caller */ { /* First search all symtabs for one whose file contains our pc */ symtab = find_pc_sect_symtab (pc, section); if (symtab == 0) /* APPLE LOCAL begin cache lookup values for improved performance */ { cached_blockvector_index = -1; cached_blockvector = NULL; return 0; } /* APPLE LOCAL end cache lookup values for improved performance */ } bl = BLOCKVECTOR(symtab); static_block = BLOCKVECTOR_BLOCK(bl, STATIC_BLOCK); b = BLOCKVECTOR_BLOCK(bl, 0); gdb_assert(b != NULL); /* Then search that symtab for the smallest block that wins. */ /* Use binary search to find the last block that starts before PC. */ bot = 0; top = BLOCKVECTOR_NBLOCKS(bl); while (top - bot > 1) { half = (top - bot + 1) >> 1; b = BLOCKVECTOR_BLOCK(bl, (bot + half)); /* APPLE LOCAL begin address ranges */ if (BLOCK_LOWEST_PC(b) <= pc) /* APPLE LOCAL end address ranges */ bot += half; else top = bot + half; } /* APPLE LOCAL We start with the block whose start/end address is higher than PC. */ /* Now search backward for a block that ends after PC. */ /* APPLE LOCAL: Stop at the first local block; i.e. don't iterate down to the global/static blocks. */ while (bot >= FIRST_LOCAL_BLOCK) { b = BLOCKVECTOR_BLOCK(bl, bot); /* APPLE LOCAL begin address ranges */ /* This condition is a little tricky. Given a function like func () { { subblock} // pc here } BOT may be pointing to "subblock" and so the BOT block start/end addrs are less than PC. But we don't want to terminate the search in this case - we need to keep iterating backwards to find "func"'s block. So I'm trying to restrict this to only quit searching if we're looking at a function's overall scope and both its highest/lowest addresses are lower than PC. */ if (BLOCK_SUPERBLOCK (b) == static_block && BLOCK_LOWEST_PC (b) < pc && BLOCK_HIGHEST_PC (b) < pc) /* APPLE LOCAL begin cache lookup values for improved performance */ { cached_blockvector_index = -1; cached_blockvector = NULL; return 0; } /* APPLE LOCAL end cache lookup values for improved performance */ if (block_contains_pc(b, pc)) /* APPLE LOCAL end address ranges */ { if (pindex) *pindex = bot; /* APPLE LOCAL begom cache lookup values for improved performance */ cached_blockvector_index = bot; cached_blockvector = bl; /* APPLE LOCAL end cache lookup values for improved performance */ return bl; } bot--; } /* APPLE LOCAL begin cache lookup values for improved performance */ cached_blockvector_index = -1; cached_blockvector = NULL; /* APPLE LOCAL end cache lookup values for improved performance */ return 0; }