/* Manages interpreters for GDB, the GNU debugger.
- Copyright (C) 2000, 2002, 2003, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002-2003, 2007-2012 Free Software Foundation,
+ Inc.
Written by Jim Ingham <jingham@apple.com> of Apple Computer, Inc.
#include "exceptions.h"
#include "continuations.h"
+/* True if the current interpreter in is async mode. See interps.h
+ for more details. This starts out disabled, until all the explicit
+ command line arguments (e.g., `gdb -ex "start" -ex "next"') are
+ processed. */
+int interpreter_async = 0;
+
struct interp
{
/* This is the name in "-i=" and set interpreter. */
/* Has the init_proc been run? */
int inited;
- /* 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. */
- struct ui_out *interpreter_out;
-
const struct interp_procs *procs;
int quiet_p;
};
fills the fields from the inputs, and returns a pointer to the
interpreter. */
struct interp *
-interp_new (const char *name, void *data, struct ui_out *uiout,
- const struct interp_procs *procs)
+interp_new (const char *name, const struct interp_procs *procs)
{
struct interp *new_interp;
new_interp = XMALLOC (struct interp);
new_interp->name = xstrdup (name);
- new_interp->data = data;
- new_interp->interpreter_out = uiout;
+ new_interp->data = NULL;
new_interp->quiet_p = 0;
new_interp->procs = procs;
new_interp->inited = 0;
if (current_interpreter != NULL)
{
- do_all_continuations ();
- ui_out_flush (uiout);
+ ui_out_flush (current_uiout);
if (current_interpreter->procs->suspend_proc
&& !current_interpreter->procs->suspend_proc (current_interpreter->
data))
interpreter_p = xstrdup (current_interpreter->name);
}
- uiout = interp->interpreter_out;
-
/* Run the init proc. If it fails, try to restore the old interp. */
if (!interp->inited)
{
if (interp->procs->init_proc != NULL)
{
- interp->data = interp->procs->init_proc (top_level);
+ interp->data = interp->procs->init_proc (interp, top_level);
}
interp->inited = 1;
}
+ /* Do this only after the interpreter is initialized. */
+ current_uiout = interp->procs->ui_out_proc (interp);
+
/* Clear out any installed interpreter hooks/event handlers. */
clear_interpreter_hooks ();
{
sprintf (buffer, "Switching to interpreter \"%.24s\".\n",
interp->name);
- ui_out_text (uiout, buffer);
+ ui_out_text (current_uiout, buffer);
}
display_gdb_prompt (NULL);
}
interp_ui_out (struct interp *interp)
{
if (interp != NULL)
- return interp->interpreter_out;
+ return interp->procs->ui_out_proc (interp);
+
+ return current_interpreter->procs->ui_out_proc (current_interpreter);
+}
+
+/* Returns the interpreter's cookie. */
- return current_interpreter->interpreter_out;
+void *
+interp_data (struct interp *interp)
+{
+ return interp->data;
+}
+
+/* Returns the interpreter's name. */
+
+const char *
+interp_name (struct interp *interp)
+{
+ return interp->name;
}
/* Returns true if the current interp is the passed in name. */