aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-interp.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2012-06-28 22:11:23 +0000
committerStan Shebs <shebs@codesourcery.com>2012-06-28 22:11:23 +0000
commit37ce89ebb295e6ed0fc0bf5a4eb2e718ed0fb2ee (patch)
treea9444e8dcde7251482e63cd19e2e1edb9550026e /gdb/mi/mi-interp.c
parentfe540416272cd7791a82793a395a4cb65f9fce16 (diff)
downloadfsf-binutils-gdb-37ce89ebb295e6ed0fc0bf5a4eb2e718ed0fb2ee.zip
fsf-binutils-gdb-37ce89ebb295e6ed0fc0bf5a4eb2e718ed0fb2ee.tar.gz
fsf-binutils-gdb-37ce89ebb295e6ed0fc0bf5a4eb2e718ed0fb2ee.tar.bz2
Make logging work for MI.
* NEWS: Mention it. * interps.h (interp_set_logging_ftype): New typedef. (struct interp_procs): New field set_logging_proc. (current_interp_set_logging): Declare. * interps.c (current_interp_set_logging): New function. * cli/cli-logging.c: Include interps.h. (set_logging_redirect): Call current_interp_set_logging. (pop_output_files): Ditto. (handle_redirections): Ditto, plus skip ui-out redirect if MI. * mi/mi-console.h (mi_console_set_raw): Declare. * mi/mi-console.c (mi_console_set_raw): New function. * mi/mi-interp.c (saved_raw_stdout): New global. (mi_set_logging): New function. (_initialize_mi_interp): Add it to interp procs. * gdb.mi/mi-logging.exp: New file.
Diffstat (limited to 'gdb/mi/mi-interp.c')
-rw-r--r--gdb/mi/mi-interp.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index ac0af70..b487136 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -755,6 +755,54 @@ mi_ui_out (struct interp *interp)
return mi->uiout;
}
+/* Save the original value of raw_stdout here when logging, so we can
+ restore correctly when done. */
+
+static struct ui_file *saved_raw_stdout;
+
+/* Do MI-specific logging actions; save raw_stdout, and change all
+ the consoles to use the supplied ui-file(s). */
+
+static int
+mi_set_logging (struct interp *interp, int start_log,
+ struct ui_file *out, struct ui_file *logfile)
+{
+ struct mi_interp *mi = interp_data (interp);
+
+ if (!mi)
+ return 0;
+
+ if (start_log)
+ {
+ /* The tee created already is based on gdb_stdout, which for MI
+ is a console and so we end up in an infinite loop of console
+ writing to ui_file writing to console etc. So discard the
+ existing tee (it hasn't been used yet, and MI won't ever use
+ it), and create one based on raw_stdout instead. */
+ if (logfile)
+ {
+ ui_file_delete (out);
+ out = tee_file_new (raw_stdout, 0, logfile, 0);
+ }
+
+ saved_raw_stdout = raw_stdout;
+ raw_stdout = out;
+ }
+ else
+ {
+ raw_stdout = saved_raw_stdout;
+ saved_raw_stdout = NULL;
+ }
+
+ mi_console_set_raw (mi->out, raw_stdout);
+ mi_console_set_raw (mi->err, raw_stdout);
+ mi_console_set_raw (mi->log, raw_stdout);
+ mi_console_set_raw (mi->targ, raw_stdout);
+ mi_console_set_raw (mi->event_channel, raw_stdout);
+
+ return 1;
+}
+
extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */
void
@@ -767,7 +815,8 @@ _initialize_mi_interp (void)
mi_interpreter_suspend, /* suspend_proc */
mi_interpreter_exec, /* exec_proc */
mi_interpreter_prompt_p, /* prompt_proc_p */
- mi_ui_out /* ui_out_proc */
+ mi_ui_out, /* ui_out_proc */
+ mi_set_logging /* set_logging_proc */
};
/* The various interpreter levels. */