Keep objfile original filename

gdb/
2013-09-24  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 two macho_add_oso_symfile calls.
	(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.
	(objfile_name): Return OBFD's filename, if available.
	* objfiles.h (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, new
	comment for it.
	(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): New variable original_name.  Save
	objfile->original_name by it.
	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
	second parameter.
This commit is contained in:
Jan Kratochvil 2013-09-24 14:00:06 +00:00
parent 4262abfb98
commit 24ba069af8
12 changed files with 115 additions and 37 deletions

View file

@ -248,6 +248,11 @@ build_objfile_section_table (struct objfile *objfile)
into the list of all known objfiles, and return a pointer to the
new objfile struct.
NAME should contain original non-canonicalized filename or other
identifier as entered by user. If there is no better source use
bfd_get_filename (ABFD). NAME may be NULL only if ABFD is NULL.
NAME content is copied into returned objfile.
The FLAGS word contains various bits (OBJF_*) that can be taken as
requests for specific operations. Other bits like OBJF_SHARED are
simply copied through to the new objfile flags member. */
@ -262,7 +267,7 @@ build_objfile_section_table (struct objfile *objfile)
things in a consistent state even if abfd is NULL. */
struct objfile *
allocate_objfile (bfd *abfd, int flags)
allocate_objfile (bfd *abfd, const char *name, int flags)
{
struct objfile *objfile;
@ -279,20 +284,23 @@ allocate_objfile (bfd *abfd, int flags)
that any data that is reference is saved in the per-objfile data
region. */
if (name == NULL)
{
gdb_assert (abfd == NULL);
name = "<<anonymous objfile>>";
}
objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
strlen (name));
objfile->obfd = abfd;
gdb_bfd_ref (abfd);
if (abfd != NULL)
{
objfile->original_name = bfd_get_filename (abfd);
objfile->mtime = bfd_get_mtime (abfd);
/* Build section table. */
build_objfile_section_table (objfile);
}
else
{
objfile->original_name = "<<anonymous objfile>>";
}
objfile->per_bfd = get_objfile_bfd_data (objfile, abfd);
objfile->pspace = current_program_space;
@ -1486,6 +1494,9 @@ default_iterate_over_objfiles_in_search_order
const char *
objfile_name (const struct objfile *objfile)
{
if (objfile->obfd != NULL)
return bfd_get_filename (objfile->obfd);
return objfile->original_name;
}