diff options
author | Tom Tromey <tromey@redhat.com> | 2012-07-18 19:33:34 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-07-18 19:33:34 +0000 |
commit | cbb099e88685f8aa80b9a958ba35988d8dbb8721 (patch) | |
tree | 67610bb717b6f48e0a3dbf9c6779da252c96177a /gdb/symfile.c | |
parent | ed1d1739a1e3efdf177aaaee0c096a27a10e6284 (diff) | |
download | gdb-cbb099e88685f8aa80b9a958ba35988d8dbb8721.zip gdb-cbb099e88685f8aa80b9a958ba35988d8dbb8721.tar.gz gdb-cbb099e88685f8aa80b9a958ba35988d8dbb8721.tar.bz2 |
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r-- | gdb/symfile.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c index 01252e2..2ad72c5 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -55,6 +55,7 @@ #include "solib.h" #include "remote.h" #include "stack.h" +#include "gdb_bfd.h" #include <sys/types.h> #include <fcntl.h> @@ -1372,7 +1373,7 @@ separate_debug_file_exists (const char *name, unsigned long crc, if (abfd_stat.st_dev == parent_stat.st_dev && abfd_stat.st_ino == parent_stat.st_ino) { - bfd_close (abfd); + gdb_bfd_unref (abfd); return 0; } verified_as_different = 1; @@ -1382,7 +1383,7 @@ separate_debug_file_exists (const char *name, unsigned long crc, file_crc_p = get_file_crc (abfd, &file_crc); - bfd_close (abfd); + gdb_bfd_unref (abfd); if (!file_crc_p) return 0; @@ -1690,15 +1691,16 @@ set_initial_language (void) } /* If NAME is a remote name open the file using remote protocol, otherwise - open it normally. */ + open it normally. Returns a new reference to the BFD. On error, + returns NULL with the BFD error set. */ bfd * bfd_open_maybe_remote (const char *name) { if (remote_filename_p (name)) - return remote_bfd_open (name, gnutarget); + return gdb_bfd_ref (remote_bfd_open (name, gnutarget)); else - return bfd_openr (name, gnutarget); + return gdb_bfd_ref (bfd_openr (name, gnutarget)); } @@ -1717,7 +1719,7 @@ symfile_bfd_open (char *name) if (remote_filename_p (name)) { name = xstrdup (name); - sym_bfd = remote_bfd_open (name, gnutarget); + sym_bfd = gdb_bfd_ref (remote_bfd_open (name, gnutarget)); if (!sym_bfd) { make_cleanup (xfree, name); @@ -1727,7 +1729,7 @@ symfile_bfd_open (char *name) if (!bfd_check_format (sym_bfd, bfd_object)) { - bfd_close (sym_bfd); + gdb_bfd_unref (sym_bfd); make_cleanup (xfree, name); error (_("`%s': can't read symbols: %s."), name, bfd_errmsg (bfd_get_error ())); @@ -1762,7 +1764,7 @@ symfile_bfd_open (char *name) xfree (name); name = absolute_name; - sym_bfd = bfd_fopen (name, gnutarget, FOPEN_RB, desc); + sym_bfd = gdb_bfd_ref (bfd_fopen (name, gnutarget, FOPEN_RB, desc)); if (!sym_bfd) { make_cleanup (xfree, name); @@ -1773,18 +1775,12 @@ symfile_bfd_open (char *name) if (!bfd_check_format (sym_bfd, bfd_object)) { - /* FIXME: should be checking for errors from bfd_close (for one - thing, on error it does not free all the storage associated - with the bfd). */ - bfd_close (sym_bfd); /* This also closes desc. */ + make_cleanup_bfd_close (sym_bfd); make_cleanup (xfree, name); error (_("`%s': can't read symbols: %s."), name, bfd_errmsg (bfd_get_error ())); } - /* bfd_usrdata exists for applications and libbfd must not touch it. */ - gdb_assert (bfd_usrdata (sym_bfd) == NULL); - return sym_bfd; } @@ -2109,16 +2105,13 @@ generic_load (char *args, int from_tty) } /* Open the file for loading. */ - loadfile_bfd = bfd_openr (filename, gnutarget); + loadfile_bfd = gdb_bfd_ref (bfd_openr (filename, gnutarget)); if (loadfile_bfd == NULL) { perror_with_name (filename); return; } - /* FIXME: should be checking for errors from bfd_close (for one thing, - on error it does not free all the storage associated with the - bfd). */ make_cleanup_bfd_close (loadfile_bfd); if (!bfd_check_format (loadfile_bfd, bfd_object)) @@ -2519,14 +2512,10 @@ reread_symbols (void) to close the descriptor but BFD lacks a way of closing the BFD without closing the descriptor. */ obfd_filename = bfd_get_filename (objfile->obfd); - if (!bfd_close (objfile->obfd)) - error (_("Can't close BFD for %s: %s"), objfile->name, - bfd_errmsg (bfd_get_error ())); + gdb_bfd_unref (objfile->obfd); objfile->obfd = bfd_open_maybe_remote (obfd_filename); if (objfile->obfd == NULL) error (_("Can't open %s to read symbols."), objfile->name); - else - objfile->obfd = gdb_bfd_ref (objfile->obfd); /* bfd_openr sets cacheable to true, which is what we want. */ if (!bfd_check_format (objfile->obfd, bfd_object)) error (_("Can't read symbols from %s: %s."), objfile->name, |