]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-02-03 Andrew Cagney <ac131313@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Mon, 3 Feb 2003 21:13:29 +0000 (21:13 +0000)
committerAndrew Cagney <cagney@redhat.com>
Mon, 3 Feb 2003 21:13:29 +0000 (21:13 +0000)
* top.c (gdb_init): Move interpreter init code from here ...
* main.c (captured_main): ... to here.  Include "interps.h".
(captured_main): Set interpreter_p to a default before parsing the
options.
* Makefile.in (main.o): Update dependencies.

gdb/ChangeLog
gdb/Makefile.in
gdb/main.c
gdb/testsuite/lib/mi-support.exp
gdb/top.c

index de814f0d8950886850d94e6327d9c3568876e7d0..5a1b7db165fcf74e8bbfb6fc71d85923e90717c9 100644 (file)
@@ -1,3 +1,11 @@
+2003-02-03  Andrew Cagney  <ac131313@redhat.com>
+
+       * top.c (gdb_init): Move interpreter init code from here ...
+       * main.c (captured_main): ... to here.  Include "interps.h".
+       (captured_main): Set interpreter_p to a default before parsing the
+       options.
+       * Makefile.in (main.o): Update dependencies.
+
 2002-11-05  Elena Zannoni  <ezannoni@redhat.com>
 
         * defs.h (selected_frame_level_changed_hook): Removed.
index 730d6e546867833a25b021ca0d73cd7ef9c885ca..b15e71f72f7d87a6af97f829d61f58d5009c504b 100644 (file)
@@ -1876,7 +1876,7 @@ macrotab.o: macrotab.c $(defs_h) $(gdb_obstack_h) $(splay_tree_h) \
        $(bcache_h) $(complaints_h)
 main.o: main.c $(defs_h) $(top_h) $(target_h) $(inferior_h) $(symfile_h) \
        $(gdbcore_h) $(getopt_h) $(gdb_stat_h) $(gdb_string_h) \
-       $(event_loop_h) $(ui_out_h) $(main_h)
+       $(event_loop_h) $(ui_out_h) $(main_h) $(interps_h)
 maint.o: maint.c $(defs_h) $(command_h) $(gdbcmd_h) $(symtab_h) \
        $(gdbtypes_h) $(demangle_h) $(gdbcore_h) $(expression_h) \
        $(language_h) $(symfile_h) $(objfiles_h) $(value_h) $(cli_decode_h)
index fdc5c1bb5f662a9e2ee6a0d01273bbd1309e0b75..754e836768c22c5f7edf7cc66ef3aac3fbecfe1b 100644 (file)
@@ -37,6 +37,7 @@
 #include "event-loop.h"
 #include "ui-out.h"
 
+#include "interps.h"
 #include "main.h"
 
 /* If nonzero, display time usage both at startup and for each command.  */
@@ -234,6 +235,12 @@ captured_main (void *data)
 #endif
 #endif
 
+  /* There will always be an interpreter.  Either the one passed into
+     this captured main (not yet implemented), or one specified by the
+     user at start up, or the console.  Make life easier by always
+     initializing the interpreter to something.  */
+  interpreter_p = xstrdup (GDB_INTERPRETER_CONSOLE);
+
   /* Parse arguments and options.  */
   {
     int c;
@@ -388,6 +395,7 @@ extern int gdbtk_test (char *);
            }
 #endif /* GDBTK */
          case 'i':
+           xfree (interpreter_p);
            interpreter_p = xstrdup (optarg);
            break;
          case 'd':
@@ -516,7 +524,10 @@ extern int gdbtk_test (char *);
   gdb_init (argv[0]);
 
   /* Do these (and anything which might call wrap_here or *_filtered)
-     after initialize_all_files.  */
+     after initialize_all_files() but before the interpreter has been
+     installed.  Otherwize the help/version messages will be eaten by
+     the interpreter's output handler.  */
+
   if (print_version)
     {
       print_gdb_version (gdb_stdout);
@@ -532,7 +543,49 @@ extern int gdbtk_test (char *);
       exit (0);
     }
 
-  if (!quiet)
+  /* 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, GDB_INTERPRETER_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);
+      if (symarg)
+       printf_filtered ("..");
+      wrap_here ("");
+      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. */
+
+  {
+    /* Find it.  */
+    struct gdb_interpreter *interp = gdb_interpreter_lookup (interpreter_p);
+    if (interp == NULL)
+      {
+        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
+                            interpreter_p);
+        exit (1);
+      }
+    /* Install it.  */
+    if (!gdb_interpreter_set (interp))
+      {
+        fprintf_unfiltered (gdb_stderr,
+                           "Interpreter `%s' failed to initialize.\n",
+                            interpreter_p);
+        exit (1);
+      }
+  }
+
+  /* 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 && !gdb_interpreter_current_is_named_p (GDB_INTERPRETER_MI1))
     {
       /* Print all the junk at the top, with trailing "..." if we are about
          to read a symbol file (possibly slowly).  */
index f7eb2652e4fc918f15e7c806fd815a804f952e43..b9c9d3c138c9436d7286838b8576d403d7a4e667 100644 (file)
@@ -127,22 +127,22 @@ proc mi_gdb_start { } {
            # We have a new format mi startup prompt.  If we are
            # running mi1, then this is an error as we should be
            # using the old-style prompt.
-#          if { $MIFLAGS == "-i=mi1" } {
-#              perror "(mi startup) Got unexpected new mi prompt."
-#              remote_close host;
-#              return -1;
-#          }
+           if { $MIFLAGS == "-i=mi1" } {
+               perror "(mi startup) Got unexpected new mi prompt."
+               remote_close host;
+               return -1;
+           }
            verbose "GDB initialized."
        }
        -re "\[^~\].*$mi_gdb_prompt$" {
            # We have an old format mi startup prompt.  If we are
            # not running mi1, then this is an error as we should be
            # using the new-style prompt.
-#          if { $MIFLAGS != "-i=mi1" } {
-#              perror "(mi startup) Got unexpected old mi prompt."
-#              remote_close host;
-#              return -1;
-#          }
+           if { $MIFLAGS != "-i=mi1" } {
+               perror "(mi startup) Got unexpected old mi prompt."
+               remote_close host;
+               return -1;
+           }
            verbose "GDB initialized."
        }
        -re ".*$gdb_prompt $" {
index d93a98db1938055d19de870e90fbfa6b003cd642..e488450808b4ccf1d3a61bde2190f74305202d77 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2126,31 +2126,4 @@ gdb_init (char *argv0)
   if (init_ui_hook)
     init_ui_hook (argv0);
 
-  /* Install the default UI */
-  /* All the interpreters should have had a look at things by now.
-     Initialize the selected interpreter. */
-  {
-
-    /* There will always be an interpreter.  Either the one specified
-       by the user at start up or the console.  */
-
-    struct gdb_interpreter *interp;
-    if (interpreter_p == NULL)
-      interpreter_p = xstrdup (GDB_INTERPRETER_CONSOLE);
-
-    interp = gdb_interpreter_lookup (interpreter_p);
-
-    if (interp == NULL)
-      {
-        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
-                            interpreter_p);
-        exit (1);
-      }
-    if (!gdb_interpreter_set (interp))
-      {
-        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' failed to initialize.\n",
-                            interpreter_p);
-        exit (1);
-      }
-  }
 }