This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/9] introduce per-bfd data for the objfile


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]