* bfd-target.c (target_bfd_reopen): Update.

* cli/cli-dump.c (bfd_openr_with_cleanup)
	(bfd_openw_with_cleanup): Update.
	* corelow.c (core_open): Update.
	* dsrec.c (load_srec): Update.
	* exec.c (exec_file_attach): Update.
	* gcore.c (create_gcore_bfd): Update.
	* gdb_bfd.c (gdb_bfd_ref): Return void.
	(gdb_bfd_open): Update.
	* gdb_bfd.h (gdb_bfd_ref): Return void.
	Update comments.
	* jit.c (jit_bfd_try_read_symtab): Update.
	* m32r-rom.c (m32r_load, m32r_upload_command): Update.
	* machoread.c (macho_symfile_read_all_oso): Update.
	(macho_check_dsym): Update.
	* procfs.c (insert_dbx_link_bpt_in_file): Update.
	* remote-m32r-sdi.c (m32r_load): Update.
	* remote-mips.c (mips_load_srec, pmon_load_fast): Update.
	* rs6000-nat.c (add_vmap): Update.
	* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
	Update.
	* solib-pa64.c (pa64_solib_create_inferior_hook): Update.
	* solib-spu.c (spu_bfd_open): Update.
	* solib.c (solib_bfd_fopen, solib_read_symbols): Update.
	* spu-linux-nat.c (spu_bfd_open): Update.
	* symfile.c (bfd_open_maybe_remote, symfile_bfd_open)
	(generic_load): Update.
	* windows-nat.c (windows_make_so): Update.
This commit is contained in:
Tom Tromey 2012-07-23 14:56:11 +00:00
parent d86492f2b7
commit 520b0001c1
23 changed files with 126 additions and 62 deletions

View File

@ -1,3 +1,34 @@
2012-07-23 Tom Tromey <tromey@redhat.com>
* bfd-target.c (target_bfd_reopen): Update.
* cli/cli-dump.c (bfd_openr_with_cleanup)
(bfd_openw_with_cleanup): Update.
* corelow.c (core_open): Update.
* dsrec.c (load_srec): Update.
* exec.c (exec_file_attach): Update.
* gcore.c (create_gcore_bfd): Update.
* gdb_bfd.c (gdb_bfd_ref): Return void.
(gdb_bfd_open): Update.
* gdb_bfd.h (gdb_bfd_ref): Return void.
Update comments.
* jit.c (jit_bfd_try_read_symtab): Update.
* m32r-rom.c (m32r_load, m32r_upload_command): Update.
* machoread.c (macho_symfile_read_all_oso): Update.
(macho_check_dsym): Update.
* procfs.c (insert_dbx_link_bpt_in_file): Update.
* remote-m32r-sdi.c (m32r_load): Update.
* remote-mips.c (mips_load_srec, pmon_load_fast): Update.
* rs6000-nat.c (add_vmap): Update.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Update.
* solib-pa64.c (pa64_solib_create_inferior_hook): Update.
* solib-spu.c (spu_bfd_open): Update.
* solib.c (solib_bfd_fopen, solib_read_symbols): Update.
* spu-linux-nat.c (spu_bfd_open): Update.
* symfile.c (bfd_open_maybe_remote, symfile_bfd_open)
(generic_load): Update.
* windows-nat.c (windows_make_so): Update.
2012-07-22 Siddhesh Poyarekar <siddhesh@redhat.com>
* sh-tdep.c (sh_treat_as_flt_p): Remove unused variable LEN.

View File

@ -84,7 +84,8 @@ target_bfd_reopen (struct bfd *abfd)
struct target_bfd_data *data;
data = XZALLOC (struct target_bfd_data);
data->bfd = gdb_bfd_ref (abfd);
data->bfd = abfd;
gdb_bfd_ref (abfd);
build_section_table (abfd, &data->table.sections, &data->table.sections_end);
t = XZALLOC (struct target_ops);

View File

