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: [patchv3 4/5] Keep objfile original filename


Jan Kratochvil writes:
 > Hi Doug,
 > 
 > this is another more universal (=also for shared library files) implementation
 > of the .dwp symlinks.
 > 
 > This patch could be called "Code cleanup" - it should have no functionality
 > effect - different names (objfile->original_name) than before can get only
 > objfiles which have OBFD.  But for those objfiles objfile_name() accessor does
 > not use the different name anyway.
 > 
 > 
 > Jan
 > 
 > 
 > gdb/
 > 2013-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 > 
 > 	Pass down original filename for objfile.
 > 	* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
 > 	* elfread.c (elf_symfile_read): Likewise.
 > 	* jit.c (jit_object_close_impl): Update allocate_objfile call, no
 > 	longer set ORIGINAL_NAME.
 > 	(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
 > 	* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
 > 	* machoread.c (macho_add_oso_symfile): Add parameter name.  Update
 > 	symbol_file_add_from_bfd call.
 > 	(macho_symfile_read_all_oso): Update macho_add_oso_symfile call.
 > 	(macho_check_dsym): Add parameter filenamep.  Change function comment.
 > 	Set *filenamep.
 > 	(macho_symfile_read): New variable dsym_filename.  Update
 > 	macho_check_dsym call.  Use it for symbol_file_add_separate.
 > 	* objfiles.c (allocate_objfile): Add parameter name.  New comment for
 > 	it.  Use it for objfile->original_name.
 > 	(free_objfile): Free also objfile->original_name.
 > 	(objfile_name): Return OBFD's filename, if available.
 > 	* objfiles.h (struct objfile): Update comment for the name field.
 > 	(allocate_objfile): Add new parameter name.
 > 	* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
 > 	* symfile-mem.c (symbol_file_add_from_memory): Update
 > 	symbol_file_add_from_bfd call.
 > 	* symfile.c (read_symbols): Update symbol_file_add_separate call.
 > 	(symbol_file_add_with_addrs): New parameter name, add function comment
 > 	for it.  Remove variable name.  Update allocate_objfile call.
 > 	(symbol_file_add_separate): New parameter name, add function comment
 > 	for it.  Update symbol_file_add_with_addrs call.
 > 	(symbol_file_add_from_bfd): New parameter name.  Update
 > 	symbol_file_add_with_addrs call.
 > 	(symbol_file_add): Update symbol_file_add_from_bfd call.
 > 	(reread_symbols): Remove the update of objfile->original_name.
 > 	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
 > 	second parameter.

Cool.

 > --- a/gdb/objfiles.c
 > +++ b/gdb/objfiles.c
 > @@ -281,20 +286,23 @@ allocate_objfile (bfd *abfd, int flags)
 >       that any data that is reference is saved in the per-objfile data
 >       region.  */
 >  
 > +  if (name != NULL)
 > +    objfile->original_name = xstrdup (name);
 > +  else
 > +    {
 > +      gdb_assert (abfd == NULL);
 > +      objfile->original_name = xstrdup ("<<anonymous objfile>>");
 > +    }

An alternative is to store the name in objfile_obstack.

 > --- a/gdb/symfile.c
 > +++ b/gdb/symfile.c
 > @@ -839,7 +839,8 @@ read_symbols (struct objfile *objfile, int add_flags)
 >        struct cleanup *cleanup = make_cleanup_bfd_unref (abfd);
 >  
 >        if (abfd != NULL)
 > -	symbol_file_add_separate (abfd, add_flags, objfile);
 > +	symbol_file_add_separate (abfd, objfile->original_name, add_flags,
 > +				  objfile);

Yeah.  Passing objfile->original_name here will help a lot.
I can see a case for either way (abfd's file name or objfile->original_name).
Maybe add a comment here explaining why objfile_original_name is passed?


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