diff options
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r-- | gdb/objfiles.c | 102 |
1 files changed, 41 insertions, 61 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3c5a554..bc909db 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -189,7 +189,7 @@ objfile_lookup_static_link (struct objfile *objfile, static void add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect, - struct objfile *objfile, int force) + struct objfile *objfile, int force) { struct obj_section *section; @@ -472,8 +472,6 @@ objfile::~objfile () /* It still may reference data modules have associated with the objfile and the symbol file data. */ forget_cached_source_info (); - for (compunit_symtab *cu : compunits ()) - cu->finalize (); breakpoint_free_objfile (this); btrace_free_objfile (this); @@ -521,8 +519,8 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile, any symbols in STRUCT_DOMAIN or UNDEF_DOMAIN. But I'm leaving out that test, on the theory that they can't possibly pass the tests below. */ - if ((sym->aclass () == LOC_LABEL - || sym->aclass () == LOC_STATIC) + if ((sym->loc_class () == LOC_LABEL + || sym->loc_class () == LOC_STATIC) && sym->section_index () >= 0) sym->set_value_address (sym->value_address () + delta[sym->section_index ()]); @@ -550,9 +548,9 @@ objfile_relocate1 (struct objfile *objfile, return 0; /* OK, get all the symtabs. */ - for (compunit_symtab *cust : objfile->compunits ()) + for (compunit_symtab &cust : objfile->compunits ()) { - struct blockvector *bv = cust->blockvector (); + struct blockvector *bv = cust.blockvector (); int block_line_section = SECT_OFF_TEXT (objfile); if (bv->map () != nullptr) @@ -587,12 +585,12 @@ objfile_relocate1 (struct objfile *objfile, get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1; /* Update the table in exec_ops, used to read memory. */ - for (obj_section *s : objfile->sections ()) + for (obj_section &s : objfile->sections ()) { - int idx = s - objfile->sections_start; + int idx = &s - objfile->sections_start; exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx, - s->addr ()); + s.addr ()); } /* Data changed. */ @@ -673,18 +671,18 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide) /* See objfiles.h. */ bool -objfile_has_full_symbols (objfile *objfile) +objfile::has_full_symbols () { - return objfile->compunit_symtabs != nullptr; + return !this->compunit_symtabs.empty (); } /* See objfiles.h. */ bool -objfile_has_symbols (objfile *objfile) +objfile::has_symbols () { - for (::objfile *o : objfile->separate_debug_objfiles ()) - if (o->has_partial_symbols () || objfile_has_full_symbols (o)) + for (::objfile *o : this->separate_debug_objfiles ()) + if (o->has_partial_symbols () || o->has_full_symbols ()) return true; return false; @@ -695,8 +693,8 @@ objfile_has_symbols (objfile *objfile) bool have_partial_symbols (program_space *pspace) { - for (objfile *ofp : pspace->objfiles ()) - if (ofp->has_partial_symbols ()) + for (objfile &ofp : pspace->objfiles ()) + if (ofp.has_partial_symbols ()) return true; return false; @@ -707,8 +705,8 @@ have_partial_symbols (program_space *pspace) bool have_full_symbols (program_space *pspace) { - for (objfile *ofp : pspace->objfiles ()) - if (objfile_has_full_symbols (ofp)) + for (objfile &ofp : pspace->objfiles ()) + if (ofp.has_full_symbols ()) return true; return false; @@ -720,13 +718,13 @@ have_full_symbols (program_space *pspace) void objfile_purge_solibs (program_space *pspace) { - for (objfile *objf : pspace->objfiles_safe ()) + for (objfile &objf : pspace->objfiles_safe ()) { /* We assume that the solib package has been purged already, or will be soon. */ - if (!(objf->flags & OBJF_USERLOADED) && (objf->flags & OBJF_SHARED)) - objf->unlink (); + if (!(objf.flags & OBJF_USERLOADED) && (objf.flags & OBJF_SHARED)) + objf.unlink (); } } @@ -735,8 +733,8 @@ objfile_purge_solibs (program_space *pspace) bool have_minimal_symbols (program_space *pspace) { - for (objfile *ofp : pspace->objfiles ()) - if (ofp->per_bfd->minimal_symbol_count > 0) + for (objfile &ofp : pspace->objfiles ()) + if (ofp.per_bfd->minimal_symbol_count > 0) return true; return false; @@ -790,10 +788,10 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2) second case shouldn't occur during normal use, but std::sort does check that '!(a < a)' when compiled in debug mode. */ - for (const obj_section *osect : objfile1->sections ()) - if (osect == sect2) + for (const obj_section &osect : objfile1->sections ()) + if (&osect == sect2) return false; - else if (osect == sect1) + else if (&osect == sect1) return true; /* We should have found one of the sections before getting here. */ @@ -803,10 +801,10 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2) { /* Sort on sequence number of the objfile in the chain. */ - for (objfile *objfile : current_program_space->objfiles ()) - if (objfile == objfile1) + for (objfile &objfile : current_program_space->objfiles ()) + if (&objfile == objfile1) return true; - else if (objfile == objfile2) + else if (&objfile == objfile2) return false; /* We should have found one of the objfiles before getting here. */ @@ -993,9 +991,9 @@ update_section_map (struct program_space *pspace, xfree (map); alloc_size = 0; - for (objfile *objfile : pspace->objfiles ()) - for (obj_section *s : objfile->sections ()) - if (insert_section_p (objfile->obfd.get (), s->the_bfd_section)) + for (objfile &objfile : pspace->objfiles ()) + for (obj_section &s : objfile.sections ()) + if (insert_section_p (objfile.obfd.get (), s.the_bfd_section)) alloc_size += 1; /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */ @@ -1009,10 +1007,10 @@ update_section_map (struct program_space *pspace, map = XNEWVEC (struct obj_section *, alloc_size); i = 0; - for (objfile *objfile : pspace->objfiles ()) - for (obj_section *s : objfile->sections ()) - if (insert_section_p (objfile->obfd.get (), s->the_bfd_section)) - map[i++] = s; + for (objfile &objfile : pspace->objfiles ()) + for (obj_section &s : objfile.sections ()) + if (insert_section_p (objfile.obfd.get (), s.the_bfd_section)) + map[i++] = &s; std::sort (map, map + alloc_size, sort_cmp); map_size = filter_debuginfo_sections(map, alloc_size); @@ -1127,12 +1125,12 @@ is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile) if (objfile == NULL) return false; - for (obj_section *osect : objfile->sections ()) + for (obj_section &osect : objfile->sections ()) { - if (section_is_overlay (osect) && !section_is_mapped (osect)) + if (section_is_overlay (&osect) && !section_is_mapped (&osect)) continue; - if (osect->contains (addr)) + if (osect.contains (addr)) return true; } return false; @@ -1144,34 +1142,16 @@ bool shared_objfile_contains_address_p (struct program_space *pspace, CORE_ADDR address) { - for (objfile *objfile : pspace->objfiles ()) + for (objfile &objfile : pspace->objfiles ()) { - if ((objfile->flags & OBJF_SHARED) != 0 - && is_addr_in_objfile (address, objfile)) + if ((objfile.flags & OBJF_SHARED) != 0 + && is_addr_in_objfile (address, &objfile)) return true; } return false; } -/* The default implementation for the "iterate_over_objfiles_in_search_order" - gdbarch method. It is equivalent to use the objfiles iterable, - searching the objfiles in the order they are stored internally, - ignoring CURRENT_OBJFILE. - - On most platforms, it should be close enough to doing the best - we can without some knowledge specific to the architecture. */ - -void -default_iterate_over_objfiles_in_search_order - (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, - objfile *current_objfile) -{ - for (objfile *objfile : current_program_space->objfiles ()) - if (cb (objfile)) - return; -} - /* See objfiles.h. */ const char * |