summaryrefslogtreecommitdiff
path: root/gdb/interps.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2011-09-12 21:24:47 +0000
committerPedro Alves <pedro@codesourcery.com>2011-09-12 21:24:47 +0000
commit17bdafbc84cbd5d4a7ab004086f3380355bd11e8 (patch)
treeac5848f546d37b6a4658552a8b246192e6160bcb /gdb/interps.c
parentbe6ea846156ab73309712e82a2ac1db1f4536107 (diff)
downloadgdb-17bdafbc84cbd5d4a7ab004086f3380355bd11e8.tar.gz
gdb/
2011-09-12 Pedro Alves <pedro@codesourcery.com> Matt Rice <ratmice@gmail.com> PR gdb/13175 * interps.c (struct interp) <interpreter_out>: Delete field. (interp_new): Remove the data and uiout parameters and adjust. (interp_set): Only set the current_uiout from the interpreter's uiout after initializing the interpreter. Adjust call to init_proc. (interp_ui_out): Adjust to call procs->ui_out_proc. (interp_data, interp_name): New. * interps.h (interp_init_ftype): Add `self' parameter. (interp_ui_out_ftype): New typedef. (struct interp_procs) <ui_out_proc>: New method pointer. (interp_new): Remove the data and uiout parameters. (interp_data, interp_name): Declare. * tui/tui-interp.c (tui_init): Adjust prototype. (tui_ui_out): New. (_initialize_tui_interp): Install tui_ui_out. Don't instanciate tui_out here. Adjust call to interp_new. * tui/tui-io.c (tui_initialize_io): Don't set current_uiout here. * cli/cli-interp.c (cli_interpreter_init): Adjust prototype. (cli_ui_out): New. (_initialize_cli_interp): Install it. Adjust call to interp_new. * mi/mi-common.h (struct mi_interp) <uiout>: New field. * mi/mi-interp.c (mi_interpreter_init): Adjust prototype. Initialize mi->uiout depending on the mi_version as extracted from the interpreter's name. (mi_ui_out): New. (_initialize_mi_interp): Install mi_ui_out. Adjust calls to interp_new. Don't allocate the ui_out's of the interpreters here. gdb/testsuite/ 2011-09-12 Matt Rice <ratmice@gmail.com> Pedro Alves <pedro@codesourcery.com> PR gdb/13175 * gdb.base/interp.exp: New tests. * gdb.base/interp.c: New file.
Diffstat (limited to 'gdb/interps.c')
-rw-r--r--gdb/interps.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/gdb/interps.c b/gdb/interps.c
index ff8daf8f7ba..4878a6ab8d3 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -67,11 +67,6 @@ struct interp
/* 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;
};
@@ -97,16 +92,14 @@ static int interpreter_initialized = 0;
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;
@@ -184,19 +177,20 @@ interp_set (struct interp *interp, int top_level)
interpreter_p = xstrdup (current_interpreter->name);
}
- current_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 ();
@@ -254,9 +248,25 @@ struct ui_out *
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. */