+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.
#include "ui-out.h"
#include "cli-out.h"
#include "top.h" /* for "execute_command" */
+#include "gdb_string.h"
struct ui_out *cli_uiout;
/* 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
#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? */
/* 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;
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)
{
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)
{
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,
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 ();
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
/* 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 */