aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-08-22 16:24:39 +0000
committerTom Tromey <tromey@redhat.com>2012-08-22 16:24:39 +0000
commit1c00ec6b06aa852351b7eebd64b4f1604766e818 (patch)
tree1c8d29e9bd8e5323650d08916442e681faa95d73 /gdb
parent6532ff3697890085456f353dd49068edfd4ed422 (diff)
downloadgdb-1c00ec6b06aa852351b7eebd64b4f1604766e818.zip
gdb-1c00ec6b06aa852351b7eebd64b4f1604766e818.tar.gz
gdb-1c00ec6b06aa852351b7eebd64b4f1604766e818.tar.bz2
* windows-nat.c (windows_make_so): Use gdb_bfd_open.
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_open. (symfile_bfd_open): Likewise. (generic_load): Likewise. * solib.c (solib_bfd_fopen): Use gdb_bfd_open. * solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_open. * solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_open. * rs6000-nat.c (add_vmap): Use gdb_bfd_open. * remote-mips.c (mips_load_srec): Use gdb_bfd_open. (pmon_load_fast): Likewise. * remote-m32r-sdi.c (m32r_load): Use gdb_bfd_open. * procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_open. * machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_open. (macho_check_dsym): Likewise. * m32r-rom.c (m32r_load): Use gdb_bfd_open. (m32r_upload_command): Likewise. * gdb_bfd.h (gdb_bfd_cache): Declare. * gdb_bfd.c (struct gdb_bfd_data): New. (gdb_bfd_cache): New global. (struct gdb_bfd_cache_search): New. (hash_bfd): New function. (eq_bfd): Likewise. (gdb_bfd_open): Likewise. (gdb_bfd_ref): Allocate a gdb_bfd_data and attach to the BFD. (gdb_bfd_unref): Remove closed BFD from cache. Update for gdb_bfd_data. * exec.c (exec_file_attach): Use gdb_bfd_open. * dsrec.c (load_srec): Use gdb_bfd_open.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog33
-rw-r--r--gdb/dsrec.c2
-rw-r--r--gdb/exec.c8
-rw-r--r--gdb/m32r-rom.c4
-rw-r--r--gdb/machoread.c4
-rw-r--r--gdb/remote-m32r-sdi.c2
-rw-r--r--gdb/remote-mips.c4
-rw-r--r--gdb/rs6000-nat.c7
-rw-r--r--gdb/solib-darwin.c2
-rw-r--r--gdb/solib-pa64.c2
-rw-r--r--gdb/solib.c2
-rw-r--r--gdb/symfile.c6
-rw-r--r--gdb/windows-nat.c2
13 files changed, 54 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 571c9b6..2f54efc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,38 @@
2012-08-22 Tom Tromey <tromey@redhat.com>
+ * windows-nat.c (windows_make_so): Use gdb_bfd_open.
+ * symfile.c (bfd_open_maybe_remote): Use gdb_bfd_open.
+ (symfile_bfd_open): Likewise.
+ (generic_load): Likewise.
+ * solib.c (solib_bfd_fopen): Use gdb_bfd_open.
+ * solib-pa64.c (pa64_solib_create_inferior_hook): Use
+ gdb_bfd_open.
+ * solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
+ Use gdb_bfd_open.
+ * rs6000-nat.c (add_vmap): Use gdb_bfd_open.
+ * remote-mips.c (mips_load_srec): Use gdb_bfd_open.
+ (pmon_load_fast): Likewise.
+ * remote-m32r-sdi.c (m32r_load): Use gdb_bfd_open.
+ * procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_open.
+ * machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_open.
+ (macho_check_dsym): Likewise.
+ * m32r-rom.c (m32r_load): Use gdb_bfd_open.
+ (m32r_upload_command): Likewise.
+ * gdb_bfd.h (gdb_bfd_cache): Declare.
+ * gdb_bfd.c (struct gdb_bfd_data): New.
+ (gdb_bfd_cache): New global.
+ (struct gdb_bfd_cache_search): New.
+ (hash_bfd): New function.
+ (eq_bfd): Likewise.
+ (gdb_bfd_open): Likewise.
+ (gdb_bfd_ref): Allocate a gdb_bfd_data and attach to the BFD.
+ (gdb_bfd_unref): Remove closed BFD from cache. Update for
+ gdb_bfd_data.
+ * exec.c (exec_file_attach): Use gdb_bfd_open.
+ * dsrec.c (load_srec): Use gdb_bfd_open.
+
+2012-08-22 Tom Tromey <tromey@redhat.com>
+
* dwarf2read.c (macro_start_file): Update.
* objfiles.c (get_objfile_bfd_data): Initialize macro_cache.
(free_objfile_per_bfd_storage): Destroy macro_cache.
diff --git a/gdb/dsrec.c b/gdb/dsrec.c
index f39d0ed..20ff339 100644
--- a/gdb/dsrec.c
+++ b/gdb/dsrec.c
@@ -61,7 +61,7 @@ load_srec (struct serial *desc, const char *file, bfd_vma load_offset,
srec = (char *) alloca (maxrecsize + 1);
- abfd = gdb_bfd_openr (file, 0);
+ abfd = gdb_bfd_open (file, NULL, -1);
if (!abfd)
{
printf_filtered (_("Unable to open file %s\n"), file);
diff --git a/gdb/exec.c b/gdb/exec.c
index de1b0b6..2bd3181 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -230,9 +230,11 @@ exec_file_attach (char *filename, int from_tty)
if (scratch_chan < 0)
perror_with_name (filename);
- exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget,
- write_files ? FOPEN_RUB : FOPEN_RB,
- scratch_chan);
+ if (write_files)
+ exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget,
+ FOPEN_RUB, scratch_chan);
+ else
+ exec_bfd = gdb_bfd_open (scratch_pathname, gnutarget, scratch_chan);
if (!exec_bfd)
{
diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
index 9a2f5aa..4bb4ceb 100644
--- a/gdb/m32r-rom.c
+++ b/gdb/m32r-rom.c
@@ -130,7 +130,7 @@ m32r_load (char *filename, int from_tty)
if (filename == NULL || filename[0] == 0)
filename = get_exec_file (1);
- abfd = gdb_bfd_openr (filename, 0);
+ abfd = gdb_bfd_open (filename, NULL, -1);
if (!abfd)
error (_("Unable to open file %s."), filename);
cleanup = make_cleanup_bfd_unref (abfd);
@@ -529,7 +529,7 @@ m32r_upload_command (char *args, int from_tty)
printf_filtered (" -- Ethernet load complete.\n");
gettimeofday (&end_time, NULL);
- abfd = gdb_bfd_openr (args, 0);
+ abfd = gdb_bfd_open (args, NULL, -1);
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 2c398fa..6a6eaa1 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -688,7 +688,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
}
/* Open the archive and check the format. */
- archive_bfd = gdb_bfd_openr (archive_name, gnutarget);
+ archive_bfd = gdb_bfd_open (archive_name, gnutarget, -1);
if (archive_bfd == NULL)
{
warning (_("Could not open OSO archive file \"%s\""),
@@ -762,7 +762,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
{
bfd *abfd;
- abfd = gdb_bfd_openr (oso->name, gnutarget);
+ abfd = gdb_bfd_open (oso->name, gnutarget, -1);
if (!abfd)
warning (_("`%s': can't open to read symbols: %s."), oso->name,
bfd_errmsg (bfd_get_error ()));
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 85268b6..748aeba 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1258,7 +1258,7 @@ m32r_load (char *args, int from_tty)
if (!filename)
filename = get_exec_file (1);
- pbfd = gdb_bfd_openr (filename, gnutarget);
+ pbfd = gdb_bfd_open (filename, gnutarget, -1);
if (pbfd == NULL)
{
perror_with_name (filename);
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index db4381b..7219bc7 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2789,7 +2789,7 @@ mips_load_srec (char *args)
buffer = alloca (srec_frame * 2 + 256);
- abfd = gdb_bfd_openr (args, 0);
+ abfd = gdb_bfd_open (args, NULL, -1);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", args);
@@ -3376,7 +3376,7 @@ pmon_load_fast (char *file)
buffer = (char *) xmalloc (MAXRECSIZE + 1);
binbuf = (unsigned char *) xmalloc (BINCHUNK);
- abfd = gdb_bfd_openr (file, 0);
+ abfd = gdb_bfd_open (file, NULL, -1);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", file);
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 9b8efd3..0ec0429 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -745,12 +745,7 @@ add_vmap (LdInfo *ldi)
mem = xstrdup (mem);
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 = gdb_bfd_openr (filename, gnutarget);
- else
- abfd = gdb_bfd_fdopenr (filename, gnutarget, fd);
+ abfd = gdb_bfd_open (filename, gnutarget, fd < 0 ? -1 : fd);
if (!abfd)
{
warning (_("Could not open `%s' as an executable file: %s"),
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index d08bd38..55ecb91 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -371,7 +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 = gdb_bfd_openr (interp_name, gnutarget);
+ dyld_bfd = gdb_bfd_open (interp_name, gnutarget, -1);
if (dyld_bfd)
{
bfd *sub;
diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c
index 00ed8a5..d9f277f 100644
--- a/gdb/solib-pa64.c
+++ b/gdb/solib-pa64.c
@@ -362,7 +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 = gdb_bfd_openr (buf, gnutarget);
+ tmp_bfd = gdb_bfd_open (buf, gnutarget, -1);
if (tmp_bfd == NULL)
return;
diff --git a/gdb/solib.c b/gdb/solib.c
index 3081f35..01573f8 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -377,7 +377,7 @@ solib_bfd_fopen (char *pathname, int fd)
}
else
{
- abfd = gdb_bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
+ abfd = gdb_bfd_open (pathname, gnutarget, fd);
if (abfd)
bfd_set_cacheable (abfd, 1);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 6c93ba6..7c202b5 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1703,7 +1703,7 @@ gdb_bfd_open_maybe_remote (const char *name)
if (remote_filename_p (name))
result = remote_bfd_open (name, gnutarget);
else
- result = gdb_bfd_openr (name, gnutarget);
+ result = gdb_bfd_open (name, gnutarget, -1);
return result;
}
@@ -1763,7 +1763,7 @@ symfile_bfd_open (char *name)
name = absolute_name;
make_cleanup (xfree, name);
- sym_bfd = gdb_bfd_fopen (name, gnutarget, FOPEN_RB, desc);
+ sym_bfd = gdb_bfd_open (name, gnutarget, desc);
if (!sym_bfd)
{
make_cleanup (xfree, name);
@@ -2103,7 +2103,7 @@ generic_load (char *args, int from_tty)
}
/* Open the file for loading. */
- loadfile_bfd = gdb_bfd_openr (filename, gnutarget);
+ loadfile_bfd = gdb_bfd_open (filename, gnutarget, -1);
if (loadfile_bfd == NULL)
{
perror_with_name (filename);
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index afef615..b3c4a8e 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -752,7 +752,7 @@ windows_make_so (const char *name, LPVOID load_addr)
asection *text = NULL;
CORE_ADDR text_vma;
- abfd = gdb_bfd_openr (so->so_name, "pei-i386");
+ abfd = gdb_bfd_open (so->so_name, "pei-i386", -1);
if (!abfd)
return so;