This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[interps] Fix mi1 console problem


This (committed to interps branch) fixes the MI1 startup message problem. It is a little brutish but it works.

It also fixes another problem:

./gdb -i=mi --version

would print the version using MI output (or worse for the TUI, in curses mode) (I think that is wrong). The patch delays the switch to the cli mode until after it is clear that the TUI/MI really is going to start.

Andrew
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.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.323.2.1
diff -u -r1.323.2.1 Makefile.in
--- Makefile.in	3 Feb 2003 06:02:44 -0000	1.323.2.1
+++ Makefile.in	3 Feb 2003 21:11:08 -0000
@@ -1876,7 +1876,7 @@
 	$(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: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.24.2.1
diff -u -r1.24.2.1 main.c
--- main.c	3 Feb 2003 06:02:45 -0000	1.24.2.1
+++ main.c	3 Feb 2003 21:11:08 -0000
@@ -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 @@
 #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 @@
 	    }
 #endif /* GDBTK */
 	  case 'i':
+	    xfree (interpreter_p);
 	    interpreter_p = xstrdup (optarg);
 	    break;
 	  case 'd':
@@ -516,7 +524,10 @@
   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 @@
       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: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.70.2.1
diff -u -r1.70.2.1 top.c
--- top.c	3 Feb 2003 06:02:45 -0000	1.70.2.1
+++ top.c	3 Feb 2003 21:11:08 -0000
@@ -2126,31 +2126,4 @@
   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);
-      }
-  }
 }
Index: testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 mi-support.exp
--- testsuite/lib/mi-support.exp	3 Feb 2003 06:02:47 -0000	1.21.2.1
+++ testsuite/lib/mi-support.exp	3 Feb 2003 21:11:08 -0000
@@ -127,22 +127,22 @@
 	    # 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]