Remove gdb_stdtargerr

Message ID 20240514135700.3737770-1-tromey@adacore.com
State New
Headers
Series Remove gdb_stdtargerr |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey May 14, 2024, 1:57 p.m. UTC
  This patch removes gdb_stdtargerr.  There doesn't seem to be a need
for this -- it is always the same as stdtarg, and (I believe) has been
for many years.
---
 gdb/cli/cli-interp.c | 3 ---
 gdb/cli/cli-interp.h | 1 -
 gdb/interps.c        | 1 -
 gdb/main.c           | 2 --
 gdb/mi/mi-interp.c   | 2 --
 gdb/remote-fileio.c  | 2 +-
 gdb/remote-sim.c     | 4 ++--
 gdb/top.c            | 2 --
 gdb/tui/tui-io.c     | 2 --
 gdb/ui-out.c         | 3 ---
 gdb/ui-out.h         | 1 -
 gdb/utils.h          | 1 -
 12 files changed, 3 insertions(+), 21 deletions(-)
  

Comments

Andrew Burgess May 17, 2024, 2:06 p.m. UTC | #1
Tom Tromey <tromey@adacore.com> writes:

> This patch removes gdb_stdtargerr.  There doesn't seem to be a need
> for this -- it is always the same as stdtarg, and (I believe) has been
> for many years.

Looks reasonable to me.

I tried to figure out what gdb_stdtarg and gdb_stdtargin are used for,
and they both appear to be of pretty limited use.  I wonder what value
they are actually adding?

Anyway, if there's ever a burning need for gdb_stdtargerr in the future,
it'll be easy enough to bring back, so for now, I say clean it up.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew



