From: Tom Tromey Date: Sun, 7 Dec 2025 23:29:17 +0000 (-0600) Subject: Move stdtarg to ui X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46db0279b1a5c4b25a533ac22361983953335276;p=thirdparty%2Fbinutils-gdb.git Move stdtarg to ui Currently, most of the output streams are handled by the UI -- with the sole exception of gdb_stdtarg. This doesn't make sense to me, and it is is useful in the longer term to make it per-UI so that the logging approach can be uniform across all streams. So, this moves it to the UI, following the implementation approach of all other output streams. Approved-By: Andrew Burgess --- diff --git a/gdb/main.c b/gdb/main.c index 296f59b0b57..ac83b953cf2 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -81,7 +81,6 @@ std::string python_libdir; /* Target IO streams. */ struct ui_file *gdb_stdtargin; -struct ui_file *gdb_stdtarg; /* True if --batch or --batch-silent was seen. */ int batch_flag = 0; @@ -695,7 +694,6 @@ captured_main_1 (struct captured_main_args *context) gdb_internal_backtrace_init_str (); current_ui = main_ui; - gdb_stdtarg = gdb_stderr; gdb_stdtargin = gdb_stdin; /* Put a CLI based uiout in place early. If the early initialization diff --git a/gdb/top.c b/gdb/top.c index f1d0baeb3f4..e7d1ded96e4 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -115,6 +115,12 @@ current_ui_gdb_stdlog_ptr () return ¤t_ui->m_gdb_stdlog; } +struct ui_file ** +current_ui_gdb_stdtarg_ptr () +{ + return ¤t_ui->m_gdb_stdtarg; +} + struct ui_out ** current_ui_current_uiout_ptr () { diff --git a/gdb/ui.c b/gdb/ui.c index 3e1ef9f8a34..6d29026117e 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -51,7 +51,8 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) m_gdb_stdout (new pager_file (new stdio_file (outstream))), m_gdb_stdin (new stdio_file (instream)), m_gdb_stderr (new stderr_file (errstream)), - m_gdb_stdlog (new timestamped_file (m_gdb_stderr)) + m_gdb_stdlog (new timestamped_file (m_gdb_stderr)), + m_gdb_stdtarg (m_gdb_stderr) { unbuffer_stream (instream_); diff --git a/gdb/ui.h b/gdb/ui.h index 10159b1c38e..ba98d2500af 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -155,6 +155,8 @@ struct ui /* Log/debug/trace messages that should bypass normal stdout/stderr filtering. */ struct ui_file *m_gdb_stdlog; + /* Target output. */ + struct ui_file *m_gdb_stdtarg; /* The current ui_out. */ struct ui_out *m_current_uiout = nullptr; diff --git a/gdb/utils.h b/gdb/utils.h index 5f6b54d2953..4f11cbf379f 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -169,6 +169,7 @@ extern struct ui_file **current_ui_gdb_stdout_ptr (void); extern struct ui_file **current_ui_gdb_stdin_ptr (void); extern struct ui_file **current_ui_gdb_stderr_ptr (void); extern struct ui_file **current_ui_gdb_stdlog_ptr (void); +extern struct ui_file **current_ui_gdb_stdtarg_ptr (); /* Flush STREAM. */ extern void gdb_flush (struct ui_file *stream); @@ -185,11 +186,11 @@ extern void gdb_flush (struct ui_file *stream); /* Log/debug/trace messages that bypasses the pager, if one is in use. */ #define gdb_stdlog (*current_ui_gdb_stdlog_ptr ()) +/* Target output. */ +#define gdb_stdtarg (*current_ui_gdb_stdtarg_ptr ()) /* Truly global ui_file streams. These are all defined in main.c. */ -/* Target output that should bypass the pager, if one is in use. */ -extern struct ui_file *gdb_stdtarg; extern struct ui_file *gdb_stdtargin; /* Set the screen dimensions to WIDTH and HEIGHT. */