struct blockvector * blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section, struct block **pblock, struct symtab *symtab) { struct blockvector *bl; struct block *b; 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) return 0; } bl = BLOCKVECTOR (symtab); /* Then search that symtab for the smallest block that wins. */ b = find_block_in_blockvector (bl, pc); if (b == NULL) return NULL; if (pblock) *pblock = b; return bl; }
static struct symtab * get_java_class_symtab (void) { if (class_symtab == NULL) { struct objfile *objfile = get_dynamics_objfile (); struct blockvector *bv; struct block *bl; class_symtab = allocate_symtab ("<java-classes>", objfile); class_symtab->language = language_java; bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack, sizeof (struct blockvector) + sizeof (struct block *)); BLOCKVECTOR_NBLOCKS (bv) = 1; BLOCKVECTOR (class_symtab) = bv; /* Allocate dummy STATIC_BLOCK. */ bl = allocate_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack, NULL); BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl; /* Allocate GLOBAL_BLOCK. */ bl = allocate_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_hashed_expandable (); BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl; class_symtab->free_func = free_class_block; } return class_symtab; }
static void add_class_symtab_symbol (struct symbol *sym) { struct symtab *symtab = get_java_class_symtab (); struct blockvector *bv = BLOCKVECTOR (symtab); dict_add_symbol (BLOCK_DICT (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)), sym); }
/* Free the dynamic symbols block. */ static void free_class_block (struct symtab *symtab) { struct blockvector *bv = BLOCKVECTOR (symtab); struct block *bl = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); dict_free (BLOCK_DICT (bl)); }
static void add_class_symtab_symbol (struct symbol *sym) { struct symtab *symtab = get_java_class_symtab (get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile)); struct blockvector *bv = BLOCKVECTOR (symtab); dict_add_symbol (BLOCK_DICT (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)), sym); }
static PyObject * stpy_static_block (PyObject *self, PyObject *args) { struct symtab *symtab = NULL; struct block *block = NULL; struct blockvector *blockvector; STPY_REQUIRE_VALID (self, symtab); blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); return block_to_block_object (block, symtab->objfile); }
struct blockvector * blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section, int *pindex, struct symtab *symtab) { struct block *b; int bot, top, half; struct blockvector *bl; 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) return 0; } bl = BLOCKVECTOR (symtab); b = BLOCKVECTOR_BLOCK (bl, 0); /* 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); if (BLOCK_START (b) <= pc) bot += half; else top = bot + half; } /* Now search backward for a block that ends after PC. */ while (bot >= 0) { b = BLOCKVECTOR_BLOCK (bl, bot); if (BLOCK_END (b) > pc) { if (pindex) *pindex = bot; return bl; } bot--; } return 0; }
static SCM gdbscm_symtab_static_block (SCM self) { symtab_smob *st_smob = stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); const struct symtab *symtab = st_smob->symtab; const struct blockvector *blockvector; const struct block *block; blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); return bkscm_scm_from_block (block, symtab->objfile); }
static struct symtab * get_java_class_symtab (struct gdbarch *gdbarch) { struct objfile *objfile = get_dynamics_objfile (gdbarch); struct symtab *class_symtab = objfile->symtabs; if (class_symtab == NULL) { struct blockvector *bv; struct block *bl; struct jv_per_objfile_data *jv_data; class_symtab = allocate_symtab ("<java-classes>", objfile); class_symtab->language = language_java; bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack, sizeof (struct blockvector) + sizeof (struct block *)); BLOCKVECTOR_NBLOCKS (bv) = 1; BLOCKVECTOR (class_symtab) = bv; /* Allocate dummy STATIC_BLOCK. */ bl = allocate_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack, NULL); BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl; /* Allocate GLOBAL_BLOCK. */ bl = allocate_global_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_hashed_expandable (); set_block_symtab (bl, class_symtab); BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl; /* Arrange to free the dict. */ jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key); jv_data->dict = BLOCK_DICT (bl); } return class_symtab; }
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; }
struct blockvector * blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section, struct block **pblock, struct symtab *symtab) { struct block *b; int bot, top, half; struct blockvector *bl; 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) return 0; } bl = BLOCKVECTOR (symtab); /* Then search that symtab for the smallest block that wins. */ /* If we have an addrmap mapping code addresses to blocks, then use that. */ if (BLOCKVECTOR_MAP (bl)) { b = addrmap_find (BLOCKVECTOR_MAP (bl), pc); if (b) { if (pblock) *pblock = b; return bl; } else return 0; } /* Otherwise, 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); if (BLOCK_START (b) <= pc) bot += half; else top = bot + half; } /* Now search backward for a block that ends after PC. */ while (bot >= 0) { b = BLOCKVECTOR_BLOCK (bl, bot); if (BLOCK_END (b) > pc) { if (pblock) *pblock = b; return bl; } bot--; } return 0; }