> ---
>  gdb/cli/cli-interp.c | 3 ---
>  gdb/cli/cli-interp.h | 1 -
>  gdb/interps.c        | 1 -
>  gdb/main.c           | 2 --
>  gdb/mi/mi-interp.c   | 2 --
>  gdb/remote-fileio.c  | 2 +-
>  gdb/remote-sim.c     | 4 ++--
>  gdb/top.c            | 2 --
>  gdb/tui/tui-io.c     | 2 --
>  gdb/ui-out.c         | 3 ---
>  gdb/ui-out.h         | 1 -
>  gdb/utils.h          | 1 -
>  12 files changed, 3 insertions(+), 21 deletions(-)
>
> diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
> index 7cefc3902d8..a488c304fea 100644
> --- a/gdb/cli/cli-interp.c
> +++ b/gdb/cli/cli-interp.c
> @@ -273,7 +273,6 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
>        m_saved_output->err = gdb_stderr;
>        m_saved_output->log = gdb_stdlog;
>        m_saved_output->targ = gdb_stdtarg;
> -      m_saved_output->targerr = gdb_stdtargerr;
>  
>        ui_file *logfile_p = logfile.get ();
>        m_saved_output->logfile_holder = std::move (logfile);
> @@ -299,7 +298,6 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
>        gdb_stdlog = m_saved_output->stdlog_holder.get ();
>        gdb_stderr = new_stderr;
>        gdb_stdtarg = new_stderr;
> -      gdb_stdtargerr = new_stderr;
>      }
>    else
>      {
> @@ -307,7 +305,6 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
>        gdb_stderr = m_saved_output->err;
>        gdb_stdlog = m_saved_output->log;
>        gdb_stdtarg = m_saved_output->targ;
> -      gdb_stdtargerr = m_saved_output->targerr;
>  
>        m_saved_output.reset (nullptr);
>      }
> diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
> index 137eb466f6b..03b592fdf9c 100644
> --- a/gdb/cli/cli-interp.h
> +++ b/gdb/cli/cli-interp.h
> @@ -50,7 +50,6 @@ class cli_interp_base : public interp
>      ui_file *err;
>      ui_file *log;
>      ui_file *targ;
> -    ui_file *targerr;
>      /* When redirecting, some or all of these may be non-null
>         depending on the logging mode.  */
>      ui_file_up stdout_holder;
> diff --git a/gdb/interps.c b/gdb/interps.c
> index 94a982e97ab..76561a350c1 100644
> --- a/gdb/interps.c
> +++ b/gdb/interps.c
> @@ -293,7 +293,6 @@ interpreter_exec_cmd (const char *args, int from_tty)
>    scoped_restore save_stderr = make_scoped_restore (&gdb_stderr);
>    scoped_restore save_stdlog = make_scoped_restore (&gdb_stdlog);
>    scoped_restore save_stdtarg = make_scoped_restore (&gdb_stdtarg);
> -  scoped_restore save_stdtargerr = make_scoped_restore (&gdb_stdtargerr);
>  
>    if (args == NULL)
>      error_no_arg (_("interpreter-exec command"));
> diff --git a/gdb/main.c b/gdb/main.c
> index 8b81640e8d2..a79a59102e1 100644
> --- a/gdb/main.c
> +++ b/gdb/main.c
> @@ -79,7 +79,6 @@ std::string python_libdir;
>  /* Target IO streams.  */
>  struct ui_file *gdb_stdtargin;
>  struct ui_file *gdb_stdtarg;
> -struct ui_file *gdb_stdtargerr;
>  
>  /* True if --batch or --batch-silent was seen.  */
>  int batch_flag = 0;
> @@ -679,7 +678,6 @@ captured_main_1 (struct captured_main_args *context)
>    current_ui = main_ui;
>  
>    gdb_stdtarg = gdb_stderr;
> -  gdb_stdtargerr = gdb_stderr;
>    gdb_stdtargin = gdb_stdin;
>  
>    /* Put a CLI based uiout in place early.  If the early initialization
> diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
> index 07e036f5ff9..168e6ed10b4 100644
> --- a/gdb/mi/mi-interp.c
> +++ b/gdb/mi/mi-interp.c
> @@ -132,8 +132,6 @@ mi_interp::resume ()
>    gdb_stdlog = mi->log;
>    /* Route target output through the MI.  */
>    gdb_stdtarg = mi->targ;
> -  /* Route target error through the MI as well.  */
> -  gdb_stdtargerr = mi->targ;
>  
>    deprecated_show_load_progress = mi_load_progress;
>  }
> diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
> index b15824637a9..11cf2bb16fa 100644
> --- a/gdb/remote-fileio.c
> +++ b/gdb/remote-fileio.c
> @@ -641,7 +641,7 @@ remote_fileio_func_write (remote_target *remote, char *buf)
>  	return;
>        case FIO_FD_CONSOLE_OUT:
>  	{
> -	  ui_file *file = target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr;
> +	  ui_file *file = gdb_stdtarg;
>  	  file->write ((char *) buffer, length);
>  	  file->flush ();
>  	  ret = length;
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index 38d7f5b7c0f..f92de619889 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -380,7 +380,7 @@ gdb_os_write_stderr (host_callback *p, const char *buf, int len)
>      {
>        b[0] = buf[i];
>        b[1] = 0;
> -      gdb_stdtargerr->puts (b);
> +      gdb_stdtarg->puts (b);
>      }
>    return len;
>  }
> @@ -390,7 +390,7 @@ gdb_os_write_stderr (host_callback *p, const char *buf, int len)
>  static void
>  gdb_os_flush_stderr (host_callback *p)
>  {
> -  gdb_stdtargerr->flush ();
> +  gdb_stdtarg->flush ();
>  }
>  
>  /* GDB version of gdb_printf callback.  */
> diff --git a/gdb/top.c b/gdb/top.c
> index b93ef0a69b5..b5e77ef6b05 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -620,8 +620,6 @@ execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn)
>        = make_scoped_restore (&gdb_stdlog, file);
>      scoped_restore save_stdtarg
>        = make_scoped_restore (&gdb_stdtarg, file);
> -    scoped_restore save_stdtargerr
> -      = make_scoped_restore (&gdb_stdtargerr, file);
>  
>      fn ();
>    }
> diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
> index 2673397cc46..285c781c25d 100644
> --- a/gdb/tui/tui-io.c
> +++ b/gdb/tui/tui-io.c
> @@ -839,7 +839,6 @@ tui_setup_io (int mode)
>        gdb_stderr = tui_stderr;
>        gdb_stdlog = tui_stdlog;
>        gdb_stdtarg = gdb_stderr;
> -      gdb_stdtargerr = gdb_stderr;
>        current_uiout = tui_out;
>  
>        /* Save tty for SIGCONT.  */
> @@ -852,7 +851,6 @@ tui_setup_io (int mode)
>        gdb_stderr = tui_old_stderr;
>        gdb_stdlog = tui_old_stdlog;
>        gdb_stdtarg = gdb_stderr;
> -      gdb_stdtargerr = gdb_stderr;
>        current_uiout = tui_old_uiout;
>  
>        /* Restore readline.  */
> diff --git a/gdb/ui-out.c b/gdb/ui-out.c
> index b3a2fb7f4e5..a692f0a45fe 100644
> --- a/gdb/ui-out.c
> +++ b/gdb/ui-out.c
> @@ -943,14 +943,12 @@ buffered_streams::buffered_streams (buffer_group *group, ui_out *uiout)
>      m_buffered_stderr (group, gdb_stderr),
>      m_buffered_stdlog (group, gdb_stdlog),
>      m_buffered_stdtarg (group, gdb_stdtarg),
> -    m_buffered_stdtargerr (group, gdb_stdtargerr),
>      m_uiout (uiout)
>  {
>    gdb_stdout = &m_buffered_stdout;
>    gdb_stderr = &m_buffered_stderr;
>    gdb_stdlog = &m_buffered_stdlog;
>    gdb_stdtarg = &m_buffered_stdtarg;
> -  gdb_stdtargerr = &m_buffered_stdtargerr;
>  
>    ui_file *stream = current_uiout->current_stream ();
>    if (stream != nullptr)
> @@ -983,7 +981,6 @@ buffered_streams::remove_buffers ()
>    gdb_stderr = m_buffered_stderr.stream ();
>    gdb_stdlog = m_buffered_stdlog.stream ();
>    gdb_stdtarg = m_buffered_stdtarg.stream ();
> -  gdb_stdtargerr = m_buffered_stdtargerr.stream ();
>  
>    if (m_buffered_current_uiout.has_value ())
>      current_uiout->redirect (nullptr);
> diff --git a/gdb/ui-out.h b/gdb/ui-out.h
> index 5b6ddd55063..3d5e8e49ada 100644
> --- a/gdb/ui-out.h
> +++ b/gdb/ui-out.h
> @@ -642,7 +642,6 @@ struct buffered_streams
>    buffering_file m_buffered_stderr;
>    buffering_file m_buffered_stdlog;
>    buffering_file m_buffered_stdtarg;
> -  buffering_file m_buffered_stdtargerr;
>  
>    /* Buffer for current_uiout's output stream.  */
>    std::optional<buffering_file> m_buffered_current_uiout;
> diff --git a/gdb/utils.h b/gdb/utils.h
> index f0189c7d723..66eec9621fd 100644
> --- a/gdb/utils.h
> +++ b/gdb/utils.h
> @@ -194,7 +194,6 @@ extern void gdb_flush (struct ui_file *stream);
>  
>  /* Target output that should bypass the pager, if one is in use.  */
>  extern struct ui_file *gdb_stdtarg;
> -extern struct ui_file *gdb_stdtargerr;
>  extern struct ui_file *gdb_stdtargin;
>  
>  /* Set the screen dimensions to WIDTH and HEIGHT.  */
> -- 
> 2.44.0
  
Tom Tromey May 17, 2024, 4:07 p.m. UTC | #2
Andrew> I tried to figure out what gdb_stdtarg and gdb_stdtargin are used for,
Andrew> and they both appear to be of pretty limited use.  I wonder what value
Andrew> they are actually adding?

For gdb_stdtargin, I don't know.

For gdb_stdtarg, I think this is one of those MI things that was never
fully implemented.  This stream does use a different prefix:

  mi->out = new mi_console_file (mi->raw_stdout, "~", '"');
  mi->err = new mi_console_file (mi->raw_stdout, "&", '"');
...
  mi->targ = new mi_console_file (mi->raw_stdout, "@", '"');

Based on the code I think the intent here was that target output would
be captured and sent to this MI stream, so the MI user could display it
differently if desired.

However, this was never really implemented, and then even "less
implemented" somehow because output packets were never updated for
non-stop.

This might change again when the "tty" patches land, because IIUC those
will make gdb intercept inferior I/O.

Tom
  

Patch

diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 7cefc3902d8..a488c304fea 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -273,7 +273,6 @@  cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
       m_saved_output->err = gdb_stderr;
       m_saved_output->log = gdb_stdlog;
       m_saved_output->targ = gdb_stdtarg;
-      m_saved_output->targerr = gdb_stdtargerr;
 
       ui_file *logfile_p = logfile.get ();
       m_saved_output->logfile_holder = std::move (logfile);
@@ -299,7 +298,6 @@  cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
       gdb_stdlog = m_saved_output->stdlog_holder.get ();
       gdb_stderr = new_stderr;
       gdb_stdtarg = new_stderr;
-      gdb_stdtargerr = new_stderr;
     }
   else
     {
@@ -307,7 +305,6 @@  cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
       gdb_stderr = m_saved_output->err;
       gdb_stdlog = m_saved_output->log;
       gdb_stdtarg = m_saved_output->targ;
-      gdb_stdtargerr = m_saved_output->targerr;
 
       m_saved_output.reset (nullptr);
     }
diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h
index 137eb466f6b..03b592fdf9c 100644
--- a/gdb/cli/cli-interp.h
+++ b/gdb/cli/cli-interp.h
@@ -50,7 +50,6 @@  class cli_interp_base : public interp
     ui_file *err;
     ui_file *log;
     ui_file *targ;
-    ui_file *targerr;
     /* When redirecting, some or all of these may be non-null
        depending on the logging mode.  */
     ui_file_up stdout_holder;
diff --git a/gdb/interps.c b/gdb/interps.c
index 94a982e97ab..76561a350c1 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -293,7 +293,6 @@  interpreter_exec_cmd (const char *args, int from_tty)
   scoped_restore save_stderr = make_scoped_restore (&gdb_stderr);
   scoped_restore save_stdlog = make_scoped_restore (&gdb_stdlog);
   scoped_restore save_stdtarg = make_scoped_restore (&gdb_stdtarg);
-  scoped_restore save_stdtargerr = make_scoped_restore (&gdb_stdtargerr);
 
   if (args == NULL)
     error_no_arg (_("interpreter-exec command"));
diff --git a/gdb/main.c b/gdb/main.c
index 8b81640e8d2..a79a59102e1 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -79,7 +79,6 @@  std::string python_libdir;
 /* Target IO streams.  */
 struct ui_file *gdb_stdtargin;
 struct ui_file *gdb_stdtarg;
