* symfile.c (symfile_bfd_open): Don't copy name. Call

gdb_bfd_stash_filename.
	(load_command): Open the new BFD before freeing the old.
	(bfd_open_maybe_remote): Call gdb_bfd_stash_filename.
	* symfile-mem.c (symbol_file_add_from_memory): Don't copy name.
	Call gdb_bfd_stash_filename.
	* spu-linux-nat.c (spu_bfd_open): Don't copy name.
	* solib-spu.c (spu_bfd_fopen): Don't copy name.  Call
	gdb_bfd_stash_filename.
	* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
	Free found_pathname.
	* rs6000-nat.c (add_vmap): Don't copy filename.  Call
	gdb_bfd_stash_filename.
	* remote.c (remote_bfd_open): Call gdb_bfd_stash_filename.
	* machoread.c (macho_add_oso_symfile): Call
	gdb_bfd_stash_filename.
	(macho_symfile_read_all_oso): Arrange to free archive_name.  Call
	gdb_bfd_stash_filename.
	(macho_check_dsym): Don't copy filename.  Call
	gdb_bfd_stash_filename.
	* jit.c (bfd_open_from_target_memory): Don't copy the filename.
	* gdb_bfd.c (gdb_bfd_stash_filename): New function.
	* gdb_bfd.h (gdb_bfd_stash_filename): Declare.
	* gcore.c (create_gcore_bfd): Call gdb_bfd_stash_filename.
	* exec.c (exec_close): Don't free the BFD's filename.
	(exec_file_attach): Don't copy the filename.  Call
	gdb_bfd_stash_filename.
	* corelow.c (core_close): Don't free the BFD's filename.
	(core_open): Call gdb_bfd_stash_filename.
	* corefile.c (reopen_exec_file): Remove #if 0 code.
	* solib.c (solib_bfd_fopen): Call gdb_bfd_stash_filename.  Free
	pathname.
	* dwarf2read.c (try_open_dwo_file): Call gdb_bfd_stash_filename.
This commit is contained in:
Tom Tromey
2012-07-18 19:34:57 +00:00
parent cbb099e886
commit a4453b7e0b
17 changed files with 143 additions and 72 deletions

View File

@@ -730,7 +730,7 @@ static struct vmap *
add_vmap (LdInfo *ldi)
{
bfd *abfd, *last;
char *mem, *objname, *filename;
char *mem, *filename;
struct objfile *obj;
struct vmap *vp;
int fd;
@@ -743,22 +743,22 @@ add_vmap (LdInfo *ldi)
filename = LDI_FILENAME (ldi, arch64);
mem = filename + strlen (filename) + 1;
mem = xstrdup (mem);
objname = xstrdup (filename);
fd = LDI_FD (ldi, arch64);
if (fd < 0)
/* Note that this opens it once for every member; a possible
enhancement would be to only open it once for every object. */
abfd = bfd_openr (objname, gnutarget);
abfd = bfd_openr (filename, gnutarget);
else
abfd = bfd_fdopenr (objname, gnutarget, fd);
abfd = bfd_fdopenr (filename, gnutarget, fd);
abfd = gdb_bfd_ref (abfd);
if (!abfd)
{
warning (_("Could not open `%s' as an executable file: %s"),
objname, bfd_errmsg (bfd_get_error ()));
filename, bfd_errmsg (bfd_get_error ()));
return NULL;
}
gdb_bfd_stash_filename (abfd);
/* Make sure we have an object file. */
@@ -775,7 +775,7 @@ add_vmap (LdInfo *ldi)
if (!last)
{
warning (_("\"%s\": member \"%s\" missing."), objname, mem);
warning (_("\"%s\": member \"%s\" missing."), filename, mem);
gdb_bfd_unref (abfd);
return NULL;
}
@@ -783,7 +783,7 @@ add_vmap (LdInfo *ldi)
if (!bfd_check_format (last, bfd_object))
{
warning (_("\"%s\": member \"%s\" not in executable format: %s."),
objname, mem, bfd_errmsg (bfd_get_error ()));
filename, mem, bfd_errmsg (bfd_get_error ()));
gdb_bfd_unref (last);
gdb_bfd_unref (abfd);
return NULL;
@@ -794,7 +794,7 @@ add_vmap (LdInfo *ldi)
else
{
warning (_("\"%s\": not in executable format: %s."),
objname, bfd_errmsg (bfd_get_error ()));
filename, bfd_errmsg (bfd_get_error ()));
gdb_bfd_unref (abfd);
return NULL;
}