Enable support for the AArch64 dot-prod instruction in the Cortex A55 and A75 cpus.
[deliverable/binutils-gdb.git] / gdb / exec.c
index 2c9a74bcaa45348195ce58553747d34f782edc03..92c87e4e02f096c2ec04bf305465649c876153f8 100644 (file)
@@ -113,17 +113,14 @@ static void
 exec_close_1 (struct target_ops *self)
 {
   struct program_space *ss;
-  struct cleanup *old_chain;
+  scoped_restore_current_program_space restore_pspace;
 
-  old_chain = save_current_program_space ();
   ALL_PSPACES (ss)
-  {
-    set_current_program_space (ss);
-    clear_section_table (current_target_sections);
-    exec_close ();
-  }
-
-  do_cleanups (old_chain);
+    {
+      set_current_program_space (ss);
+      clear_section_table (current_target_sections);
+      exec_close ();
+    }
 }
 
 void
@@ -252,16 +249,12 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
 void
 exec_file_attach (const 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);
   gdb_bfd_ref_ptr exec_bfd_holder (exec_bfd);
 
-  cleanups = make_cleanup (null_cleanup, NULL);
-
   /* Remove any previous exec file.  */
   exec_close ();
 
@@ -277,7 +270,7 @@ exec_file_attach (const char *filename, int from_tty)
   else
     {
       int load_via_target = 0;
-      char *scratch_pathname, *canonical_pathname;
+      const char *scratch_pathname, *canonical_pathname;
       int scratch_chan;
       struct target_section *sections = NULL, *sections_end = NULL;
       char **matching;
@@ -290,6 +283,7 @@ exec_file_attach (const char *filename, int from_tty)
            load_via_target = 1;
        }
 
+      gdb::unique_xmalloc_ptr<char> canonical_storage, scratch_storage;
       if (load_via_target)
        {
          /* gdb_bfd_fopen does not support "target:" filenames.  */
@@ -298,19 +292,18 @@ exec_file_attach (const char *filename, int from_tty)
                       "not supported for %s sysroots"),
                     TARGET_SYSROOT_PREFIX);
 
-         scratch_pathname = xstrdup (filename);
-         make_cleanup (xfree, scratch_pathname);
-
+         scratch_pathname = filename;
          scratch_chan = -1;
-
          canonical_pathname = scratch_pathname;
        }
       else
        {
+         char *temp_pathname;
+
          scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
                                filename, write_files ?
                                O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
-                               &scratch_pathname);
+                               &temp_pathname);
 #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
          if (scratch_chan < 0)
            {
@@ -321,18 +314,19 @@ exec_file_attach (const char *filename, int from_tty)
                                    exename, write_files ?
                                    O_RDWR | O_BINARY
                                    : O_RDONLY | O_BINARY,
-                                   &scratch_pathname);
+                                   &temp_pathname);
            }
 #endif
          if (scratch_chan < 0)
            perror_with_name (filename);
 
-         make_cleanup (xfree, scratch_pathname);
+         scratch_storage.reset (temp_pathname);
+         scratch_pathname = temp_pathname;
 
          /* gdb_bfd_open (and its variants) prefers canonicalized
             pathname for better BFD caching.  */
-         canonical_pathname = gdb_realpath (scratch_pathname);
-         make_cleanup (xfree, canonical_pathname);
+         canonical_storage = gdb_realpath (scratch_pathname);
+         canonical_pathname = canonical_storage.get ();
        }
 
       gdb_bfd_ref_ptr temp;
@@ -355,7 +349,7 @@ exec_file_attach (const char *filename, int from_tty)
       if (load_via_target)
        exec_filename = xstrdup (bfd_get_filename (exec_bfd));
       else
-       exec_filename = gdb_realpath_keepfile (scratch_pathname);
+       exec_filename = gdb_realpath_keepfile (scratch_pathname).release ();
 
       if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
        {
@@ -393,8 +387,6 @@ exec_file_attach (const char *filename, int from_tty)
        (*deprecated_exec_file_display_hook) (filename);
     }
 
-  do_cleanups (cleanups);
-
   bfd_cache_close_all ();
   observer_notify_executable_changed ();
 }
@@ -410,7 +402,6 @@ exec_file_attach (const char *filename, int from_tty)
 static void
 exec_file_command (char *args, int from_tty)
 {
-  char **argv;
   char *filename;
 
   if (from_tty && target_has_execution
@@ -420,13 +411,11 @@ exec_file_command (char *args, int from_tty)
 
   if (args)
     {
-      struct cleanup *cleanups;
-
       /* Scan through the args and pick up the first non option arg
          as the filename.  */
 
-      argv = gdb_buildargv (args);
-      cleanups = make_cleanup_freeargv (argv);
+      gdb_argv built_argv (args);
+      char **argv = built_argv.get ();
 
       for (; (*argv != NULL) && (**argv == '-'); argv++)
         {;
@@ -434,11 +423,8 @@ exec_file_command (char *args, int from_tty)
       if (*argv == NULL)
         error (_("No executable file name was specified"));
 
-      filename = tilde_expand (*argv);
-      make_cleanup (xfree, filename);
-      exec_file_attach (filename, from_tty);
-
-      do_cleanups (cleanups);
+      gdb::unique_xmalloc_ptr<char> filename (tilde_expand (*argv));
+      exec_file_attach (filename.get (), from_tty);
     }
   else
     exec_file_attach (NULL, from_tty);
This page took 0.035881 seconds and 4 git commands to generate.