-struct ui_file *gdb_stdtargerr;
 
 /* True if --batch or --batch-silent was seen.  */
 int batch_flag = 0;
@@ -679,7 +678,6 @@  captured_main_1 (struct captured_main_args *context)
   current_ui = main_ui;
 
   gdb_stdtarg = gdb_stderr;
-  gdb_stdtargerr = gdb_stderr;
   gdb_stdtargin = gdb_stdin;
 
   /* Put a CLI based uiout in place early.  If the early initialization
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 07e036f5ff9..168e6ed10b4 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -132,8 +132,6 @@  mi_interp::resume ()
   gdb_stdlog = mi->log;
   /* Route target output through the MI.  */
   gdb_stdtarg = mi->targ;
-  /* Route target error through the MI as well.  */
-  gdb_stdtargerr = mi->targ;
 
   deprecated_show_load_progress = mi_load_progress;
 }
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index b15824637a9..11cf2bb16fa 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -641,7 +641,7 @@  remote_fileio_func_write (remote_target *remote, char *buf)
 	return;
       case FIO_FD_CONSOLE_OUT:
 	{
-	  ui_file *file = target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr;
+	  ui_file *file = gdb_stdtarg;
 	  file->write ((char *) buffer, length);
 	  file->flush ();
 	  ret = length;
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 38d7f5b7c0f..f92de619889 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -380,7 +380,7 @@  gdb_os_write_stderr (host_callback *p, const char *buf, int len)
     {
       b[0] = buf[i];
       b[1] = 0;
-      gdb_stdtargerr->puts (b);
+      gdb_stdtarg->puts (b);
     }
   return len;
 }
