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.
This commit is contained in:
parent
fe54041627
commit
37ce89ebb2
10 changed files with 260 additions and 22 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "defs.h"
|
||||
#include "gdbcmd.h"
|
||||
#include "ui-out.h"
|
||||
#include "interps.h"
|
||||
#include "gdb_assert.h"
|
||||
|
||||
#include "gdb_string.h"
|
||||
|
@ -115,11 +116,17 @@ set_logging_redirect (char *args, int from_tty, struct cmd_list_element *c)
|
|||
logging_filename);
|
||||
}
|
||||
|
||||
gdb_stdout = output;
|
||||
gdb_stderr = output;
|
||||
gdb_stdlog = output;
|
||||
gdb_stdtarg = output;
|
||||
gdb_stdtargerr = output;
|
||||
/* Give the current interpreter a chance to do anything special that
|
||||
it might need for logging, such as updating other channels. */
|
||||
if (current_interp_set_logging (1, output, NULL) == 0)
|
||||
{
|
||||
gdb_stdout = output;
|
||||
gdb_stdlog = output;
|
||||
gdb_stderr = output;
|
||||
gdb_stdtarg = output;
|
||||
gdb_stdtargerr = output;
|
||||
}
|
||||
|
||||
logging_no_redirect_file = new_logging_no_redirect_file;
|
||||
|
||||
/* There is a former output pushed on the ui_out_redirect stack. We
|
||||
|
@ -147,19 +154,25 @@ show_logging_redirect (struct ui_file *file, int from_tty,
|
|||
static void
|
||||
pop_output_files (void)
|
||||
{
|
||||
/* Only delete one of the files -- they are all set to the same
|
||||
value. */
|
||||
ui_file_delete (gdb_stdout);
|
||||
if (logging_no_redirect_file)
|
||||
{
|
||||
ui_file_delete (logging_no_redirect_file);
|
||||
logging_no_redirect_file = NULL;
|
||||
}
|
||||
gdb_stdout = saved_output.out;
|
||||
gdb_stderr = saved_output.err;
|
||||
gdb_stdlog = saved_output.log;
|
||||
gdb_stdtarg = saved_output.targ;
|
||||
gdb_stdtargerr = saved_output.targ;
|
||||
|
||||
if (current_interp_set_logging (0, NULL, NULL) == 0)
|
||||
{
|
||||
/* Only delete one of the files -- they are all set to the same
|
||||
value. */
|
||||
ui_file_delete (gdb_stdout);
|
||||
|
||||
gdb_stdout = saved_output.out;
|
||||
gdb_stderr = saved_output.err;
|
||||
gdb_stdlog = saved_output.log;
|
||||
gdb_stdtarg = saved_output.targ;
|
||||
gdb_stdtargerr = saved_output.targ;
|
||||
}
|
||||
|
||||
saved_output.out = NULL;
|
||||
saved_output.err = NULL;
|
||||
saved_output.log = NULL;
|
||||
|
@ -175,6 +188,7 @@ handle_redirections (int from_tty)
|
|||
{
|
||||
struct cleanup *cleanups;
|
||||
struct ui_file *output;
|
||||
struct ui_file *no_redirect_file = NULL;
|
||||
|
||||
if (saved_filename != NULL)
|
||||
{
|
||||
|
@ -191,7 +205,7 @@ handle_redirections (int from_tty)
|
|||
/* Redirects everything to gdb_stdout while this is running. */
|
||||
if (!logging_redirect)
|
||||
{
|
||||
struct ui_file *no_redirect_file = output;
|
||||
no_redirect_file = output;
|
||||
|
||||
output = tee_file_new (gdb_stdout, 0, no_redirect_file, 0);
|
||||
if (output == NULL)
|
||||
|
@ -220,14 +234,22 @@ handle_redirections (int from_tty)
|
|||
saved_output.targ = gdb_stdtarg;
|
||||
saved_output.targerr = gdb_stdtargerr;
|
||||
|
||||
gdb_stdout = output;
|
||||
gdb_stderr = output;
|
||||
gdb_stdlog = output;
|
||||
gdb_stdtarg = output;
|
||||
gdb_stdtargerr = output;
|
||||
/* Let the interpreter do anything it needs. */
|
||||
if (current_interp_set_logging (1, output, no_redirect_file) == 0)
|
||||
{
|
||||
gdb_stdout = output;
|
||||
gdb_stdlog = output;
|
||||
gdb_stderr = output;
|
||||
gdb_stdtarg = output;
|
||||
gdb_stdtargerr = output;
|
||||
}
|
||||
|
||||
if (ui_out_redirect (current_uiout, output) < 0)
|
||||
warning (_("Current output protocol does not support redirection"));
|
||||
/* Don't do the redirect for MI, it confuses MI's ui-out scheme. */
|
||||
if (!ui_out_is_mi_like_p (current_uiout))
|
||||
{
|
||||
if (ui_out_redirect (current_uiout, output) < 0)
|
||||
warning (_("Current output protocol does not support redirection"));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue