objfile_per_bfd_storage non-POD
A following patch will want to add a std::vector to objfile_per_bfd_storage. That makes it non-trivially constructible/destructible. Since objfile_per_bfd_storage objects are allocated on an obstack, we need to call their ctors/dtors manually. This is what this patch does. And then since we can now rely on ctors/dtors being run, make objfile_per_bfd_storage::storage_obstack be an auto_obstack. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * objfiles.c (get_objfile_bfd_data): Call bfd_alloc instead of bfd_zalloc. Call objfile_per_bfd_storage's ctor. (free_objfile_per_bfd_storage): Call objfile_per_bfd_storage's dtor. * objfiles.h (objfile_per_bfd_storage): Add ctor. Make 'storage_obstack' field an auto_obstack. In-class initialize all non-bitfield fields. Make minsyms_read bool. * symfile.c (read_symbols): Adjust.
This commit is contained in:
parent
a4d1e79aaa
commit
23732b1e32
4 changed files with 41 additions and 19 deletions
|
@ -142,12 +142,19 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
|
|||
{
|
||||
storage
|
||||
= ((struct objfile_per_bfd_storage *)
|
||||
bfd_zalloc (abfd, sizeof (struct objfile_per_bfd_storage)));
|
||||
bfd_alloc (abfd, sizeof (struct objfile_per_bfd_storage)));
|
||||
set_bfd_data (abfd, objfiles_bfd_data, storage);
|
||||
}
|
||||
else
|
||||
storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||
struct objfile_per_bfd_storage);
|
||||
{
|
||||
storage = (objfile_per_bfd_storage *)
|
||||
obstack_alloc (&objfile->objfile_obstack,
|
||||
sizeof (objfile_per_bfd_storage));
|
||||
}
|
||||
|
||||
/* objfile_per_bfd_storage is not trivially constructible, must
|
||||
call the ctor manually. */
|
||||
storage = new (storage) objfile_per_bfd_storage ();
|
||||
|
||||
/* Look up the gdbarch associated with the BFD. */
|
||||
if (abfd != NULL)
|
||||
|
@ -171,7 +178,7 @@ free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage)
|
|||
bcache_xfree (storage->macro_cache);
|
||||
if (storage->demangled_names_hash)
|
||||
htab_delete (storage->demangled_names_hash);
|
||||
obstack_free (&storage->storage_obstack, 0);
|
||||
storage->~objfile_per_bfd_storage ();
|
||||
}
|
||||
|
||||
/* A wrapper for free_objfile_per_bfd_storage that can be passed as a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue