aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-07-23 14:57:58 +0000
committerTom Tromey <tromey@redhat.com>2012-07-23 14:57:58 +0000
commit64c311498e46cef6b70aa88577e7d7c382e0f7cc (patch)
treefabf22b710c731e652b80893b1b133a3b1247e40
parent520b0001c16bc59223bec1369d056787c1883f10 (diff)
downloadgdb-64c311498e46cef6b70aa88577e7d7c382e0f7cc.zip
gdb-64c311498e46cef6b70aa88577e7d7c382e0f7cc.tar.gz
gdb-64c311498e46cef6b70aa88577e7d7c382e0f7cc.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog39
-rw-r--r--gdb/cli/cli-dump.c6
-rw-r--r--gdb/corelow.c9
-rw-r--r--gdb/dsrec.c3
-rw-r--r--gdb/exec.c9
-rw-r--r--gdb/gcore.c4
-rw-r--r--gdb/gdb_bfd.c114
-rw-r--r--gdb/gdb_bfd.h45
-rw-r--r--gdb/jit.c13
-rw-r--r--gdb/m32r-rom.c6
-rw-r--r--gdb/machoread.c25
-rw-r--r--gdb/procfs.c3
-rw-r--r--gdb/remote-m32r-sdi.c3
-rw-r--r--gdb/remote-mips.c6
-rw-r--r--gdb/remote.c14
-rw-r--r--gdb/rs6000-nat.c9
-rw-r--r--gdb/solib-darwin.c3
-rw-r--r--gdb/solib-pa64.c3
-rw-r--r--gdb/solib-spu.c10
-rw-r--r--gdb/solib.c4
-rw-r--r--gdb/spu-linux-nat.c9
-rw-r--r--gdb/symfile.c16
-rw-r--r--gdb/windows-nat.c3
23 files changed, 250 insertions, 106 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6cf1b52..9b96acf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,44 @@
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.
* cli/cli-dump.c (bfd_openr_with_cleanup)
(bfd_openw_with_cleanup): Update.
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 5998b3f..7341f00 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -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 ()));
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 529e3e2..340b149 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -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))
{
diff --git a/gdb/dsrec.c b/gdb/dsrec.c
index 8cca361..f39d0ed 100644
--- a/gdb/dsrec.c
+++ b/gdb/dsrec.c
@@ -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);
diff --git a/gdb/exec.c b/gdb/exec.c
index dc9258a..9b95e02 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -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
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 1443289..a45e787 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -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;
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index dd6eac3..095d0f3 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -481,3 +481,117 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
*size = descriptor->size;
return descriptor->data;
}
+
+
+
+/* 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;
+}
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index f5b6103..f131ba7 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -58,4 +58,49 @@ void gdb_bfd_unref (struct bfd *abfd);
const gdb_byte *gdb_bfd_map_section (asection *section, bfd_size_type *size);
+
+
+/* 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 */
diff --git a/gdb/jit.c b/gdb/jit.c
index 34b7777..410b94d 100644
--- 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. */
diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
index 5678f13..9a2f5aa 100644
--- a/gdb/m32r-rom.c
+++ b/gdb/m32r-rom.c
@@ -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. */
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 8ecd4c5..5b9e2ba 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -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))
{
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 3df8254..4409e5b 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -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 ()));
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index f0c7cba..85268b6 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -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);
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 2c8b92e..db4381b 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -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);
diff --git a/gdb/remote.c b/gdb/remote.c
index 9e620df..6780212 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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;
}
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 073f167..140012b 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -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;
}
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index b76a966..db8f187 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -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;
diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c
index 5e1f730..00ed8a5 100644
--- a/gdb/solib-pa64.c
+++ b/gdb/solib-pa64.c
@@ -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;
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index c1c49e7..f62d96c 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -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;
}
diff --git a/gdb/solib.c b/gdb/solib.c
index 649cedd..9779e10 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -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;
}
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index ae643e3..a17ff3f 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -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))
{
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 921ed30..64c4a3b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -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);
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b2a1d8b..afef615 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -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;