* bfd-target.c (target_bfd_reopen): Update.
[deliverable/binutils-gdb.git] / gdb / corelow.c
index 3dfa2f483d3502babfff1d187ceac348b79645ff..529e3e24ec3477ffeefc879314eb983ec5cf9d0d 100644 (file)
@@ -216,9 +216,7 @@ core_close (int quitting)
          core_data = NULL;
        }
 
-      name = bfd_get_filename (core_bfd);
       gdb_bfd_unref (core_bfd);
-      xfree (name);
       core_bfd = NULL;
     }
   core_vec = NULL;
@@ -320,12 +318,15 @@ 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);
 
+  gdb_bfd_stash_filename (temp_bfd);
+
   if (!bfd_check_format (temp_bfd, bfd_core)
       && !gdb_check_format (temp_bfd))
     {
@@ -333,7 +334,7 @@ core_open (char *filename, int from_tty)
       /* FIXME: should be checking for errors from bfd_close (for one
          thing, on error it does not free all the storage associated
          with the bfd).  */
-      make_cleanup_bfd_close (temp_bfd);
+      make_cleanup_bfd_unref (temp_bfd);
       error (_("\"%s\" is not a core dump: %s"),
             filename, bfd_errmsg (bfd_get_error ()));
     }
@@ -341,7 +342,7 @@ core_open (char *filename, int from_tty)
   /* Looks semi-reasonable.  Toss the old core file and work on the
      new.  */
 
-  discard_cleanups (old_chain);        /* Don't free filename any more */
+  do_cleanups (old_chain);
   unpush_target (&core_ops);
   core_bfd = temp_bfd;
   old_chain = make_cleanup (core_close_cleanup, 0 /*ignore*/);
This page took 0.024437 seconds and 4 git commands to generate.