X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fobjfiles.c;h=ada5edc42fab32e6ef61d0a4f1d7cb9fa00c294f;hb=ee3711344b6e0cffeb237fa6889aab04853f9004;hp=4091b42dbf17fb404cc30b655bd36d8e1ffa7f87;hpb=25629dfdb438c82f2bb711174042bb326a526aaf;p=binutils-gdb.git diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 4091b42dbf1..ada5edc42fa 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -117,13 +117,15 @@ get_objfile_pspace_data (struct program_space *pspace) static const struct bfd_data *objfiles_bfd_data; +objfile_per_bfd_storage::~objfile_per_bfd_storage () +{ +} + /* Create the per-BFD storage object for OBJFILE. If ABFD is not NULL, and it already has a per-BFD storage object, use that. - Otherwise, allocate a new per-BFD storage object. If ABFD is not - NULL, the object is allocated on the BFD; otherwise it is allocated - on OBJFILE's obstack. Note that it is not safe to call this - multiple times for a given OBJFILE -- it can only be called when - allocating or re-initializing OBJFILE. */ + Otherwise, allocate a new per-BFD storage object. Note that it is + not safe to call this multiple times for a given OBJFILE -- it can + only be called when allocating or re-initializing OBJFILE. */ static struct objfile_per_bfd_storage * get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) @@ -136,50 +138,28 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) if (storage == NULL) { + storage = new objfile_per_bfd_storage; /* If the object requires gdb to do relocations, we simply fall back to not sharing data across users. These cases are rare enough that this seems reasonable. */ if (abfd != NULL && !gdb_bfd_requires_relocations (abfd)) - { - storage - = ((struct objfile_per_bfd_storage *) - bfd_alloc (abfd, sizeof (struct objfile_per_bfd_storage))); - /* objfile_per_bfd_storage is not trivially constructible, must - call the ctor manually. */ - storage = new (storage) objfile_per_bfd_storage (); - set_bfd_data (abfd, objfiles_bfd_data, storage); - } - else - storage - = obstack_new (&objfile->objfile_obstack); + set_bfd_data (abfd, objfiles_bfd_data, storage); /* Look up the gdbarch associated with the BFD. */ if (abfd != NULL) storage->gdbarch = gdbarch_from_bfd (abfd); - - storage->language_of_main = language_unknown; } return storage; } -/* Free STORAGE. */ - -static void -free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage) -{ - if (storage->demangled_names_hash) - htab_delete (storage->demangled_names_hash); - storage->~objfile_per_bfd_storage (); -} - -/* A wrapper for free_objfile_per_bfd_storage that can be passed as a +/* A deleter for objfile_per_bfd_storage that can be passed as a cleanup function to the BFD registry. */ static void objfile_bfd_data_free (struct bfd *unused, void *d) { - free_objfile_per_bfd_storage ((struct objfile_per_bfd_storage *) d); + delete (struct objfile_per_bfd_storage *) d; } /* See objfiles.h. */ @@ -411,8 +391,6 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_) per_bfd = get_objfile_bfd_data (this, abfd); - terminate_minimal_symbol_table (this); - /* Add this file onto the tail of the linked list of other such files. */ if (object_files == NULL) @@ -672,7 +650,7 @@ objfile::~objfile () if (obfd) gdb_bfd_unref (obfd); else - free_objfile_per_bfd_storage (per_bfd); + delete per_bfd; /* Remove it from the chain of all objfiles. */ @@ -692,12 +670,6 @@ objfile::~objfile () for example), so we need to call this here. */ clear_pc_function_cache (); - /* Clear globals which might have pointed into a removed objfile. - FIXME: It's not clear which of these are supposed to persist - between expressions and which ought to be reset each time. */ - expression_context_block = NULL; - innermost_block.reset (); - /* Check to see if the current_source_symtab belongs to this objfile, and if so, call clear_current_source_symtab_and_line. */ @@ -727,7 +699,7 @@ free_all_objfiles (void) { struct so_list *so; - /* Any objfile referencewould become stale. */ + /* Any objfile reference would become stale. */ for (so = master_so_list (); so; so = so->next) gdb_assert (so->objfile == NULL);