diff options
Diffstat (limited to 'gdb/mi/mi-interp.c')
-rw-r--r-- | gdb/mi/mi-interp.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index f167a53..aa76989 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -1373,33 +1373,25 @@ mi_ui_out (struct interp *interp) /* 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) +static void +mi_set_logging (struct interp *interp, + ui_file_up logfile, bool logging_redirect) { struct mi_interp *mi = (struct mi_interp *) interp_data (interp); - if (!mi) - return 0; + gdb_assert (mi != NULL); - if (start_log) + if (logfile != NULL) { - /* 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) - { - delete out; - out = new tee_file (mi->raw_stdout, false, logfile, false); - } - mi->saved_raw_stdout = mi->raw_stdout; - mi->raw_stdout = out; + mi->raw_stdout = make_logging_output (mi->raw_stdout, + std::move (logfile), + logging_redirect); + } else { + delete mi->raw_stdout; mi->raw_stdout = mi->saved_raw_stdout; mi->saved_raw_stdout = NULL; } @@ -1409,8 +1401,6 @@ mi_set_logging (struct interp *interp, int start_log, mi->log->set_raw (mi->raw_stdout); mi->targ->set_raw (mi->raw_stdout); mi->event_channel->set_raw (mi->raw_stdout); - - return 1; } /* The MI interpreter's vtable. */ |