Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v3 02/21] Move stdtarg to ui
Date: Fri, 30 Jan 2026 06:17:16 -0700	[thread overview]
Message-ID: <20260130-pr-28948-logging-5-v3-2-3eec47ef3cba@tromey.com> (raw)
In-Reply-To: <20260130-pr-28948-logging-5-v3-0-3eec47ef3cba@tromey.com>

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.
---
 gdb/main.c  | 2 --
 gdb/top.c   | 6 ++++++
 gdb/ui.c    | 3 ++-
 gdb/ui.h    | 2 ++
 gdb/utils.h | 5 +++--
 5 files changed, 13 insertions(+), 5 deletions(-)

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 &current_ui->m_gdb_stdlog;
 }
 
+struct ui_file **
+current_ui_gdb_stdtarg_ptr ()
+{
+  return &current_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.  */

-- 
2.49.0


  parent reply	other threads:[~2026-01-30 13:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 13:17 [PATCH v3 00/21] Rework gdb logging and output redirection Tom Tromey
2026-01-30 13:17 ` [PATCH v3 01/21] Remove unnecessary override of write_async_safe Tom Tromey
2026-01-30 13:17 ` Tom Tromey [this message]
2026-01-30 13:17 ` [PATCH v3 03/21] Turn wrapped_file into a template Tom Tromey
2026-01-30 13:17 ` [PATCH v3 04/21] Small rewrite of get_unbuffered Tom Tromey
2026-01-30 13:17 ` [PATCH v3 05/21] Move buffered stream to new files Tom Tromey
2026-01-30 13:17 ` [PATCH v3 06/21] Remove TYPE_FN_FIELD_STUB and associated code Tom Tromey
2026-01-30 13:17 ` [PATCH v3 07/21] Change how stdin is handled in the UI Tom Tromey
2026-01-30 13:17 ` [PATCH v3 08/21] Remove gdb_stdtargin Tom Tromey
2026-01-30 13:17 ` [PATCH v3 09/21] Improve fputs_highlighted by using ui_file::write Tom Tromey
2026-01-30 13:17 ` [PATCH v3 10/21] Add stream to buffer_group::output_unit constructor Tom Tromey
2026-01-30 13:17 ` [PATCH v3 11/21] Restore ui_file::can_page Tom Tromey
2026-01-30 13:17 ` [PATCH v3 12/21] Rewrite cli-style.c:do_show Tom Tromey
2026-01-30 13:17 ` [PATCH v3 13/21] Remove m_applied_style from ui_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 14/21] Add a new logging_file implementation Tom Tromey
2026-01-30 13:17 ` [PATCH v3 15/21] Rewrite output redirection and logging Tom Tromey
2026-01-30 13:17 ` [PATCH v3 16/21] Remove tee_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 17/21] Warn if log file changed while logging Tom Tromey
2026-01-30 13:17 ` [PATCH v3 18/21] Fix leaks with timestamped_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 19/21] Use std::make_unique with ui_files Tom Tromey
2026-01-30 13:17 ` [PATCH v3 20/21] Style filenames in cli-logging.c Tom Tromey
2026-01-30 13:17 ` [PATCH v3 21/21] Update gdb.execute documentation Tom Tromey
2026-01-30 13:35   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260130-pr-28948-logging-5-v3-2-3eec47ef3cba@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox