aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 4749c38..b4026c1 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -63,6 +63,7 @@
#include <ctype.h>
#include "ui-out.h"
#include "cli-out.h"
+#include "interps.h"
/* Default command line prompt. This is overriden in some configs. */
@@ -386,6 +387,7 @@ catcher (catch_exceptions_ftype *func,
char *saved_error_pre_print;
char *saved_quit_pre_print;
struct ui_out *saved_uiout;
+ struct gdb_interpreter *saved_interp;
/* Return value from SIGSETJMP(): enum return_reason if error or
quit caught, 0 otherwise. */
@@ -408,6 +410,7 @@ catcher (catch_exceptions_ftype *func,
/* Override the global ``struct ui_out'' builder. */
saved_uiout = uiout;
+ saved_interp = gdb_current_interpreter ();
uiout = func_uiout;
/* Prevent error/quit during FUNC from calling cleanups established
@@ -438,7 +441,24 @@ catcher (catch_exceptions_ftype *func,
restore_cleanups (saved_cleanup_chain);
- uiout = saved_uiout;
+ /*
+ cases:
+ 1. interp1 calls using uiout1
+ 2. interp1 calls using uiout1 calls using uiout2
+ 3. interp1 calls using uiout1 calls interp2 using uiout2
+ 4. more?
+ is it enough to note that the interpreter has changed and
+ reset saved_uiout
+ */
+ if (gdb_current_interpreter () == saved_interp)
+ uiout = saved_uiout;
+ else
+ {
+ /* We've changed interpreters under this call.
+ Reset uiout to the current interpreter's uiout
+ and hope for the best. */
+ uiout = gdb_interpreter_ui_out (NULL);
+ }
if (mask & RETURN_MASK_QUIT)
quit_pre_print = saved_quit_pre_print;
@@ -2088,17 +2108,26 @@ gdb_init (char *argv0)
init_ui_hook (argv0);
/* Install the default UI */
- if (!init_ui_hook)
- {
- uiout = cli_out_new (gdb_stdout);
+ /* All the interpreters should have had a look at things by now.
+ Initialize the selected interpreter. */
+ {
+ struct gdb_interpreter *interp;
+ if (interpreter_p == NULL)
+ interpreter_p = xstrdup (GDB_INTERPRETER_CONSOLE);
- /* All the interpreters should have had a look at things by now.
- Initialize the selected interpreter. */
- if (interpreter_p)
- {
- fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
- interpreter_p);
- exit (1);
- }
- }
+ interp = gdb_lookup_interpreter (interpreter_p);
+
+ if (interp == NULL)
+ {
+ fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
+ interpreter_p);
+ exit (1);
+ }
+ if (!gdb_set_interpreter (interp))
+ {
+ fprintf_unfiltered (gdb_stderr, "Interpreter `%s' failed to initialize.\n",
+ interpreter_p);
+ exit (1);
+ }
+ }
}