ui_file *targ;
ui_file *targerr;
ui_file_up file_to_delete;
+ ui_file_up log_to_delete;
};
static std::unique_ptr<saved_output_files> saved_output;
else
saved_output->file_to_delete = std::move (logfile);
+ saved_output->log_to_delete.reset
+ (new timestamped_file (debug_redirect ? logfile_p : tee));
+
gdb_stdout = logging_redirect ? logfile_p : tee;
- gdb_stdlog = debug_redirect ? logfile_p : tee;
+ gdb_stdlog = saved_output->log_to_delete.get ();
gdb_stderr = logging_redirect ? logfile_p : tee;
gdb_stdtarg = logging_redirect ? logfile_p : tee;
gdb_stdtargerr = logging_redirect ? logfile_p : tee;
if (!batch_silent)
gdb_stdout = new stdio_file (ui->outstream);
gdb_stderr = new stderr_file (ui->errstream);
- gdb_stdlog = gdb_stderr; /* for moment */
+ gdb_stdlog = new timestamped_file (gdb_stderr);
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
/* TUI output files. */
static struct ui_file *tui_stdout;
static struct ui_file *tui_stderr;
+static struct ui_file *tui_stdlog;
struct ui_out *tui_out;
/* GDB output files in non-curses mode. */
static struct ui_file *tui_old_stdout;
static struct ui_file *tui_old_stderr;
+static struct ui_file *tui_old_stdlog;
cli_ui_out *tui_old_uiout;
/* Readline previous hooks. */
/* Keep track of previous gdb output. */
tui_old_stdout = gdb_stdout;
tui_old_stderr = gdb_stderr;
+ tui_old_stdlog = gdb_stdlog;
tui_old_uiout = dynamic_cast<cli_ui_out *> (current_uiout);
gdb_assert (tui_old_uiout != nullptr);
/* Reconfigure gdb output. */
gdb_stdout = tui_stdout;
gdb_stderr = tui_stderr;
- gdb_stdlog = gdb_stdout; /* for moment */
+ gdb_stdlog = tui_stdlog;
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
current_uiout = tui_out;
/* Restore gdb output. */
gdb_stdout = tui_old_stdout;
gdb_stderr = tui_old_stderr;
- gdb_stdlog = gdb_stdout; /* for moment */
+ gdb_stdlog = tui_old_stdlog;
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
current_uiout = tui_old_uiout;
/* Create tui output streams. */
tui_stdout = new tui_file (stdout);
tui_stderr = new tui_file (stderr);
+ tui_stdlog = new timestamped_file (tui_stderr);
tui_out = tui_out_new (tui_stdout);
/* Create the default UI. */
void
vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
{
- if (debug_timestamp && stream == gdb_stdlog)
- {
- static bool needs_timestamp = true;
-
- /* Print timestamp if previous print ended with a \n. */
- if (needs_timestamp)
- {
- using namespace std::chrono;
-
- steady_clock::time_point now = steady_clock::now ();
- seconds s = duration_cast<seconds> (now.time_since_epoch ());
- microseconds us = duration_cast<microseconds> (now.time_since_epoch () - s);
- std::string timestamp = string_printf ("%ld.%06ld ",
- (long) s.count (),
- (long) us.count ());
- fputs_unfiltered (timestamp.c_str (), stream);
- }
-
- /* Print the message. */
- string_file sfile;
- cli_ui_out (&sfile, 0).vmessage (ui_file_style (), format, args);
- const std::string &linebuffer = sfile.string ();
- fputs_unfiltered (linebuffer.c_str (), stream);
-
- size_t len = linebuffer.length ();
- needs_timestamp = (len > 0 && linebuffer[len - 1] == '\n');
- }
- else
- vfprintf_maybe_filtered (stream, format, args, false);
+ vfprintf_maybe_filtered (stream, format, args, false);
}
void