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: Tom Tromey <tromey at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 21 Aug 2012 11:14:12 -0600
- Subject: Re: [PATCH 5/9] introduce per-bfd data for the objfile
- References: <87a9yh5l68.fsf@fleche.redhat.com> <5018064E.5040703@redhat.com>
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>> +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);
Pedro> If ABFD is NULL, then we'll always reach this OBSTACK_ZALLOC.
Pedro> That looks suspicious --- multiple get calls allocate multiple
Pedro> independent storages. Is this intended?
Yeah. get_objfile_bfd_data is only called in two situations -- first,
when allocating an objfile, and second, in reread_symbols when
re-creating an objfile.
In both these situations we want to allocate a new storage object.
I will add some comments to make this more clear.
Tom