aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-12-31 12:00:11 -0700
committerTom Tromey <tom@tromey.com>2022-03-28 14:13:28 -0600
commit52a4a5885af15e7ef32d5f4e5b77f98349c32276 (patch)
tree1ca6af096a9c652bbe8aa4f7347eb178e39ed1f1 /gdb/tui
parent3c6c449e304413f513db5635abd2181776f7db92 (diff)
downloadgdb-52a4a5885af15e7ef32d5f4e5b77f98349c32276.zip
gdb-52a4a5885af15e7ef32d5f4e5b77f98349c32276.tar.gz
gdb-52a4a5885af15e7ef32d5f4e5b77f98349c32276.tar.bz2
Switch gdb_stdlog to use timestamped_file
Currently, timestamps for logging are done by looking for the use of gdb_stdlog in vfprintf_unfiltered. This seems potentially buggy, in that during logging or other redirects (like execute_fn_to_ui_file) we might have gdb_stdout==gdb_stdlog and so, conceivably, wind up with timestamps in a log when they were not desired. It seems better, instead, for timestamps to be a property of the ui_file itself. This patch changes gdb to use the new timestamped_file for gdb_stdlog where appropriate, and removes the special case from vfprintf_unfiltered. Note that this may somewhat change the output in some cases -- in particular, when going through execute_fn_to_ui_file (or the _string variant), timestamps won't be emitted. This could be fixed in those functions, but it wasn't clear to me whether this is really desirable. Note also that this changes the TUI to send gdb_stdlog to gdb_stderr. I imagine that the previous use of gdb_stdout here was inadvertent. (And in any case it probably doesn't matter.)
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-io.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 8cac1c4..01300d8 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -108,11 +108,13 @@ key_is_start_sequence (int ch)
/* 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. */
@@ -828,13 +830,14 @@ tui_setup_io (int mode)
/* 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;
@@ -847,7 +850,7 @@ tui_setup_io (int mode)
/* 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;
@@ -902,6 +905,7 @@ tui_initialize_io (void)
/* 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. */