* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
authorTom Tromey <tromey@redhat.com>
Mon, 23 Jul 2012 14:57:58 +0000 (14:57 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 23 Jul 2012 14:57:58 +0000 (14:57 +0000)
(bfd_openw_with_cleanup): Use gdb_bfd_openw.
* corelow.c (core_open): Use gdb_bfd_fopen.
* dsrec.c (load_srec): Use gdb_bfd_openr.
* exec.c (exec_file_attach): Use gdb_bfd_fopen.
* gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
* gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): New functions.
* gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): Declare.
* jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
* m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
* machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
gdb_bfd_openr_next_archived_file.
(macho_check_dsym): Use gdb_bfd_openr.
(macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
* remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
* remote-mips.c (mips_load_srec, pmon_load_fast): Use
gdb_bfd_openr.
* remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
* rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
gdb_bfd_openr_next_archived_file.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Use gdb_bfd_openr.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use
gdb_bfd_openr.
* solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
* solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
(symfile_bfd_open): Use gdb_bfd_fopen.
(generic_load): Use gdb_bfd_openr.
* windows-nat.c (windows_make_so): Use gdb_bfd_openr.

23 files changed:
gdb/ChangeLog
gdb/cli/cli-dump.c
gdb/corelow.c
gdb/dsrec.c
gdb/exec.c
gdb/gcore.c
gdb/gdb_bfd.c
gdb/gdb_bfd.h
gdb/jit.c
gdb/m32r-rom.c
gdb/machoread.c
gdb/procfs.c
gdb/remote-m32r-sdi.c
gdb/remote-mips.c
gdb/remote.c
gdb/rs6000-nat.c
gdb/solib-darwin.c
gdb/solib-pa64.c
gdb/solib-spu.c
gdb/solib.c
gdb/spu-linux-nat.c
gdb/symfile.c
gdb/windows-nat.c

index 6cf1b524cdff9931f57b01f809c07969672de9d9..9b96acf65a0d3ccf1f7e6e23619e78024c4ce6a6 100644 (file)
@@ -1,3 +1,42 @@
+2012-07-23  Tom Tromey  <tromey@redhat.com>
+
+       * cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
+       (bfd_openw_with_cleanup): Use gdb_bfd_openw.
+       * corelow.c (core_open): Use gdb_bfd_fopen.
+       * dsrec.c (load_srec): Use gdb_bfd_openr.
+       * exec.c (exec_file_attach): Use gdb_bfd_fopen.
+       * gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
+       * gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
+       (gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
+       (gdb_bfd_fdopenr): New functions.
+       * gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
+       (gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
+       (gdb_bfd_fdopenr): Declare.
+       * jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
+       * m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
+       * machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
+       gdb_bfd_openr_next_archived_file.
+       (macho_check_dsym): Use gdb_bfd_openr.
+       (macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
+       * procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
+       * remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
+       * remote-mips.c (mips_load_srec, pmon_load_fast): Use
+       gdb_bfd_openr.
+       * remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
+       * rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
+       gdb_bfd_openr_next_archived_file.
+       * solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
+       Use gdb_bfd_openr.
+       * solib-pa64.c (pa64_solib_create_inferior_hook): Use
+       gdb_bfd_openr.
+       * solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
+       * solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
+       * spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
+       * symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
+       (symfile_bfd_open): Use gdb_bfd_fopen.
+       (generic_load): Use gdb_bfd_openr.
+       * windows-nat.c (windows_make_so): Use gdb_bfd_openr.
+
 2012-07-23  Tom Tromey  <tromey@redhat.com>
 
        * bfd-target.c (target_bfd_reopen): Update.
index 5998b3f0f50865fa45c6f167e3efa0828cc8ab2c..7341f0029ef8dcd896bd98fe7cf3985ac3cc02b7 100644 (file)
@@ -112,8 +112,7 @@ bfd_openr_with_cleanup (const char *filename, const char *target)
 {
   bfd *ibfd;
 
-  ibfd = bfd_openr (filename, target);
-  gdb_bfd_ref (ibfd);
+  ibfd = gdb_bfd_openr (filename, target);
   if (ibfd == NULL)
     error (_("Failed to open %s: %s."), filename, 
           bfd_errmsg (bfd_get_error ()));
@@ -133,8 +132,7 @@ bfd_openw_with_cleanup (const char *filename, const char *target,
 
   if (*mode == 'w')    /* Write: create new file */
     {
-      obfd = bfd_openw (filename, target);
-      gdb_bfd_ref (obfd);
+      obfd = gdb_bfd_openw (filename, target);
       if (obfd == NULL)
        error (_("Failed to open %s: %s."), filename, 
               bfd_errmsg (bfd_get_error ()));
index 529e3e24ec3477ffeefc879314eb983ec5cf9d0d..340b149c2e81b873b2e02a9b3196cdca55e81c58 100644 (file)
@@ -318,15 +318,12 @@ core_open (char *filename, int from_tty)
   if (scratch_chan < 0)
     perror_with_name (filename);
 
-  temp_bfd = bfd_fopen (filename, gnutarget, 
-                       write_files ? FOPEN_RUB : FOPEN_RB,
-                       scratch_chan);
-  gdb_bfd_ref (temp_bfd);
+  temp_bfd = gdb_bfd_fopen (filename, gnutarget, 
+                           write_files ? FOPEN_RUB : FOPEN_RB,
+                           scratch_chan);
   if (temp_bfd == NULL)
     perror_with_name (filename);
 
-  gdb_bfd_stash_filename (temp_bfd);
-
   if (!bfd_check_format (temp_bfd, bfd_core)
       && !gdb_check_format (temp_bfd))
     {
index 8cca3610937145e7c0e685d5da3a7aa5afd5cd6a..f39d0ed5f392ca66d5e3c065bdf25747da9feb49 100644 (file)
@@ -61,8 +61,7 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset,
 
   srec = (char *) alloca (maxrecsize + 1);
 
-  abfd = bfd_openr (file, 0);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_openr (file, 0);
   if (!abfd)
     {
       printf_filtered (_("Unable to open file %s\n"), file);
index dc9258a6544c966ac6934df544a00b76479eca6a..9b95e028ea4216ad688391480465cd9fc58b6d95 100644 (file)
@@ -233,10 +233,9 @@ exec_file_attach (char *filename, int from_tty)
 
       if (scratch_chan < 0)
        perror_with_name (filename);
-      exec_bfd = bfd_fopen (scratch_pathname, gnutarget,
-                           write_files ? FOPEN_RUB : FOPEN_RB,
-                           scratch_chan);
-      gdb_bfd_ref (exec_bfd);
+      exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget,
+                               write_files ? FOPEN_RUB : FOPEN_RB,
+                               scratch_chan);
 
       if (!exec_bfd)
        {
@@ -254,8 +253,6 @@ exec_file_attach (char *filename, int from_tty)
                 gdb_bfd_errmsg (bfd_get_error (), matching));
        }
 
-      gdb_bfd_stash_filename (exec_bfd);
-
       /* FIXME - This should only be run for RS6000, but the ifdef is a poor
          way to accomplish.  */
 #ifdef DEPRECATED_IBM6000_TARGET
index 14432895565c1b02d7980f92d1b3b2dfa3effb85..a45e78773919a177922d21113976ca91fff89f7a 100644 (file)
@@ -51,12 +51,10 @@ static int gcore_memory_sections (bfd *);
 bfd *
 create_gcore_bfd (char *filename)
 {
-  bfd *obfd = bfd_openw (filename, default_gcore_target ());
+  bfd *obfd = gdb_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);
   bfd_set_format (obfd, bfd_core);
   bfd_set_arch_mach (obfd, default_gcore_arch (), default_gcore_mach ());
   return obfd;
index dd6eac38a52ee6c012b9a559d8c4ca4834097b38..095d0f34e255d43ff6b871ee97d1d7a270d056a0 100644 (file)
@@ -481,3 +481,117 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
   *size = descriptor->size;
   return descriptor->data;
 }
+
+\f
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_fopen (const char *filename, const char *target, const char *mode,
+              int fd)
+{
+  bfd *result = bfd_fopen (filename, target, mode, fd);
+
+  if (result)
+    {
+      gdb_bfd_stash_filename (result);
+      gdb_bfd_ref (result);
+    }
+
+  return result;
+}
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_openr (const char *filename, const char *target)
+{
+  bfd *result = bfd_openr (filename, target);
+
+  if (result)
+    {
+      gdb_bfd_stash_filename (result);
+      gdb_bfd_ref (result);
+    }
+
+  return result;
+}
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_openw (const char *filename, const char *target)
+{
+  bfd *result = bfd_openw (filename, target);
+
+  if (result)
+    {
+      gdb_bfd_stash_filename (result);
+      gdb_bfd_ref (result);
+    }
+
+  return result;
+}
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_openr_iovec (const char *filename, const char *target,
+                    void *(*open_func) (struct bfd *nbfd,
+                                        void *open_closure),
+                    void *open_closure,
+                    file_ptr (*pread_func) (struct bfd *nbfd,
+                                            void *stream,
+                                            void *buf,
+                                            file_ptr nbytes,
+                                            file_ptr offset),
+                    int (*close_func) (struct bfd *nbfd,
+                                       void *stream),
+                    int (*stat_func) (struct bfd *abfd,
+                                      void *stream,
+                                      struct stat *sb))
+{
+  bfd *result = bfd_openr_iovec (filename, target,
+                                open_func, open_closure,
+                                pread_func, close_func, stat_func);
+
+  if (result)
+    {
+      gdb_bfd_ref (result);
+      gdb_bfd_stash_filename (result);
+    }
+
+  return result;
+}
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous)
+{
+  bfd *result = bfd_openr_next_archived_file (archive, previous);
+
+  if (result)
+    {
+      gdb_bfd_ref (result);
+      /* No need to stash the filename here.  */
+    }
+
+  return result;
+}
+
+/* See gdb_bfd.h.  */
+
+bfd *
+gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
+{
+  bfd *result = bfd_fdopenr (filename, target, fd);
+
+  if (result)
+    {
+      gdb_bfd_ref (result);
+      gdb_bfd_stash_filename (result);
+    }
+
+  return result;
+}
index f5b6103e2fcd3a62863c11bf2b2d3fffebdbbaeb..f131ba777192427ad8cef9a33ad6d412e60aed45 100644 (file)
@@ -58,4 +58,49 @@ void gdb_bfd_unref (struct bfd *abfd);
 
 const gdb_byte *gdb_bfd_map_section (asection *section, bfd_size_type *size);
 
+\f
+
+/* A wrapper for bfd_fopen that initializes the gdb-specific reference
+   count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_fopen (const char *, const char *, const char *, int);
+
+/* A wrapper for bfd_openr that initializes the gdb-specific reference
+   count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_openr (const char *, const char *);
+
+/* A wrapper for bfd_openw that initializes the gdb-specific reference
+   count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_openw (const char *, const char *);
+
+/* A wrapper for bfd_openr_iovec that initializes the gdb-specific
+   reference count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_openr_iovec (const char *filename, const char *target,
+                         void *(*open_func) (struct bfd *nbfd,
+                                             void *open_closure),
+                         void *open_closure,
+                         file_ptr (*pread_func) (struct bfd *nbfd,
+                                                 void *stream,
+                                                 void *buf,
+                                                 file_ptr nbytes,
+                                                 file_ptr offset),
+                         int (*close_func) (struct bfd *nbfd,
+                                            void *stream),
+                         int (*stat_func) (struct bfd *abfd,
+                                           void *stream,
+                                           struct stat *sb));
+
+/* A wrapper for bfd_openr_next_archived_file that initializes the
+   gdb-specific reference count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous);
+
+/* A wrapper for bfd_fdopenr that initializes the gdb-specific
+   reference count and calls gdb_bfd_stash_filename.  */
+
+bfd *gdb_bfd_fdopenr (const char *filename, const char *target, int fd);
+
 #endif /* GDB_BFD_H */
index 34b77774856802037995256b6f6d8d54c2cb641c..410b94d8610c389001ab7dfb9c2058f840eac161 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -137,12 +137,12 @@ bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, char *target)
 
   buffer->base = addr;
   buffer->size = size;
-  return bfd_openr_iovec ("<in-memory>", target,
-                          mem_bfd_iovec_open,
-                          buffer,
-                          mem_bfd_iovec_pread,
-                          mem_bfd_iovec_close,
-                          mem_bfd_iovec_stat);
+  return gdb_bfd_openr_iovec ("<in-memory>", target,
+                             mem_bfd_iovec_open,
+                             buffer,
+                             mem_bfd_iovec_pread,
+                             mem_bfd_iovec_close,
+                             mem_bfd_iovec_stat);
 }
 
 /* One reader that has been loaded successfully, and can potentially be used to
@@ -861,7 +861,6 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
       puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
       return;
     }
-  gdb_bfd_ref (nbfd);
 
   /* Check the format.  NOTE: This initializes important data that GDB uses!
      We would segfault later without this line.  */
index 5678f13dc3bce8763890b185e96c0abe061f418d..9a2f5aa555f7fcaa383a58f08616f60b87430df1 100644 (file)
@@ -130,8 +130,7 @@ m32r_load (char *filename, int from_tty)
   if (filename == NULL || filename[0] == 0)
     filename = get_exec_file (1);
 
-  abfd = bfd_openr (filename, 0);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_openr (filename, 0);
   if (!abfd)
     error (_("Unable to open file %s."), filename);
   cleanup = make_cleanup_bfd_unref (abfd);
@@ -530,8 +529,7 @@ m32r_upload_command (char *args, int from_tty)
     printf_filtered (" -- Ethernet load complete.\n");
 
   gettimeofday (&end_time, NULL);
-  abfd = bfd_openr (args, 0);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_openr (args, 0);
   cleanup = make_cleanup_bfd_unref (abfd);
   if (abfd != NULL)
     {          /* Download is done -- print section statistics.  */
index 8ecd4c59ebc59dcc6c9ecf1efcfdf9e8c94e6e60..5b9e2ba4f64fb18fa0ca75464462db89d0439b2a 100644 (file)
@@ -629,11 +629,6 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
 
   bfd_hash_table_free (&table);
 
-  /* Make sure that the filename has the correct lifetime.  The
-     current filename comes either from an OSO symbol name or from an
-     archive name.  Memory for both is not managed by gdb.  */
-  gdb_bfd_stash_filename (abfd);
-
   /* We need to clear SYMFILE_MAINLINE to avoid interractive question
      from symfile.c:symbol_file_add_with_addrs_or_offsets.  */
   symbol_file_add_from_bfd
@@ -689,8 +684,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
             }
 
          /* Open the archive and check the format.  */
-         archive_bfd = bfd_openr (archive_name, gnutarget);
-         gdb_bfd_ref (archive_bfd);
+         archive_bfd = gdb_bfd_openr (archive_name, gnutarget);
          if (archive_bfd == NULL)
            {
              warning (_("Could not open OSO archive file \"%s\""),
@@ -707,10 +701,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
              continue;
            }
 
-         gdb_bfd_stash_filename (archive_bfd);
-
-         member_bfd = bfd_openr_next_archived_file (archive_bfd, NULL);
-         gdb_bfd_ref (member_bfd);
+         member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd, NULL);
 
          if (member_bfd == NULL)
            {
@@ -746,9 +737,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
                 }
 
               prev = member_bfd;
-             member_bfd = bfd_openr_next_archived_file (archive_bfd,
-                                                        member_bfd);
-             gdb_bfd_ref (member_bfd);
+             member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd,
+                                                            member_bfd);
 
               /* Free previous member if not referenced by an oso.  */
               if (ix2 >= last_ix)
@@ -768,8 +758,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
        {
           bfd *abfd;
 
-         abfd = bfd_openr (oso->name, gnutarget);
-         gdb_bfd_ref (abfd);
+         abfd = gdb_bfd_openr (oso->name, gnutarget);
          if (!abfd)
             warning (_("`%s': can't open to read symbols: %s."), oso->name,
                      bfd_errmsg (bfd_get_error ()));
@@ -819,14 +808,12 @@ macho_check_dsym (struct objfile *objfile)
       warning (_("can't find UUID in %s"), objfile->name);
       return NULL;
     }
-  dsym_bfd = bfd_openr (dsym_filename, gnutarget);
-  gdb_bfd_ref (dsym_bfd);
+  dsym_bfd = gdb_bfd_openr (dsym_filename, gnutarget);
   if (dsym_bfd == NULL)
     {
       warning (_("can't open dsym file %s"), dsym_filename);
       return NULL;
     }
-  gdb_bfd_stash_filename (dsym_filename);
 
   if (!bfd_check_format (dsym_bfd, bfd_object))
     {
index 3df825448c3601741bbcca899d6dcdacab99470a..4409e5bfb0c0095241acdcbb78726deda3f84b97 100644 (file)
@@ -3486,8 +3486,7 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored)
   long storage_needed;
   CORE_ADDR sym_addr;
 
-  abfd = bfd_fdopenr ("unamed", 0, fd);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_fdopenr ("unamed", 0, fd);
   if (abfd == NULL)
     {
       warning (_("Failed to create a bfd: %s."), bfd_errmsg (bfd_get_error ()));
index f0c7cba2a7efdac6a43fa9c86cb8d1d1aadde116..85268b6ab1caaab008efb95712070d7fb0d1290e 100644 (file)
@@ -1258,8 +1258,7 @@ m32r_load (char *args, int from_tty)
   if (!filename)
     filename = get_exec_file (1);
 
-  pbfd = bfd_openr (filename, gnutarget);
-  gdb_bfd_ref (pbfd);
+  pbfd = gdb_bfd_openr (filename, gnutarget);
   if (pbfd == NULL)
     {
       perror_with_name (filename);
index 2c8b92e3fe6b93b9524c94da16f6c28f8967b994..db4381b653003326822e31c8570bfa241b58874f 100644 (file)
@@ -2789,8 +2789,7 @@ mips_load_srec (char *args)
 
   buffer = alloca (srec_frame * 2 + 256);
 
-  abfd = bfd_openr (args, 0);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_openr (args, 0);
   if (!abfd)
     {
       printf_filtered ("Unable to open file %s\n", args);
@@ -3377,8 +3376,7 @@ pmon_load_fast (char *file)
   buffer = (char *) xmalloc (MAXRECSIZE + 1);
   binbuf = (unsigned char *) xmalloc (BINCHUNK);
 
-  abfd = bfd_openr (file, 0);
-  gdb_bfd_ref (abfd);
+  abfd = gdb_bfd_openr (file, 0);
   if (!abfd)
     {
       printf_filtered ("Unable to open file %s\n", file);
index 9e620df2d39f938816c914c8a39f4cd9aca7e27d..67802122e0c7395afe4b36a97e5af80580b8e7e8 100644 (file)
@@ -9824,14 +9824,12 @@ remote_filename_p (const char *filename)
 bfd *
 remote_bfd_open (const char *remote_file, const char *target)
 {
-  bfd *abfd = bfd_openr_iovec (remote_file, target,
-                              remote_bfd_iovec_open, NULL,
-                              remote_bfd_iovec_pread,
-                              remote_bfd_iovec_close,
-                              remote_bfd_iovec_stat);
-
-  if (abfd != NULL)
-    gdb_bfd_stash_filename (abfd);
+  bfd *abfd = gdb_bfd_openr_iovec (remote_file, target,
+                                  remote_bfd_iovec_open, NULL,
+                                  remote_bfd_iovec_pread,
+                                  remote_bfd_iovec_close,
+                                  remote_bfd_iovec_stat);
+
   return abfd;
 }
 
index 073f167caf4e03ded73dba24d3538b7c79afcc39..140012bbebcf70f4559123c4b00db62447ec4d7f 100644 (file)
@@ -748,17 +748,15 @@ add_vmap (LdInfo *ldi)
   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 (filename, gnutarget);
+    abfd = gdb_bfd_openr (filename, gnutarget);
   else
-    abfd = bfd_fdopenr (filename, gnutarget, fd);
-  gdb_bfd_ref (abfd);
+    abfd = gdb_bfd_fdopenr (filename, gnutarget, fd);
   if (!abfd)
     {
       warning (_("Could not open `%s' as an executable file: %s"),
               filename, bfd_errmsg (bfd_get_error ()));
       return NULL;
     }
-  gdb_bfd_stash_filename (abfd);
 
   /* Make sure we have an object file.  */
 
@@ -769,9 +767,8 @@ add_vmap (LdInfo *ldi)
     {
       last = 0;
       /* FIXME??? am I tossing BFDs?  bfd?  */
-      while ((last = bfd_openr_next_archived_file (abfd, last)))
+      while ((last = gdb_bfd_openr_next_archived_file (abfd, last)))
        {
-         gdb_bfd_ref (last);
          if (strcmp (mem, last->filename) == 0)
            break;
        }
index b76a966d8e056cafa78c87a196ef2d83c94069ed..db8f187ad0f4b0a1f82bc1c57f4270c5ca4be11e 100644 (file)
@@ -371,8 +371,7 @@ 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 = bfd_openr (interp_name, gnutarget);
-  gdb_bfd_ref (dyld_bfd);
+  dyld_bfd = gdb_bfd_openr (interp_name, gnutarget);
   if (dyld_bfd)
     {
       bfd *sub;
index 5e1f730bc9893164527b88edf31e6a845348fbfd..00ed8a549036a1f8c3a5344a7a38a2e5797cf4b7 100644 (file)
@@ -362,8 +362,7 @@ 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 = bfd_openr (buf, gnutarget);
-      gdb_bfd_ref (tmp_bfd);
+      tmp_bfd = gdb_bfd_openr (buf, gnutarget);
       if (tmp_bfd == NULL)
        return;
 
index c1c49e7fa1aaa4941341eda343f69a01447b3e68..f62d96cf57ff4c780735a1b07f4f1a1dfdd715eb 100644 (file)
@@ -326,11 +326,10 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
   CORE_ADDR *open_closure = xmalloc (sizeof (CORE_ADDR));
   *open_closure = addr;
 
-  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);
+  nbfd = gdb_bfd_openr_iovec (name, "elf32-spu",
+                             spu_bfd_iovec_open, open_closure,
+                             spu_bfd_iovec_pread, spu_bfd_iovec_close,
+                             spu_bfd_iovec_stat);
   if (!nbfd)
     return NULL;
 
@@ -340,7 +339,6 @@ spu_bfd_fopen (char *name, CORE_ADDR addr)
       return NULL;
     }
 
-  gdb_bfd_stash_filename (nbfd);
   return nbfd;
 }
 
index 649ceddc3c22d55ff3b279736aca9a9b3c98310d..9779e100a01cffeffb628d2d9bed55a63684fa69 100644 (file)
@@ -377,7 +377,7 @@ solib_bfd_fopen (char *pathname, int fd)
     }
   else
     {
-      abfd = bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
+      abfd = gdb_bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
 
       if (abfd)
        bfd_set_cacheable (abfd, 1);
@@ -390,10 +390,8 @@ solib_bfd_fopen (char *pathname, int fd)
             pathname, bfd_errmsg (bfd_get_error ()));
     }
 
-  gdb_bfd_stash_filename (abfd);
   xfree (pathname);
 
-  gdb_bfd_ref (abfd);
   return abfd;
 }
 
index ae643e3c2bc7499b733ec1c16de4b6eea0277c87..a17ff3f831f8a1936e7e559a8e4d79d2212ef688 100644 (file)
@@ -315,13 +315,12 @@ spu_bfd_open (ULONGEST addr)
   ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
   *open_closure = addr;
 
-  nbfd = bfd_openr_iovec ("<in-memory>", "elf32-spu",
-                         spu_bfd_iovec_open, open_closure,
-                         spu_bfd_iovec_pread, spu_bfd_iovec_close,
-                         spu_bfd_iovec_stat);
+  nbfd = gdb_bfd_openr_iovec ("<in-memory>", "elf32-spu",
+                             spu_bfd_iovec_open, open_closure,
+                             spu_bfd_iovec_pread, spu_bfd_iovec_close,
+                             spu_bfd_iovec_stat);
   if (!nbfd)
     return NULL;
-  gdb_bfd_ref (nbfd);
 
   if (!bfd_check_format (nbfd, bfd_object))
     {
index 921ed304b780fa2f48b9aa05902c060c4dc8ab34..64c4a3b23d363953f9ed26ed0b4b7c5354c719b6 100644 (file)
@@ -1702,13 +1702,8 @@ bfd_open_maybe_remote (const char *name)
   if (remote_filename_p (name))
     result = remote_bfd_open (name, gnutarget);
   else
-    {
-      result = bfd_openr (name, gnutarget);
-      if (result != NULL)
-       gdb_bfd_stash_filename (result);
-    }
+    result = gdb_bfd_openr (name, gnutarget);
 
-  gdb_bfd_ref (result);
   return result;
 }
 
@@ -1728,7 +1723,6 @@ symfile_bfd_open (char *name)
   if (remote_filename_p (name))
     {
       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 ()));
@@ -1768,8 +1762,7 @@ symfile_bfd_open (char *name)
   name = absolute_name;
   make_cleanup (xfree, name);
 
-  sym_bfd = bfd_fopen (name, gnutarget, FOPEN_RB, desc);
-  gdb_bfd_ref (sym_bfd);
+  sym_bfd = gdb_bfd_fopen (name, gnutarget, FOPEN_RB, desc);
   if (!sym_bfd)
     {
       make_cleanup (xfree, name);
@@ -1785,8 +1778,6 @@ symfile_bfd_open (char *name)
             bfd_errmsg (bfd_get_error ()));
     }
 
-  gdb_bfd_stash_filename (sym_bfd);
-
   return sym_bfd;
 }
 
@@ -2111,8 +2102,7 @@ generic_load (char *args, int from_tty)
     }
 
   /* Open the file for loading.  */
-  loadfile_bfd = bfd_openr (filename, gnutarget);
-  gdb_bfd_ref (loadfile_bfd);
+  loadfile_bfd = gdb_bfd_openr (filename, gnutarget);
   if (loadfile_bfd == NULL)
     {
       perror_with_name (filename);
index b2a1d8bf6c3b601f22fe2b0c896df970afde5e19..afef61544a0b7316386d96d42e4d66517f2f8504 100644 (file)
@@ -752,8 +752,7 @@ windows_make_so (const char *name, LPVOID load_addr)
       asection *text = NULL;
       CORE_ADDR text_vma;
 
-      abfd = bfd_openr (so->so_name, "pei-i386");
-      gdb_bfd_ref (abfd);
+      abfd = gdb_bfd_openr (so->so_name, "pei-i386");
 
       if (!abfd)
        return so;