Rename to allow_rust_tests
[binutils-gdb.git] / gdb / main.c
index acb7a45fb7c56a8c0c97c55df9a33d318f62b919..c04d37a45f9165234c5ce41cc9ed546523776da9 100644 (file)
@@ -1,6 +1,6 @@
 /* Top level stuff for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2022 Free Software Foundation, Inc.
+   Copyright (C) 1986-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "observable.h"
 #include "serial.h"
 
-/* The selected interpreter.  This will be used as a set command
-   variable, so it should always be malloc'ed - since
-   do_setshow_command will free it.  */
-char *interpreter_p;
-
-/* Whether dbx commands will be handled.  */
-int dbx_commands = 0;
+/* The selected interpreter.  */
+std::string interpreter_p;
 
 /* System root path, used to find libraries etc.  */
 std::string gdb_sysroot;
@@ -136,12 +131,7 @@ set_gdb_data_directory (const char *new_datadir)
      "../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
      isn't canonical, but that's ok.  */
   if (!IS_ABSOLUTE_PATH (gdb_datadir.c_str ()))
-    {
-      gdb::unique_xmalloc_ptr<char> abs_datadir
-       = gdb_abspath (gdb_datadir.c_str ());
-
-      gdb_datadir = abs_datadir.get ();
-    }
+    gdb_datadir = gdb_abspath (gdb_datadir.c_str ());
 }
 
 /* Relocate a file or directory.  PROGNAME is the name by which gdb
@@ -686,8 +676,9 @@ captured_main_1 (struct captured_main_args *context)
   main_ui = new ui (stdin, stdout, stderr);
   current_ui = main_ui;
 
-  gdb_stdtargerr = gdb_stderr; /* for moment */
-  gdb_stdtargin = gdb_stdin;   /* for moment */
+  gdb_stdtarg = gdb_stderr;
+  gdb_stdtargerr = gdb_stderr;
+  gdb_stdtargin = gdb_stdin;
 
   if (bfd_init () != BFD_INIT_MAGIC)
     error (_("fatal error: libbfd ABI mismatch"));
@@ -737,7 +728,7 @@ captured_main_1 (struct captured_main_args *context)
      this captured main, or one specified by the user at start up, or
      the console.  Initialize the interpreter to the one requested by 
      the application.  */
-  interpreter_p = xstrdup (context->interpreter_p);
+  interpreter_p = context->interpreter_p;
 
   /* Parse arguments and options.  */
   {
@@ -766,7 +757,6 @@ captured_main_1 (struct captured_main_args *context)
     static struct option long_options[] =
     {
       {"tui", no_argument, 0, OPT_TUI},
-      {"dbx", no_argument, &dbx_commands, 1},
       {"readnow", no_argument, NULL, OPT_READNOW},
       {"readnever", no_argument, NULL, OPT_READNEVER},
       {"r", no_argument, NULL, OPT_READNOW},
@@ -875,8 +865,7 @@ captured_main_1 (struct captured_main_args *context)
          case OPT_TUI:
            /* --tui is equivalent to -i=tui.  */
 #ifdef TUI
-           xfree (interpreter_p);
-           interpreter_p = xstrdup (INTERP_TUI);
+           interpreter_p = INTERP_TUI;
 #else
            error (_("%s: TUI mode is not supported"), gdb_program_name);
 #endif
@@ -886,14 +875,12 @@ captured_main_1 (struct captured_main_args *context)
               actually useful, and if it is, what it should do.  */
 #ifdef GDBTK
            /* --windows is equivalent to -i=insight.  */
-           xfree (interpreter_p);
-           interpreter_p = xstrdup (INTERP_INSIGHT);
+           interpreter_p = INTERP_INSIGHT;
 #endif
            break;
          case OPT_NOWINDOWS:
            /* -nw is equivalent to -i=console.  */
-           xfree (interpreter_p);
-           interpreter_p = xstrdup (INTERP_CONSOLE);
+           interpreter_p = INTERP_CONSOLE;
            break;
          case 'f':
            annotation_level = 1;
@@ -959,8 +946,7 @@ captured_main_1 (struct captured_main_args *context)
            }
 #endif /* GDBTK */
          case 'i':
-           xfree (interpreter_p);
-           interpreter_p = xstrdup (optarg);
+           interpreter_p = optarg;
            break;
          case 'd':
            dirarg.push_back (optarg);
@@ -1028,9 +1014,6 @@ captured_main_1 (struct captured_main_args *context)
       }
   }
 
-  if (dbx_commands)
-    warning (_("--dbx mode is deprecated and will be removed"));
-
   save_original_signals_state (quiet);
 
   /* Try to set up an alternate signal stack for SIGSEGV handlers.  */
@@ -1141,31 +1124,11 @@ captured_main_1 (struct captured_main_args *context)
       exit (0);
     }
 
-  /* FIXME: cagney/2003-02-03: The big hack (part 1 of 2) that lets
-     GDB retain the old MI1 interpreter startup behavior.  Output the
-     copyright message before the interpreter is installed.  That way
-     it isn't encapsulated in MI output.  */
-  if (!quiet && strcmp (interpreter_p, INTERP_MI1) == 0)
-    {
-      /* Print all the junk at the top, with trailing "..." if we are
-        about to read a symbol file (possibly slowly).  */
-      print_gdb_version (gdb_stdout, true);
-      if (symarg)
-       gdb_printf ("..");
-      gdb_printf ("\n");
-      gdb_flush (gdb_stdout);  /* Force to screen during slow
-                                  operations.  */
-    }
-
   /* Install the default UI.  All the interpreters should have had a
      look at things by now.  Initialize the default interpreter.  */
-  set_top_level_interpreter (interpreter_p);
+  set_top_level_interpreter (interpreter_p.c_str ());
 
-  /* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets
-     GDB retain the old MI1 interpreter startup behavior.  Output the
-     copyright message after the interpreter is installed when it is
-     any sane interpreter.  */
-  if (!quiet && !current_interp_named_p (INTERP_MI1))
+  if (!quiet)
     {
       /* Print all the junk at the top, with trailing "..." if we are
         about to read a symbol file (possibly slowly).  */
@@ -1437,7 +1400,6 @@ Output and user interface control:\n\n\
 "), stream);
 #endif
   gdb_puts (_("\
-  --dbx              DBX compatibility mode.\n\
   -q, --quiet, --silent\n\
                     Do not print version number on startup.\n\n\
 "), stream);
@@ -1503,8 +1465,8 @@ GDB manual (available as on-line info or a printed manual).\n\
 "), stream);
   if (REPORT_BUGS_TO[0] && stream == gdb_stdout)
     gdb_printf (stream, _("\n\
-Report bugs to %s.\n\
-"), REPORT_BUGS_TO);
+Report bugs to %ps.\n\
+"), styled_string (file_name_style.style (), REPORT_BUGS_TO));
   if (stream == gdb_stdout)
     gdb_printf (stream, _("\n\
 You can ask GDB-related questions on the GDB users mailing list\n\