diff options
author | Tom Tromey <tromey@redhat.com> | 2012-07-23 14:58:44 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-07-23 14:58:44 +0000 |
commit | 8ac244b433d5d36b787afd36f7144069e7d837e0 (patch) | |
tree | dccbc64cbec657281a84c4d8e07d96df3e508661 /gdb/symfile.c | |
parent | 64c311498e46cef6b70aa88577e7d7c382e0f7cc (diff) | |
download | gdb-8ac244b433d5d36b787afd36f7144069e7d837e0.zip gdb-8ac244b433d5d36b787afd36f7144069e7d837e0.tar.gz gdb-8ac244b433d5d36b787afd36f7144069e7d837e0.tar.bz2 |
* coffread.c (coff_symfile_read): Make a cleanup for 'debugfile'
and 'abfd'.
* elfread.c (elf_symfile_read): Make a cleanup for 'debugfile'
and 'abfd'.
* jit.c (jit_bfd_try_read_symtab): Make a cleanup for 'nbfd'.
* machoread.c (macho_add_oso_symfile): Make a cleanup for
'abfd'.
(macho_symfile_read): Make a cleanup for 'dsym_bfd'.
* objfiles.c (allocate_objfile): Acquire a new reference.
* rs6000-nat.c (add_vmap): Don't acquire a BFD reference.
* solib.c (solib_read_symbols): Don't acquire a BFD reference.
* spu-linux-nat.c (spu_symbol_file_add_from_memory): Make
a cleanup for 'nbfd'.
* symfile-mem.c (symbol_file_add_from_memory): Make a cleanup
for 'nbfd'.
* symfile.c (symbol_file_add_with_addrs_or_offsets): Don't
make a cleanup for 'abfd'.
(symbol_file_add): Make a BFD cleanup.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r-- | gdb/symfile.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c index 64c4a3b..e1d5c15 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1037,7 +1037,7 @@ new_symfile_objfile (struct objfile *objfile, int add_flags) loaded file. ABFD is a BFD already open on the file, as from symfile_bfd_open. - This BFD will be closed on error, and is always consumed by this function. + A new reference is acquired by this function. ADD_FLAGS encodes verbosity, whether this is main symbol file or extra, such as dynamically loaded code, and what to do with breakpoins. @@ -1061,7 +1061,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int flags, struct objfile *parent) { struct objfile *objfile; - struct cleanup *my_cleanups; const char *name = bfd_get_filename (abfd); const int from_tty = add_flags & SYMFILE_VERBOSE; const int mainline = add_flags & SYMFILE_MAINLINE; @@ -1075,8 +1074,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, add_flags &= ~SYMFILE_NO_READ; } - my_cleanups = make_cleanup_bfd_unref (abfd); - /* Give user a chance to burp if we'd be interactively wiping out any existing symbols. */ @@ -1087,7 +1084,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, error (_("Not confirmed.")); objfile = allocate_objfile (abfd, flags | (mainline ? OBJF_MAINLINE : 0)); - discard_cleanups (my_cleanups); if (parent) add_separate_debug_objfile (objfile, parent); @@ -1208,8 +1204,14 @@ struct objfile * symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs, int flags) { - return symbol_file_add_from_bfd (symfile_bfd_open (name), add_flags, addrs, + bfd *bfd = symfile_bfd_open (name); + struct cleanup *cleanup = make_cleanup_bfd_unref (bfd); + struct objfile *objf; + + objf = symbol_file_add_from_bfd (symfile_bfd_open (name), add_flags, addrs, flags, NULL); + do_cleanups (cleanup); + return objf; } |