Change file close behavior for tee_file

Instead of using two bools to decide if the files should close when tee_file
is closed, make file one stay open and file two close.  This simplifies the
use cases for it.

Inline the make_logging_output into the calling functions (the logic here
looks ugly in order to simplify a later change).

Expand ui-redirect.exp to cover the changes, similar to mi-logging.exp.

gdb/ChangeLog:

	* cli/cli-interp.c (cli_interp_base::set_logging): Create tee_file
	directly.
	* cli/cli-interp.h (make_logging_output): Remove declaration.
	* cli/cli-logging.c (make_logging_output): Remove function.
	* mi/mi-interp.c (mi_interp::set_logging): Create tee_file
	directly.
	* ui-file.c (tee_file::tee_file): Remove bools.
	(tee_file::~tee_file): Remove deletes.
	* ui-file.h (tee_file): Remove bools.

gdb/testsuite/ChangeLog:

	* gdb.base/ui-redirect.exp: Test redirection.
This commit is contained in:
Alan Hayward
2019-05-17 14:07:04 +01:00
parent af4fa23fba
commit f3a09c800f
9 changed files with 86 additions and 75 deletions

View File

@ -33,19 +33,6 @@ public:
bool supports_command_editing () override;
};
/* Make the output ui_file to use when logging is enabled.
CURR_OUTPUT is the stream where output is currently being sent to
(e.g., gdb_stdout for the CLI, raw output stream for the MI).
LOGFILE is the log file already opened by the caller.
LOGGING_REDIRECT is the value of the "set logging redirect"
setting. If true, the resulting output is the logfile. If false,
the output stream is a tee, with the log file as one of the
outputs. Ownership of LOGFILE is transferred to the returned
output file, which is an owning pointer. */
extern ui_file *make_logging_output (ui_file *curr_output,
ui_file_up logfile,
bool logging_redirect);
/* The CLI interpreter's set_logging_proc method. Exported so other
interpreters can reuse it. */
extern void cli_set_logging (struct interp *interp,