This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 5/9] introduce per-bfd data for the objfile
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 31 Jul 2012 17:22:38 +0100
- Subject: Re: [PATCH 5/9] introduce per-bfd data for the objfile
- References: <87a9yh5l68.fsf@fleche.redhat.com>
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