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 9/9] do not malloc objfile->name


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> +	    if (objfile->obfd == NULL)
>> +	      {
>> +		make_cleanup_bfd_unref (obfd);
>> +		error (_("Can't open %s to read symbols."), objfile->name);
>> +	      }
[...]
>> -	  if (objfile->obfd == NULL)
>> -	    error (_("Can't open %s to read symbols."), objfile->name);
>> +	  objfile->name = bfd_get_filename (objfile->obfd);

Pedro> Took me a second to grok this change.  The issue is that the
Pedro> lifetime of objfile-> name is now the BFD's lifetime, so we can't
Pedro> gdb_bfd_unref, and then use objfile->name in the error call.  I
Pedro> think this deserves a small comment here, [...]

I changed the error to use 'obfd_filename'.  I think this makes the
logic more obvious.  I also added a comment:

	    if (objfile->obfd == NULL)
	      {
		/* We have to make a cleanup and error here, rather
		   than erroring later, because once we unref OBFD,
		   OBFD_FILENAME will be freed.  */
		make_cleanup_bfd_unref (obfd);
		error (_("Can't open %s to read symbols."), obfd_filename);
	      }

Tom


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