[PATCH 5/9] introduce per-bfd data for the objfile
Pedro Alves
palves@redhat.com
Tue Jul 31 16:22:00 GMT 2012
On 07/30/2012 04:21 PM, Tom Tromey wrote:
> +static const struct bfd_data *objfiles_bfd_data;
> +
> +static struct objfile_per_bfd_storage *
> +get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
> +{
> + struct objfile_per_bfd_storage *storage = NULL;
> +
> + if (abfd != NULL)
> + storage = bfd_data (abfd, objfiles_bfd_data);
> +
> + if (storage == NULL)
> + {
> + if (abfd != NULL)
> + {
> + storage = bfd_zalloc (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);
If ABFD is NULL, then we'll always reach this OBSTACK_ZALLOC.
That looks suspicious --- multiple get calls allocate multiple independent
storages. Is this intended?
> +
> + obstack_init (&storage->storage_obstack);
> + storage->filename_cache = bcache_xmalloc (NULL, NULL);
> + }
> +
> + return storage;
> +}
--
Pedro Alves
More information about the Gdb-patches
mailing list