diff options
-rw-r--r-- | gdb/ChangeLog | 31 | ||||
-rw-r--r-- | gdb/bfd-target.c | 3 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 6 | ||||
-rw-r--r-- | gdb/corelow.c | 7 | ||||
-rw-r--r-- | gdb/dsrec.c | 3 | ||||
-rw-r--r-- | gdb/exec.c | 7 | ||||
-rw-r--r-- | gdb/gcore.c | 3 | ||||
-rw-r--r-- | gdb/gdb_bfd.c | 14 | ||||
-rw-r--r-- | gdb/gdb_bfd.h | 12 | ||||
-rw-r--r-- | gdb/jit.c | 2 | ||||
-rw-r--r-- | gdb/m32r-rom.c | 6 | ||||
-rw-r--r-- | gdb/machoread.c | 19 | ||||
-rw-r--r-- | gdb/procfs.c | 3 | ||||
-rw-r--r-- | gdb/remote-m32r-sdi.c | 3 | ||||
-rw-r--r-- | gdb/remote-mips.c | 6 | ||||
-rw-r--r-- | gdb/rs6000-nat.c | 14 | ||||
-rw-r--r-- | gdb/solib-darwin.c | 6 | ||||
-rw-r--r-- | gdb/solib-pa64.c | 3 | ||||
-rw-r--r-- | gdb/solib-spu.c | 9 | ||||
-rw-r--r-- | gdb/solib.c | 6 | ||||
-rw-r--r-- | gdb/spu-linux-nat.c | 2 | ||||
-rw-r--r-- | gdb/symfile.c | 20 | ||||
-rw-r--r-- | gdb/windows-nat.c | 3 |
23 files changed, 126 insertions, 62 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e13db0d..6cf1b52 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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. diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index 21f53bb..455d3e6 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -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); diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 1244767..5998b3f 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -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 ())); diff --git a/gdb/corelow.c b/gdb/corelow.c index 380c0dc..529e3e2 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -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); diff --git a/gdb/dsrec.c b/gdb/dsrec.c index 66d4c13..8cca361 100644 --- a/gdb/dsrec.c +++ b/gdb/dsrec.c @@ -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); @@ -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) { diff --git a/gdb/gcore.c b/gdb/gcore.c index f9a1389..1443289 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -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); diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 10489ac..dd6eac3 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -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. */ diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index 1dd82c3..f5b6103 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -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); @@ -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. */ diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index ffda6f9..5678f13 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -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. */ diff --git a/gdb/machoread.c b/gdb/machoread.c index 6d309bb..8ecd4c5 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -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); diff --git a/gdb/procfs.c b/gdb/procfs.c index 32cb468..3df8254 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -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 ())); diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index b4b7324..f0c7cba 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -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); diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index b46325f..2c8b92e 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -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); diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 017e997..073f167 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -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. */ diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 7109ead..b76a966 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -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 diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c index b55b67c..5e1f730 100644 --- a/gdb/solib-pa64.c +++ b/gdb/solib-pa64.c @@ -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; diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c index 5eeae62..c1c49e7 100644 --- a/gdb/solib-spu.c +++ b/gdb/solib-spu.c @@ -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; diff --git a/gdb/solib.c b/gdb/solib.c index 0fd955d..649cedd 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -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; diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c index 12f8211..ae643e3 100644 --- a/gdb/spu-linux-nat.c +++ b/gdb/spu-linux-nat.c @@ -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)) { diff --git a/gdb/symfile.c b/gdb/symfile.c index c904011..921ed30 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -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); diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6ba92d9..b2a1d8b 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -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; |