@ -112,7 +112,8 @@ bfd_openr_with_cleanup (const char *filename, const char *target)
{
bfd *ibfd;
ibfd = gdb_bfd_ref (bfd_openr (filename, target));
ibfd = bfd_openr (filename, target);
gdb_bfd_ref (ibfd);
if (ibfd == NULL)
error (_("Failed to open %s: %s."), filename,
bfd_errmsg (bfd_get_error ()));
@ -132,7 +133,8 @@ bfd_openw_with_cleanup (const char *filename, const char *target,
if (*mode == 'w') /* Write: create new file */
{
obfd = gdb_bfd_ref (bfd_openw (filename, target));
obfd = bfd_openw (filename, target);
gdb_bfd_ref (obfd);
if (obfd == NULL)
error (_("Failed to open %s: %s."), filename,
bfd_errmsg (bfd_get_error ()));

View File

@ -318,9 +318,10 @@ core_open (char *filename, int from_tty)
if (scratch_chan < 0)
perror_with_name (filename);
temp_bfd = gdb_bfd_ref (bfd_fopen (filename, gnutarget,
write_files ? FOPEN_RUB : FOPEN_RB,
scratch_chan));
temp_bfd = bfd_fopen (filename, gnutarget,
write_files ? FOPEN_RUB : FOPEN_RB,
scratch_chan);
gdb_bfd_ref (temp_bfd);
if (temp_bfd == NULL)
perror_with_name (filename);

View File

@ -61,7 +61,8 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset,
srec = (char *) alloca (maxrecsize + 1);
abfd = gdb_bfd_ref (bfd_openr (file, 0));
abfd = bfd_openr (file, 0);
gdb_bfd_ref (abfd);
if (!abfd)
{
printf_filtered (_("Unable to open file %s\n"), file);

View File

@ -233,9 +233,10 @@ exec_file_attach (char *filename, int from_tty)
if (scratch_chan < 0)
perror_with_name (filename);
exec_bfd = gdb_bfd_ref (bfd_fopen (scratch_pathname, gnutarget,
write_files ? FOPEN_RUB : FOPEN_RB,
scratch_chan));
exec_bfd = bfd_fopen (scratch_pathname, gnutarget,
write_files ? FOPEN_RUB : FOPEN_RB,
scratch_chan);
gdb_bfd_ref (exec_bfd);
if (!exec_bfd)
{

View File

@ -51,8 +51,9 @@ static int gcore_memory_sections (bfd *);
bfd *
create_gcore_bfd (char *filename)
{
bfd *obfd = gdb_bfd_ref (bfd_openw (filename, default_gcore_target ()));
bfd *obfd = bfd_openw (filename, default_gcore_target ());
gdb_bfd_ref (obfd);
if (!obfd)
error (_("Failed to open '%s' for output."), filename);
gdb_bfd_stash_filename (obfd);

View File

@ -158,7 +158,8 @@ gdb_bfd_open (const char *name, const char *target, int fd)
if (abfd != NULL)
{
close (fd);
return gdb_bfd_ref (abfd);
gdb_bfd_ref (abfd);
return abfd;
}
abfd = bfd_fopen (name, target, FOPEN_RB, fd);
@ -170,7 +171,8 @@ gdb_bfd_open (const char *name, const char *target, int fd)
*slot = abfd;
gdb_bfd_stash_filename (abfd);
return gdb_bfd_ref (abfd);
gdb_bfd_ref (abfd);
return abfd;
}
/* A helper function that releases any section data attached to the
@ -218,28 +220,26 @@ gdb_bfd_close_or_warn (struct bfd *abfd)
/* Add reference to ABFD. Returns ABFD. */
struct bfd *
void
gdb_bfd_ref (struct bfd *abfd)
{
struct gdb_bfd_data *gdata;
if (abfd == NULL)
return NULL;
return;
gdata = bfd_usrdata (abfd);
if (gdata != NULL)
{
gdata->refc += 1;
return abfd;
return;
}
gdata = bfd_zalloc (abfd, sizeof (struct gdb_bfd_data));
gdata->refc = 1;
gdata->mtime = bfd_get_mtime (abfd);
bfd_usrdata (abfd) = gdata;
return abfd;
}
/* Unreference and possibly close ABFD. */

View File

@ -35,14 +35,14 @@ void gdb_bfd_stash_filename (struct bfd *abfd);
struct bfd *gdb_bfd_open (const char *name, const char *target, int fd);
/* Acquire a new reference to ABFD. Returns ABFD for convenience.
It is fine for ABFD to be NULL; in this case the function does
nothing and returns NULL. */
/* Increment the reference count of ABFD. It is fine for ABFD to be
NULL; in this case the function does nothing. */
struct bfd *gdb_bfd_ref (struct bfd *abfd);
void gdb_bfd_ref (struct bfd *abfd);
/* Release a reference to ABFD. If this is the last reference, ABFD
will be freed. If ABFD is NULL, this function does nothing. */
/* Decrement the reference count of ABFD. If this is the last
reference, ABFD will be freed. If ABFD is NULL, this function does
nothing. */
void gdb_bfd_unref (struct bfd *abfd);

View File

@ -861,7 +861,7 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
return;
}
nbfd = gdb_bfd_ref (nbfd);
gdb_bfd_ref (nbfd);
/* Check the format. NOTE: This initializes important data that GDB uses!
We would segfault later without this line. */

View File

@ -130,7 +130,8 @@ m32r_load (char *filename, int from_tty)
if (filename == NULL || filename[0] == 0)
filename = get_exec_file (1);
abfd = gdb_bfd_ref (bfd_openr (filename, 0));
abfd = bfd_openr (filename, 0);
gdb_bfd_ref (abfd);
if (!abfd)
error (_("Unable to open file %s."), filename);
cleanup = make_cleanup_bfd_unref (abfd);
@ -529,7 +530,8 @@ m32r_upload_command (char *args, int from_tty)
printf_filtered (" -- Ethernet load complete.\n");
gettimeofday (&end_time, NULL);
abfd = gdb_bfd_ref (bfd_openr (args, 0));
abfd = bfd_openr (args, 0);
gdb_bfd_ref (abfd);
cleanup = make_cleanup_bfd_unref (abfd);
if (abfd != NULL)
{ /* Download is done -- print section statistics. */

View File

@ -689,7 +689,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
}
/* Open the archive and check the format. */
archive_bfd = gdb_bfd_ref (bfd_openr (archive_name, gnutarget));
archive_bfd = bfd_openr (archive_name, gnutarget);
gdb_bfd_ref (archive_bfd);
if (archive_bfd == NULL)
{
warning (_("Could not open OSO archive file \"%s\""),
@ -708,8 +709,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
gdb_bfd_stash_filename (archive_bfd);
member_bfd = gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd,
NULL));
member_bfd = bfd_openr_next_archived_file (archive_bfd, NULL);
gdb_bfd_ref (member_bfd);
if (member_bfd == NULL)
{
@ -745,9 +746,9 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
}
prev = member_bfd;
member_bfd
= gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd,
member_bfd));
member_bfd = bfd_openr_next_archived_file (archive_bfd,
member_bfd);
gdb_bfd_ref (member_bfd);
/* Free previous member if not referenced by an oso. */
if (ix2 >= last_ix)
@ -767,7 +768,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
{
bfd *abfd;
abfd = gdb_bfd_ref (bfd_openr (oso->name, gnutarget));
abfd = bfd_openr (oso->name, gnutarget);
gdb_bfd_ref (abfd);
if (!abfd)
warning (_("`%s': can't open to read symbols: %s."), oso->name,
bfd_errmsg (bfd_get_error ()));
@ -817,7 +819,8 @@ macho_check_dsym (struct objfile *objfile)
warning (_("can't find UUID in %s"), objfile->name);
return NULL;
}
dsym_bfd = gdb_bfd_ref (bfd_openr (dsym_filename, gnutarget));
dsym_bfd = bfd_openr (dsym_filename, gnutarget);
gdb_bfd_ref (dsym_bfd);
if (dsym_bfd == NULL)
{
warning (_("can't open dsym file %s"), dsym_filename);

View File

@ -3486,7 +3486,8 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored)
long storage_needed;
CORE_ADDR sym_addr;
abfd = gdb_bfd_ref (bfd_fdopenr ("unamed", 0, fd));
abfd = bfd_fdopenr ("unamed", 0, fd);
gdb_bfd_ref (abfd);
if (abfd == NULL)
{
warning (_("Failed to create a bfd: %s."), bfd_errmsg (bfd_get_error ()));

View File

@ -1258,7 +1258,8 @@ m32r_load (char *args, int from_tty)
if (!filename)
filename = get_exec_file (1);
pbfd = gdb_bfd_ref (bfd_openr (filename, gnutarget));
pbfd = bfd_openr (filename, gnutarget);
gdb_bfd_ref (pbfd);
if (pbfd == NULL)
{
perror_with_name (filename);

View File

@ -2789,7 +2789,8 @@ mips_load_srec (char *args)
buffer = alloca (srec_frame * 2 + 256);
abfd = gdb_bfd_ref (bfd_openr (args, 0));
abfd = bfd_openr (args, 0);
gdb_bfd_ref (abfd);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", args);
@ -3376,7 +3377,8 @@ pmon_load_fast (char *file)
buffer = (char *) xmalloc (MAXRECSIZE + 1);
binbuf = (unsigned char *) xmalloc (BINCHUNK);
abfd = gdb_bfd_ref (bfd_openr (file, 0));
abfd = bfd_openr (file, 0);
gdb_bfd_ref (abfd);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", file);

View File

@ -751,7 +751,7 @@ add_vmap (LdInfo *ldi)
abfd = bfd_openr (filename, gnutarget);
else
abfd = bfd_fdopenr (filename, gnutarget, fd);
abfd = gdb_bfd_ref (abfd);
gdb_bfd_ref (abfd);
if (!abfd)
{
warning (_("Could not open `%s' as an executable file: %s"),
@ -769,9 +769,12 @@ add_vmap (LdInfo *ldi)
{
last = 0;
/* FIXME??? am I tossing BFDs? bfd? */
while ((last = gdb_bfd_ref (bfd_openr_next_archived_file (abfd, last))))
if (strcmp (mem, last->filename) == 0)
break;
while ((last = bfd_openr_next_archived_file (abfd, last)))
{
gdb_bfd_ref (last);
if (strcmp (mem, last->filename) == 0)
break;
}
if (!last)
{
@ -798,7 +801,8 @@ add_vmap (LdInfo *ldi)
gdb_bfd_unref (abfd);
return NULL;
}
obj = allocate_objfile (gdb_bfd_ref (vp->bfd), 0);
gdb_bfd_ref (vp->bfd);
obj = allocate_objfile (vp->bfd, 0);
vp->objfile = obj;
/* Always add symbols for the main objfile. */

View File

@ -371,7 +371,8 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
cleanup = make_cleanup (null_cleanup, NULL);
/* Create a bfd for the interpreter. */
dyld_bfd = gdb_bfd_ref (bfd_openr (interp_name, gnutarget));
dyld_bfd = bfd_openr (interp_name, gnutarget);
gdb_bfd_ref (dyld_bfd);
if (dyld_bfd)
{
bfd *sub;
@ -381,7 +382,8 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
gdbarch_bfd_arch_info (target_gdbarch));
if (sub)
{
dyld_bfd = gdb_bfd_ref (sub);
dyld_bfd = sub;
gdb_bfd_ref (sub);
make_cleanup_bfd_unref (sub);
}
else

View File

@ -362,7 +362,8 @@ manpage for methods to privately map shared library text."));
to find any magic formula to find it for Solaris (appears to
be trivial on GNU/Linux). Therefore, we have to try an alternate
mechanism to find the dynamic linker's base address. */
tmp_bfd = gdb_bfd_ref (bfd_openr (buf, gnutarget));
tmp_bfd = bfd_openr (buf, gnutarget);
gdb_bfd_ref (tmp_bfd);
if (tmp_bfd == NULL)
return;

View File

@ -326,10 +326,11 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
CORE_ADDR *open_closure = xmalloc (sizeof (CORE_ADDR));
*open_closure = addr;
nbfd = gdb_bfd_ref (bfd_openr_iovec (name, "elf32-spu",
spu_bfd_iovec_open, open_closure,
spu_bfd_iovec_pread, spu_bfd_iovec_close,
spu_bfd_iovec_stat));
nbfd = bfd_openr_iovec (name, "elf32-spu",
spu_bfd_iovec_open, open_closure,
spu_bfd_iovec_pread, spu_bfd_iovec_close,
spu_bfd_iovec_stat);
gdb_bfd_ref (nbfd);
if (!nbfd)
return NULL;

View File

@ -393,7 +393,8 @@ solib_bfd_fopen (char *pathname, int fd)
gdb_bfd_stash_filename (abfd);
xfree (pathname);
return gdb_bfd_ref (abfd);
gdb_bfd_ref (abfd);
return abfd;
}
/* Find shared library PATHNAME and open a BFD for it. */
@ -611,7 +612,8 @@ solib_read_symbols (struct so_list *so, int flags)
sap = build_section_addr_info_from_section_table (so->sections,
so->sections_end);
so->objfile = symbol_file_add_from_bfd (gdb_bfd_ref (so->abfd),
gdb_bfd_ref (so->abfd);
so->objfile = symbol_file_add_from_bfd (so->abfd,
flags, sap, OBJF_SHARED,
NULL);
so->objfile->addr_low = so->addr_low;

View File

@ -321,7 +321,7 @@ spu_bfd_open (ULONGEST addr)
spu_bfd_iovec_stat);
if (!nbfd)
return NULL;
nbfd = gdb_bfd_ref (nbfd);
gdb_bfd_ref (nbfd);
if (!bfd_check_format (nbfd, bfd_object))
{

View File

@ -1697,16 +1697,19 @@ set_initial_language (void)
bfd *
bfd_open_maybe_remote (const char *name)
{
bfd *result;
if (remote_filename_p (name))
return gdb_bfd_ref (remote_bfd_open (name, gnutarget));
result = remote_bfd_open (name, gnutarget);
else
{
bfd *result = gdb_bfd_ref (bfd_openr (name, gnutarget));
result = bfd_openr (name, gnutarget);
if (result != NULL)
gdb_bfd_stash_filename (result);
return result;
}
gdb_bfd_ref (result);
return result;
}
@ -1724,7 +1727,8 @@ symfile_bfd_open (char *name)
if (remote_filename_p (name))
{
sym_bfd = gdb_bfd_ref (remote_bfd_open (name, gnutarget));
sym_bfd = remote_bfd_open (name, gnutarget);
gdb_bfd_ref (sym_bfd);
if (!sym_bfd)
error (_("`%s': can't open to read symbols: %s."), name,
bfd_errmsg (bfd_get_error ()));
@ -1764,7 +1768,8 @@ symfile_bfd_open (char *name)
name = absolute_name;
make_cleanup (xfree, name);
sym_bfd = gdb_bfd_ref (bfd_fopen (name, gnutarget, FOPEN_RB, desc));
sym_bfd = bfd_fopen (name, gnutarget, FOPEN_RB, desc);
gdb_bfd_ref (sym_bfd);
if (!sym_bfd)
{
make_cleanup (xfree, name);
@ -2106,7 +2111,8 @@ generic_load (char *args, int from_tty)
}
/* Open the file for loading. */
loadfile_bfd = gdb_bfd_ref (bfd_openr (filename, gnutarget));
loadfile_bfd = bfd_openr (filename, gnutarget);
gdb_bfd_ref (loadfile_bfd);
if (loadfile_bfd == NULL)
{
perror_with_name (filename);

View File

@ -752,7 +752,8 @@ windows_make_so (const char *name, LPVOID load_addr)
asection *text = NULL;
CORE_ADDR text_vma;
abfd = gdb_bfd_ref (bfd_openr (so->so_name, "pei-i386"));
abfd = bfd_openr (so->so_name, "pei-i386");
gdb_bfd_ref (abfd);
if (!abfd)
return so;