@@ -390,7 +390,7 @@  gdb_os_write_stderr (host_callback *p, const char *buf, int len)
 static void
 gdb_os_flush_stderr (host_callback *p)
 {
-  gdb_stdtargerr->flush ();
+  gdb_stdtarg->flush ();
 }
 
 /* GDB version of gdb_printf callback.  */
diff --git a/gdb/top.c b/gdb/top.c
index b93ef0a69b5..b5e77ef6b05 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -620,8 +620,6 @@  execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn)
       = make_scoped_restore (&gdb_stdlog, file);
     scoped_restore save_stdtarg
       = make_scoped_restore (&gdb_stdtarg, file);
-    scoped_restore save_stdtargerr
-      = make_scoped_restore (&gdb_stdtargerr, file);
 
     fn ();
   }
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 2673397cc46..285c781c25d 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -839,7 +839,6 @@  tui_setup_io (int mode)
       gdb_stderr = tui_stderr;
       gdb_stdlog = tui_stdlog;
       gdb_stdtarg = gdb_stderr;
-      gdb_stdtargerr = gdb_stderr;
       current_uiout = tui_out;
 
       /* Save tty for SIGCONT.  */
@@ -852,7 +851,6 @@  tui_setup_io (int mode)
       gdb_stderr = tui_old_stderr;
       gdb_stdlog = tui_old_stdlog;
       gdb_stdtarg = gdb_stderr;
-      gdb_stdtargerr = gdb_stderr;
       current_uiout = tui_old_uiout;
 
       /* Restore readline.  */
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index b3a2fb7f4e5..a692f0a45fe 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -943,14 +943,12 @@  buffered_streams::buffered_streams (buffer_group *group, ui_out *uiout)
     m_buffered_stderr (group, gdb_stderr),
     m_buffered_stdlog (group, gdb_stdlog),
     m_buffered_stdtarg (group, gdb_stdtarg),
-    m_buffered_stdtargerr (group, gdb_stdtargerr),
     m_uiout (uiout)
 {
   gdb_stdout = &m_buffered_stdout;
   gdb_stderr = &m_buffered_stderr;
   gdb_stdlog = &m_buffered_stdlog;
   gdb_stdtarg = &m_buffered_stdtarg;
-  gdb_stdtargerr = &m_buffered_stdtargerr;
 
   ui_file *stream = current_uiout->current_stream ();
   if (stream != nullptr)
@@ -983,7 +981,6 @@  buffered_streams::remove_buffers ()
   gdb_stderr = m_buffered_stderr.stream ();
   gdb_stdlog = m_buffered_stdlog.stream ();
   gdb_stdtarg = m_buffered_stdtarg.stream ();
-  gdb_stdtargerr = m_buffered_stdtargerr.stream ();
 
   if (m_buffered_current_uiout.has_value ())
     current_uiout->redirect (nullptr);
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 5b6ddd55063..3d5e8e49ada 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -642,7 +642,6 @@  struct buffered_streams
   buffering_file m_buffered_stderr;
   buffering_file m_buffered_stdlog;
   buffering_file m_buffered_stdtarg;
-  buffering_file m_buffered_stdtargerr;
 
   /* Buffer for current_uiout's output stream.  */
   std::optional<buffering_file> m_buffered_current_uiout;
diff --git a/gdb/utils.h b/gdb/utils.h
index f0189c7d723..66eec9621fd 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -194,7 +194,6 @@  extern void gdb_flush (struct ui_file *stream);
 
 /* Target output that should bypass the pager, if one is in use.  */
 extern struct ui_file *gdb_stdtarg;
-extern struct ui_file *gdb_stdtargerr;
 extern struct ui_file *gdb_stdtargin;
 
 /* Set the screen dimensions to WIDTH and HEIGHT.  */