Fix gdb.fortran "failed to extract expected results" errors
[binutils-gdb.git] / gdb / main.c
index d92aa02d83185512bd25d1150bae62c0387e4f20..8f944d86545068dd5dfaa7bf8d4f7e9abde7b9ef 100644 (file)
@@ -1,6 +1,6 @@
 /* Top level stuff for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2021 Free Software Foundation, Inc.
+   Copyright (C) 1986-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -65,7 +65,7 @@ char *interpreter_p;
 int dbx_commands = 0;
 
 /* System root path, used to find libraries etc.  */
-char *gdb_sysroot = 0;
+std::string gdb_sysroot;
 
 /* GDB datadir, used to store data files.  */
 std::string gdb_datadir;
@@ -574,14 +574,14 @@ enum cmdarg_kind
 
   /* Option type -ix.  */
   CMDARG_INIT_FILE,
-    
+
   /* Option type -iex.  */
   CMDARG_INIT_COMMAND,
 
-  /* Option type -sx.  */
+  /* Option type -eix.  */
   CMDARG_EARLYINIT_FILE,
 
-  /* Option type -sex.  */
+  /* Option type -eiex.  */
   CMDARG_EARLYINIT_COMMAND
 };
 
@@ -702,7 +702,7 @@ captured_main_1 (struct captured_main_args *context)
 
   /* Prefix warning messages with the command name.  */
   gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
-    (xstrprintf ("%s: warning: ", gdb_program_name));
+    = xstrprintf ("%s: warning: ", gdb_program_name);
   warning_pre_print = tmp_warn_preprint.get ();
 
   current_directory = getcwd (NULL, 0);
@@ -710,19 +710,14 @@ captured_main_1 (struct captured_main_args *context)
     perror_warning_with_name (_("error finding working directory"));
 
   /* Set the sysroot path.  */
-  gdb_sysroot
-    = xstrdup (relocate_gdb_directory (TARGET_SYSTEM_ROOT,
-                                    TARGET_SYSTEM_ROOT_RELOCATABLE).c_str ());
+  gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
+                                       TARGET_SYSTEM_ROOT_RELOCATABLE);
 
-  if (*gdb_sysroot == '\0')
-    {
-      xfree (gdb_sysroot);
-      gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
-    }
+  if (gdb_sysroot.empty ())
+    gdb_sysroot = TARGET_SYSROOT_PREFIX;
 
   debug_file_directory
-    = xstrdup (relocate_gdb_directory (DEBUGDIR,
-                                    DEBUGDIR_RELOCATABLE).c_str ());
+    = relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE);
 
   gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
                                        GDB_DATADIR_RELOCATABLE);
@@ -1126,7 +1121,7 @@ captured_main_1 (struct captured_main_args *context)
   if (print_version)
     {
       print_gdb_version (gdb_stdout, false);
-      wrap_here ("");
+      gdb_stdout->wrap_here (0);
       printf_filtered ("\n");
       exit (0);
     }
@@ -1140,7 +1135,7 @@ captured_main_1 (struct captured_main_args *context)
   if (print_configuration)
     {
       print_gdb_configuration (gdb_stdout);
-      wrap_here ("");
+      gdb_stdout->wrap_here (0);
       printf_filtered ("\n");
       exit (0);
     }
@@ -1156,7 +1151,7 @@ captured_main_1 (struct captured_main_args *context)
       print_gdb_version (gdb_stdout, true);
       if (symarg)
        printf_filtered ("..");
-      wrap_here ("");
+      gdb_stdout->wrap_here (0);
       printf_filtered ("\n");
       gdb_flush (gdb_stdout);  /* Force to screen during slow
                                   operations.  */
@@ -1177,7 +1172,7 @@ captured_main_1 (struct captured_main_args *context)
       print_gdb_version (gdb_stdout, true);
       if (symarg)
        printf_filtered ("..");
-      wrap_here ("");
+      gdb_stdout->wrap_here (0);
       printf_filtered ("\n");
       gdb_flush (gdb_stdout);  /* Force to screen during slow
                                   operations.  */