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


>>>>> "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


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