diff options
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; } |