implement support for "enum class"
[deliverable/binutils-gdb.git] / gdb / exec.c
index 758e382702fc204031d69406af00bb6a705f47e0..ca59c72bab2ceec767c25aef916021550b45d4a2 100644 (file)
@@ -168,6 +168,14 @@ exec_file_clear (int from_tty)
 void
 exec_file_attach (char *filename, int from_tty)
 {
+  struct cleanup *cleanups;
+
+  /* First, acquire a reference to the current exec_bfd.  We release
+     this at the end of the function; but acquiring it now lets the
+     BFD cache return it if this call refers to the same file.  */
+  gdb_bfd_ref (exec_bfd);
+  cleanups = make_cleanup_bfd_unref (exec_bfd);
+
   /* Remove any previous exec file.  */
   exec_close ();
 
@@ -182,7 +190,6 @@ exec_file_attach (char *filename, int from_tty)
     }
   else
     {
-      struct cleanup *cleanups;
       char *scratch_pathname, *canonical_pathname;
       int scratch_chan;
       struct target_section *sections = NULL, *sections_end = NULL;
@@ -205,7 +212,7 @@ exec_file_attach (char *filename, int from_tty)
       if (scratch_chan < 0)
        perror_with_name (filename);
 
-      cleanups = make_cleanup (xfree, scratch_pathname);
+      make_cleanup (xfree, scratch_pathname);
 
       /* gdb_bfd_open (and its variants) prefers canonicalized pathname for
         better BFD caching.  */
@@ -261,9 +268,10 @@ exec_file_attach (char *filename, int from_tty)
       /* Tell display code (if any) about the changed file name.  */
       if (deprecated_exec_file_display_hook)
        (*deprecated_exec_file_display_hook) (filename);
-
-      do_cleanups (cleanups);
     }
+
+  do_cleanups (cleanups);
+
   bfd_cache_close_all ();
   observer_notify_executable_changed ();
 }
@@ -661,7 +669,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
          else
            {
              *xfered_len = r->start - offset;
-             status = TARGET_XFER_E_UNAVAILABLE;
+             status = TARGET_XFER_UNAVAILABLE;
            }
          do_cleanups (old_chain);
          return status;
@@ -670,7 +678,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
   do_cleanups (old_chain);
 
   *xfered_len = len;
-  return TARGET_XFER_E_UNAVAILABLE;
+  return TARGET_XFER_UNAVAILABLE;
 }
 
 enum target_xfer_status
@@ -951,13 +959,11 @@ init_exec_ops (void)
 Specify the filename of the executable file.";
   exec_ops.to_open = exec_open;
   exec_ops.to_close = exec_close_1;
-  exec_ops.to_attach = find_default_attach;
   exec_ops.to_xfer_partial = exec_xfer_partial;
   exec_ops.to_get_section_table = exec_get_section_table;
   exec_ops.to_files_info = exec_files_info;
   exec_ops.to_insert_breakpoint = ignore;
   exec_ops.to_remove_breakpoint = ignore;
-  exec_ops.to_create_inferior = find_default_create_inferior;
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
This page took 0.024105 seconds and 4 git commands to generate.