]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
More cleanups. Add `current_interp_command_loop()'.
authorAndrew Cagney <cagney@redhat.com>
Tue, 4 Feb 2003 16:52:10 +0000 (16:52 +0000)
committerAndrew Cagney <cagney@redhat.com>
Tue, 4 Feb 2003 16:52:10 +0000 (16:52 +0000)
gdb/ChangeLog
gdb/cli/cli-interp.c
gdb/interps.c
gdb/interps.h
gdb/main.c
gdb/mi/mi-main.c

index 0b7a1e3b4e37cac2bef68af0a3236535fec42647..bd9722c1b6ce6bbf72c8f22d3f5a705a38c1dd03 100644 (file)
@@ -1,3 +1,13 @@
+2003-02-04  Andrew Cagney  <ac131313@redhat.com>
+
+       * interps.c (current_interp_command_loop): New function.
+
+       * main.c (captured_command_loop): Call current_interp_command_loop.
+
+       * interps.h (current_interp_command_loop): Declare.
+       (interp_command_loop_ftype): Define.
+       (struct interp_procs): Add command_loop_proc.
+
 2003-02-03  Andrew Cagney  <ac131313@redhat.com>
 
        * interps.c (gdb_interpreter_get_procs): Delete function.
index 1056d4b5670c4d483f6e0075e39101aac32d04cb..09a82251ff3a4cf89cb41c07d30b9b7dc8696f40 100644 (file)
@@ -25,6 +25,7 @@
 #include "ui-out.h"
 #include "cli-out.h"
 #include "top.h"               /* for "execute_command" */
+#include "gdb_string.h"
 
 struct ui_out *cli_uiout;
 
@@ -81,8 +82,7 @@ cli_interpreter_exec (void *data, const char *command_str)
 
   /* FIXME: cagney/2003-02-01: Need to const char *propogate
      safe_execute_command.  */
-  char *str = alloca (strlen (command_str) + 1);
-  strcpy (str, command_str);
+  char *str = strcpy (alloca (strlen (command_str) + 1), command_str);
 
   /* gdb_stdout could change between the time cli_uiout was initialized
      and now. Since we're probably using a different interpreter which has
index 01d5613759a15a555152f3c95c9e5af66b7aaf63..c61c08a373a4642006e6b5a86b2a53465ebd1c35 100644 (file)
 #include "gdb_string.h"
 #include "gdb-events.h"
 #include "gdb_assert.h"
+#include "top.h"               /* For command_loop.  */
 
 struct interp
 {
   /* This is the name in "-i=" and set interpreter. */
   const char *name;
 
-  /* Interpreters are stored in a linked list, this is the next one... */
+  /* Interpreters are stored in a linked list, this is the next
+     one...  */
   struct interp *next;
 
-  /* This is a cookie that the instance of the interpreter can use, for
-     instance to call itself in hook functions */
+  /* This is a cookie that an instance of the interpreter can use.
+     This is a bit confused right now as the exact initialization
+     sequence for it, and how it relates to the interpreter's uiout
+     object is a bit confused.  */
   void *data;
 
   /* Has the init_proc been run? */
@@ -59,7 +63,7 @@ struct interp
 
   /* This is the ui_out used to collect results for this interpreter.
      It can be a formatter for stdout, as is the case for the console
-     & mi outputs, or it might be a result formatter. */
+     & mi outputs, or it might be a result formatter.  */
   struct ui_out *interpreter_out;
 
   const struct interp_procs *procs;
@@ -245,9 +249,9 @@ current_interp_named_p (const char *interp_name)
   return 0;
 }
 
-/* This is called in display_gdb_prompt.
-   If the proc returns a zero value, display_gdb_prompt will
-   return without displaying the prompt.  */
+/* This is called in display_gdb_prompt.  If the proc returns a zero
+   value, display_gdb_prompt will return without displaying the
+   prompt.  */
 int
 current_interp_display_prompt_p (void)
 {
@@ -259,6 +263,22 @@ current_interp_display_prompt_p (void)
                                                      data);
 }
 
+/* Run the current command interpreter's main loop.  */
+void
+current_interp_command_loop (void)
+{
+  /* Somewhat messy.  For the moment prop up all the old ways of
+     selecting the command loop.  `command_loop_hook' should be
+     deprecated.  */
+  if (command_loop_hook != NULL)
+    command_loop_hook ();
+  else if (current_interpreter != NULL
+          && current_interpreter->procs->command_loop_proc != NULL)
+    current_interpreter->procs->command_loop_proc (current_interpreter->data);
+  else
+    command_loop ();
+}
+
 int
 interp_quiet_p (struct interp *interp)
 {
index 1bf37bfa988bdfc8476eb519220d5d484fd9fc67..7bb1675b5c75f5cf19b0d6250a8ae9408f6c08b0 100644 (file)
@@ -32,19 +32,21 @@ extern int interp_exec_p (struct interp *interp);
 extern int interp_exec (struct interp *interp, const char *command);
 extern int interp_quiet_p (struct interp *interp);
 
-typedef void *(*interp_init_ftype) (void);
-typedef int (*interp_resume_ftype) (void *data);
-typedef int (*interp_suspend_ftype) (void *data);
-typedef int (*interp_prompt_p_ftype) (void *data);
-typedef int (*interp_exec_ftype) (void *data, const char *command);
+typedef void *(interp_init_ftype) (void);
+typedef int (interp_resume_ftype) (void *data);
+typedef int (interp_suspend_ftype) (void *data);
+typedef int (interp_prompt_p_ftype) (void *data);
+typedef int (interp_exec_ftype) (void *data, const char *command);
+typedef int (interp_command_loop_ftype) (void *data);
 
 struct interp_procs
 {
-  interp_init_ftype init_proc;
-  interp_resume_ftype resume_proc;
-  interp_suspend_ftype suspend_proc;
-  interp_exec_ftype exec_proc;
-  interp_prompt_p_ftype prompt_proc_p;
+  interp_init_ftype *init_proc;
+  interp_resume_ftype *resume_proc;
+  interp_suspend_ftype *suspend_proc;
+  interp_exec_ftype *exec_proc;
+  interp_prompt_p_ftype *prompt_proc_p;
+  interp_command_loop_ftype *command_loop_proc;
 };
 
 extern struct interp *interp_new (const char *name, void *data,
@@ -57,6 +59,7 @@ extern struct ui_out *interp_ui_out (struct interp *interp);
 
 extern int current_interp_named_p (const char *name);
 extern int current_interp_display_prompt_p (void);
+extern void current_interp_command_loop (void);
 
 extern void clear_interpreter_hooks ();
 
index 7cb74ce97bdd614cba42b296fb6684c42f81e670..a1dbf4662f8727831418046a84c3987a0a11add3 100644 (file)
@@ -96,10 +96,7 @@ extern char *external_editor_command;
 static int
 captured_command_loop (void *data)
 {
-  if (command_loop_hook == NULL)
-    command_loop ();
-  else
-    command_loop_hook ();
+  current_interp_command_loop ();
   /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton
      would clean things up (restoring the cleanup chain) to the state
      they were just prior to the call.  Technically, this means that
index 54450fd91b4a7f81eb9e43ae3bd5b7ccddfe17f7..2f21f74cf6685e6e683c30e5d6f6bd929621fb0d 100644 (file)
@@ -1162,7 +1162,6 @@ captured_mi_execute_command (struct ui_out *uiout, void *data)
 
       /* If we changed interpreters, DON'T print out anything. */
       if (current_interp_named_p (INTERP_MI)
-         || current_interp_named_p (INTERP_MI2)
          || current_interp_named_p (INTERP_MI1))
        {
          /* print the result */