public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/19] Simplify GDB output functions
@ 2022-01-22  1:37 Tom Tromey
  2022-01-22  1:37 ` [PATCH 01/19] Use unfiltered output in annotate.c Tom Tromey
                   ` (20 more replies)
  0 siblings, 21 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches

This series tries to untangle and simplify the GDB output functions.

By the end of this series, whether a particular bit of output goes
through the filter will largely depend on the particular stream that
is being written to.  This means that new code can be much simpler --
there's no need to decide between using a _filtered or _unfiltered
form of a function, and in fact, that distinction will no longer
exist.  (Some unfiltered output is still needed, but only to
gdb_stdout, and only via a single API.  New such cases should be
rare.)

A few cleanups are still possible after this series goes in.  For
example, ui-file.c could be broken up a bit, and the pager
implementation should be moved out of utils.c.  I also have a couple
of pager bug fixes that I will apply afterward.

This series is based on a couple of still-pending output series that
I've already sent.  I'll probably check those in reasonably soon.

Regression tested on x86-64 Fedora 34.

Tom



^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 01/19] Use unfiltered output in annotate.c
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 02/19] Remove some uses of printf_unfiltered Tom Tromey
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

It seems to me that annotations should not be filtered.  While it
might be weird for an annotation-based UI to use the pager, it's not,
I think, out of the question.  This patch makes this change.
---
 gdb/annotate.c | 148 ++++++++++++++++++++++++-------------------------
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/gdb/annotate.c b/gdb/annotate.c
index 4ac1b63b66b..00a2e204a94 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -52,9 +52,9 @@ static void
 print_value_flags (struct type *t)
 {
   if (can_dereference (t))
-    printf_filtered (("*"));
+    printf_unfiltered (("*"));
   else
-    printf_filtered (("-"));
+    printf_unfiltered (("-"));
 }
 
 static void
@@ -76,42 +76,42 @@ void
 annotate_breakpoint (int num)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032breakpoint %d\n"), num);
+    printf_unfiltered (("\n\032\032breakpoint %d\n"), num);
 }
 
 void
 annotate_catchpoint (int num)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032catchpoint %d\n"), num);
+    printf_unfiltered (("\n\032\032catchpoint %d\n"), num);
 }
 
 void
 annotate_watchpoint (int num)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032watchpoint %d\n"), num);
+    printf_unfiltered (("\n\032\032watchpoint %d\n"), num);
 }
 
 void
 annotate_starting (void)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032starting\n"));
+    printf_unfiltered (("\n\032\032starting\n"));
 }
 
 void
 annotate_stopped (void)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032stopped\n"));
+    printf_unfiltered (("\n\032\032stopped\n"));
 }
 
 void
 annotate_exited (int exitstatus)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032exited %d\n"), exitstatus);
+    printf_unfiltered (("\n\032\032exited %d\n"), exitstatus);
 }
 
 void
@@ -121,35 +121,35 @@ annotate_signalled (void)
     deprecated_annotate_signalled_hook ();
 
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032signalled\n"));
+    printf_unfiltered (("\n\032\032signalled\n"));
 }
 
 void
 annotate_signal_name (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032signal-name\n"));
+    printf_unfiltered (("\n\032\032signal-name\n"));
 }
 
 void
 annotate_signal_name_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032signal-name-end\n"));
+    printf_unfiltered (("\n\032\032signal-name-end\n"));
 }
 
 void
 annotate_signal_string (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032signal-string\n"));
+    printf_unfiltered (("\n\032\032signal-string\n"));
 }
 
 void
 annotate_signal_string_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032signal-string-end\n"));
+    printf_unfiltered (("\n\032\032signal-string-end\n"));
 }
 
 void
@@ -159,42 +159,42 @@ annotate_signal (void)
     deprecated_annotate_signal_hook ();
 
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032signal\n"));
+    printf_unfiltered (("\n\032\032signal\n"));
 }
 \f
 void
 annotate_breakpoints_headers (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032breakpoints-headers\n"));
+    printf_unfiltered (("\n\032\032breakpoints-headers\n"));
 }
 
 void
 annotate_field (int num)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032field %d\n"), num);
+    printf_unfiltered (("\n\032\032field %d\n"), num);
 }
 
 void
 annotate_breakpoints_table (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032breakpoints-table\n"));
+    printf_unfiltered (("\n\032\032breakpoints-table\n"));
 }
 
 void
 annotate_record (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032record\n"));
+    printf_unfiltered (("\n\032\032record\n"));
 }
 
 void
 annotate_breakpoints_table_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032breakpoints-table-end\n"));
+    printf_unfiltered (("\n\032\032breakpoints-table-end\n"));
 }
 
 void
@@ -237,9 +237,9 @@ annotate_thread_exited (struct thread_info *t, int silent)
 {
   if (annotation_level > 1)
     {
-      printf_filtered(("\n\032\032thread-exited,"
-		       "id=\"%d\",group-id=\"i%d\"\n"),
-		      t->global_num, t->inf->num);
+      printf_unfiltered (("\n\032\032thread-exited,"
+			  "id=\"%d\",group-id=\"i%d\"\n"),
+			 t->global_num, t->inf->num);
     }
 }
 
@@ -248,9 +248,9 @@ annotate_field_begin (struct type *type)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032field-begin "));
+      printf_unfiltered (("\n\032\032field-begin "));
       print_value_flags (type);
-      printf_filtered (("\n"));
+      printf_unfiltered (("\n"));
     }
 }
 
@@ -258,42 +258,42 @@ void
 annotate_field_name_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032field-name-end\n"));
+    printf_unfiltered (("\n\032\032field-name-end\n"));
 }
 
 void
 annotate_field_value (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032field-value\n"));
+    printf_unfiltered (("\n\032\032field-value\n"));
 }
 
 void
 annotate_field_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032field-end\n"));
+    printf_unfiltered (("\n\032\032field-end\n"));
 }
 \f
 void
 annotate_quit (void)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032quit\n"));
+    printf_unfiltered (("\n\032\032quit\n"));
 }
 
 void
 annotate_error (void)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032error\n"));
+    printf_unfiltered (("\n\032\032error\n"));
 }
 
 void
 annotate_error_begin (void)
 {
   if (annotation_level > 1)
-    fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
+    fprintf_unfiltered (gdb_stderr, "\n\032\032error-begin\n");
 }
 
 void
@@ -301,9 +301,9 @@ annotate_value_history_begin (int histindex, struct type *type)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032value-history-begin %d "), histindex);
+      printf_unfiltered (("\n\032\032value-history-begin %d "), histindex);
       print_value_flags (type);
-      printf_filtered (("\n"));
+      printf_unfiltered (("\n"));
     }
 }
 
@@ -312,9 +312,9 @@ annotate_value_begin (struct type *type)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032value-begin "));
+      printf_unfiltered (("\n\032\032value-begin "));
       print_value_flags (type);
-      printf_filtered (("\n"));
+      printf_unfiltered (("\n"));
     }
 }
 
@@ -322,84 +322,84 @@ void
 annotate_value_history_value (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032value-history-value\n"));
+    printf_unfiltered (("\n\032\032value-history-value\n"));
 }
 
 void
 annotate_value_history_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032value-history-end\n"));
+    printf_unfiltered (("\n\032\032value-history-end\n"));
 }
 
 void
 annotate_value_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032value-end\n"));
+    printf_unfiltered (("\n\032\032value-end\n"));
 }
 
 void
 annotate_display_begin (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-begin\n"));
+    printf_unfiltered (("\n\032\032display-begin\n"));
 }
 
 void
 annotate_display_number_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-number-end\n"));
+    printf_unfiltered (("\n\032\032display-number-end\n"));
 }
 
 void
 annotate_display_format (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-format\n"));
+    printf_unfiltered (("\n\032\032display-format\n"));
 }
 
 void
 annotate_display_expression (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-expression\n"));
+    printf_unfiltered (("\n\032\032display-expression\n"));
 }
 
 void
 annotate_display_expression_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-expression-end\n"));
+    printf_unfiltered (("\n\032\032display-expression-end\n"));
 }
 
 void
 annotate_display_value (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-value\n"));
+    printf_unfiltered (("\n\032\032display-value\n"));
 }
 
 void
 annotate_display_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032display-end\n"));
+    printf_unfiltered (("\n\032\032display-end\n"));
 }
 
 void
 annotate_arg_begin (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032arg-begin\n"));
+    printf_unfiltered (("\n\032\032arg-begin\n"));
 }
 
 void
 annotate_arg_name_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032arg-name-end\n"));
+    printf_unfiltered (("\n\032\032arg-name-end\n"));
 }
 
 void
@@ -407,9 +407,9 @@ annotate_arg_value (struct type *type)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032arg-value "));
+      printf_unfiltered (("\n\032\032arg-value "));
       print_value_flags (type);
-      printf_filtered (("\n"));
+      printf_unfiltered (("\n"));
     }
 }
 
@@ -417,7 +417,7 @@ void
 annotate_arg_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032arg-end\n"));
+    printf_unfiltered (("\n\032\032arg-end\n"));
 }
 
 static void
@@ -425,12 +425,12 @@ annotate_source (const char *filename, int line, int character, int mid,
 		 struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032source "));
+    printf_unfiltered (("\n\032\032source "));
   else
-    printf_filtered (("\032\032"));
+    printf_unfiltered (("\032\032"));
 
-  printf_filtered (("%s:%d:%d:%s:%s\n"), filename, line, character,
-		   mid ? "middle" : "beg", paddress (gdbarch, pc));
+  printf_unfiltered (("%s:%d:%d:%s:%s\n"), filename, line, character,
+		     mid ? "middle" : "beg", paddress (gdbarch, pc));
 }
 
 /* See annotate.h.  */
@@ -469,99 +469,99 @@ void
 annotate_frame_begin (int level, struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   if (annotation_level > 1)
-    printf_filtered (("\n\032\032frame-begin %d %s\n"),
-		     level, paddress (gdbarch, pc));
+    printf_unfiltered (("\n\032\032frame-begin %d %s\n"),
+		       level, paddress (gdbarch, pc));
 }
 
 void
 annotate_function_call (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032function-call\n"));
+    printf_unfiltered (("\n\032\032function-call\n"));
 }
 
 void
 annotate_signal_handler_caller (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032signal-handler-caller\n"));
+    printf_unfiltered (("\n\032\032signal-handler-caller\n"));
 }
 
 void
 annotate_frame_address (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-address\n"));
+    printf_unfiltered (("\n\032\032frame-address\n"));
 }
 
 void
 annotate_frame_address_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-address-end\n"));
+    printf_unfiltered (("\n\032\032frame-address-end\n"));
 }
 
 void
 annotate_frame_function_name (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-function-name\n"));
+    printf_unfiltered (("\n\032\032frame-function-name\n"));
 }
 
 void
 annotate_frame_args (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-args\n"));
+    printf_unfiltered (("\n\032\032frame-args\n"));
 }
 
 void
 annotate_frame_source_begin (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-source-begin\n"));
+    printf_unfiltered (("\n\032\032frame-source-begin\n"));
 }
 
 void
 annotate_frame_source_file (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-source-file\n"));
+    printf_unfiltered (("\n\032\032frame-source-file\n"));
 }
 
 void
 annotate_frame_source_file_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-source-file-end\n"));
+    printf_unfiltered (("\n\032\032frame-source-file-end\n"));
 }
 
 void
 annotate_frame_source_line (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-source-line\n"));
+    printf_unfiltered (("\n\032\032frame-source-line\n"));
 }
 
 void
 annotate_frame_source_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-source-end\n"));
+    printf_unfiltered (("\n\032\032frame-source-end\n"));
 }
 
 void
 annotate_frame_where (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-where\n"));
+    printf_unfiltered (("\n\032\032frame-where\n"));
 }
 
 void
 annotate_frame_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032frame-end\n"));
+    printf_unfiltered (("\n\032\032frame-end\n"));
 }
 \f
 void
@@ -569,9 +569,9 @@ annotate_array_section_begin (int idx, struct type *elttype)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032array-section-begin %d "), idx);
+      printf_unfiltered (("\n\032\032array-section-begin %d "), idx);
       print_value_flags (elttype);
-      printf_filtered (("\n"));
+      printf_unfiltered (("\n"));
     }
 }
 
@@ -579,28 +579,28 @@ void
 annotate_elt_rep (unsigned int repcount)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
+    printf_unfiltered (("\n\032\032elt-rep %u\n"), repcount);
 }
 
 void
 annotate_elt_rep_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032elt-rep-end\n"));
+    printf_unfiltered (("\n\032\032elt-rep-end\n"));
 }
 
 void
 annotate_elt (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032elt\n"));
+    printf_unfiltered (("\n\032\032elt\n"));
 }
 
 void
 annotate_array_section_end (void)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032array-section-end\n"));
+    printf_unfiltered (("\n\032\032array-section-end\n"));
 }
 
 /* Called when GDB is about to display the prompt.  Used to reset
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 02/19] Remove some uses of printf_unfiltered
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
  2022-01-22  1:37 ` [PATCH 01/19] Use unfiltered output in annotate.c Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 03/19] Only have one API for unfiltered output Tom Tromey
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A number of spots call printf_unfiltered only because they are in code
that should not be interrupted by the pager.  However, I believe these
cases are all handled by infrun's blanket ban on paging, and so can be
converted to the default (_filtered) API.

After this patch, I think all the remaining _unfiltered calls are ones
that really ought to be.  A few -- namely in complete_command -- could
be replaced by a scoped assignment to pagination_enabled, but for the
remainder, the code seems simple enough like this.
---
 gdb/fbsd-nat.c        |  4 ++--
 gdb/infcmd.c          | 10 +++++-----
 gdb/inferior.c        | 14 +++++++-------
 gdb/infrun.c          | 10 +++++-----
 gdb/linux-nat.c       |  4 ++--
 gdb/linux-thread-db.c |  6 +++---
 gdb/mdebugread.c      | 10 +++++-----
 gdb/netbsd-nat.c      |  4 ++--
 gdb/procfs.c          |  8 ++++----
 gdb/remote.c          | 10 +++++-----
 gdb/sol-thread.c      |  2 +-
 gdb/solib-svr4.c      | 16 ++++++++--------
 gdb/solib.c           | 14 +++++++-------
 gdb/target.c          | 16 ++++++++--------
 gdb/thread.c          |  2 +-
 gdb/windows-nat.c     | 18 +++++++++---------
 16 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 9a945576a94..2a124bac63e 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1216,8 +1216,8 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 		  fbsd_lwp_debug_printf ("deleting thread for LWP %u",
 					 pl.pl_lwpid);
 		  if (print_thread_events)
-		    printf_unfiltered (_("[%s exited]\n"),
-				       target_pid_to_str (wptid).c_str ());
+		    printf_filtered (_("[%s exited]\n"),
+				     target_pid_to_str (wptid).c_str ());
 		  delete_thread (thr);
 		}
 	      if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 994dd5b32a3..e82286f5c1c 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1178,11 +1178,11 @@ signal_command (const char *signum_exp, int from_tty)
 	      && signal_pass_state (tp->stop_signal ()))
 	    {
 	      if (!must_confirm)
-		printf_unfiltered (_("Note:\n"));
-	      printf_unfiltered (_("  Thread %s previously stopped with signal %s, %s.\n"),
-				 print_thread_id (tp),
-				 gdb_signal_to_name (tp->stop_signal ()),
-				 gdb_signal_to_string (tp->stop_signal ()));
+		printf_filtered (_("Note:\n"));
+	      printf_filtered (_("  Thread %s previously stopped with signal %s, %s.\n"),
+			       print_thread_id (tp),
+			       gdb_signal_to_name (tp->stop_signal ()),
+			       gdb_signal_to_string (tp->stop_signal ()));
 	      must_confirm = 1;
 	    }
 	}
diff --git a/gdb/inferior.c b/gdb/inferior.c
index bebddb44173..57650ef0134 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -163,11 +163,11 @@ add_inferior (int pid)
   if (print_inferior_events)
     {
       if (pid != 0)
-	printf_unfiltered (_("[New inferior %d (%s)]\n"),
-			   inf->num,
-			   target_pid_to_str (ptid_t (pid)).c_str ());
+	printf_filtered (_("[New inferior %d (%s)]\n"),
+			 inf->num,
+			 target_pid_to_str (ptid_t (pid)).c_str ());
       else
-	printf_unfiltered (_("[New inferior %d]\n"), inf->num);
+	printf_filtered (_("[New inferior %d]\n"), inf->num);
     }
 
   return inf;
@@ -263,9 +263,9 @@ detach_inferior (inferior *inf)
   exit_inferior_1 (inf, 0);
 
   if (print_inferior_events)
-    printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
-		       inf->num,
-		       target_pid_to_str (ptid_t (pid)).c_str ());
+    printf_filtered (_("[Inferior %d (%s) detached]\n"),
+		     inf->num,
+		     target_pid_to_str (ptid_t (pid)).c_str ());
 }
 
 void
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2e7ed15723f..03e3489c91e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1131,9 +1131,9 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
 
   /* What is this a.out's name?  */
   process_ptid = ptid_t (pid);
-  printf_unfiltered (_("%s is executing new program: %s\n"),
-		     target_pid_to_str (process_ptid).c_str (),
-		     exec_file_target);
+  printf_filtered (_("%s is executing new program: %s\n"),
+		   target_pid_to_str (process_ptid).c_str (),
+		   exec_file_target);
 
   /* We've followed the inferior through an exec.  Therefore, the
      inferior has essentially been killed & reborn.  */
@@ -4174,7 +4174,7 @@ fetch_inferior_event ()
       && exec_done_display_p
       && (inferior_ptid == null_ptid
 	  || inferior_thread ()->state != THREAD_RUNNING))
-    printf_unfiltered (_("completed.\n"));
+    printf_filtered (_("completed.\n"));
 }
 
 /* See infrun.h.  */
@@ -8858,7 +8858,7 @@ Are you sure you want to change it? "),
 		      sigs[signum] = 1;
 		    }
 		  else
-		    printf_unfiltered (_("Not confirmed, unchanged.\n"));
+		    printf_filtered (_("Not confirmed, unchanged.\n"));
 		}
 	      break;
 	    case GDB_SIGNAL_0:
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 0cc6923ad02..95410e0d780 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -994,8 +994,8 @@ exit_lwp (struct lwp_info *lp)
   if (th)
     {
       if (print_thread_events)
-	printf_unfiltered (_("[%s exited]\n"),
-			   target_pid_to_str (lp->ptid).c_str ());
+	printf_filtered (_("[%s exited]\n"),
+			 target_pid_to_str (lp->ptid).c_str ());
 
       delete_thread (th);
     }
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 18d313bf9be..52e8c9a0e43 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -936,7 +936,7 @@ try_thread_db_load_1 (struct thread_db_info *info)
       return false;
     }
 
-  printf_unfiltered (_("[Thread debugging using libthread_db enabled]\n"));
+  printf_filtered (_("[Thread debugging using libthread_db enabled]\n"));
 
   if (!libthread_db_search_path.empty () || libthread_db_debug)
     {
@@ -946,8 +946,8 @@ try_thread_db_load_1 (struct thread_db_info *info)
       if (library == NULL)
 	library = LIBTHREAD_DB_SO;
 
-      printf_unfiltered (_("Using host libthread_db library \"%ps\".\n"),
-			 styled_string (file_name_style.style (), library));
+      printf_filtered (_("Using host libthread_db library \"%ps\".\n"),
+		       styled_string (file_name_style.style (), library));
     }
 
   /* The thread library was detected.  Activate the thread_db target
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1b327ad6115..dd531550864 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -371,11 +371,11 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader,
   if (compare_glevel (max_glevel, GLEVEL_2) < 0)
     {
       if (max_gdbinfo == 0)
-	printf_unfiltered (_("\n%s not compiled with -g, "
-			     "debugging support is limited.\n"),
-			   objfile->name);
-      printf_unfiltered (_("You should compile with -g2 or "
-			   "-g3 for best debugging support.\n"));
+	printf_filtered (_("\n%s not compiled with -g, "
+			   "debugging support is limited.\n"),
+			 objfile->name);
+      printf_filtered (_("You should compile with -g2 or "
+			 "-g3 for best debugging support.\n"));
     }
 #endif
 }
diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c
index 9e9014283cd..b8389ca14b6 100644
--- a/gdb/netbsd-nat.c
+++ b/gdb/netbsd-nat.c
@@ -626,8 +626,8 @@ nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	  ourstatus->set_thread_exited (0);
 
 	  if (print_thread_events)
-	    printf_unfiltered (_("[%s exited]\n"),
-			       target_pid_to_str (wptid).c_str ());
+	    printf_filtered (_("[%s exited]\n"),
+			     target_pid_to_str (wptid).c_str ());
 	  delete_thread (thr);
 	}
 
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 840201d1897..47516450b53 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -2122,8 +2122,8 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
 		if (what == SYS_lwp_exit)
 		  {
 		    if (print_thread_events)
-		      printf_unfiltered (_("[%s exited]\n"),
-					 target_pid_to_str (retval).c_str ());
+		      printf_filtered (_("[%s exited]\n"),
+				       target_pid_to_str (retval).c_str ());
 		    delete_thread (find_thread_ptid (this, retval));
 		    target_continue_no_signal (ptid);
 		    goto wait_again;
@@ -2229,8 +2229,8 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
 		else if (what == SYS_lwp_exit)
 		  {
 		    if (print_thread_events)
-		      printf_unfiltered (_("[%s exited]\n"),
-					 target_pid_to_str (retval).c_str ());
+		      printf_filtered (_("[%s exited]\n"),
+				       target_pid_to_str (retval).c_str ());
 		    delete_thread (find_thread_ptid (this, retval));
 		    status->set_spurious ();
 		    return retval;
diff --git a/gdb/remote.c b/gdb/remote.c
index b093ad86675..bc9a73b2b09 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6004,8 +6004,8 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty)
 
       target_mourn_inferior (inferior_ptid);
       if (print_inferior_events)
-	printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
-			   inf->num, infpid.c_str ());
+	printf_filtered (_("[Inferior %d (%s) detached]\n"),
+			 inf->num, infpid.c_str ());
     }
   else
     {
@@ -9974,7 +9974,7 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf,
 	{
 	  /* We have tried hard enough, and just can't receive the
 	     packet/notification.  Give up.  */
-	  printf_unfiltered (_("Ignoring packet error, continuing...\n"));
+	  printf_filtered (_("Ignoring packet error, continuing...\n"));
 
 	  /* Skip the ack char if we're in no-ack mode.  */
 	  if (!rs->noack_mode)
@@ -12325,8 +12325,8 @@ remote_target::remote_hostio_open (inferior *inf, const char *filename,
     {
       static int warning_issued = 0;
 
-      printf_unfiltered (_("Reading %s from remote target...\n"),
-			 filename);
+      printf_filtered (_("Reading %s from remote target...\n"),
+		       filename);
 
       if (!warning_issued)
 	{
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 44e990b6e5f..0bfdbdf5037 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -638,7 +638,7 @@ check_for_thread_db (void)
       break;
 
     case TD_OK:
-      printf_unfiltered (_("[Thread debugging using libthread_db enabled]\n"));
+      printf_filtered (_("[Thread debugging using libthread_db enabled]\n"));
 
       /* The thread library was detected.  Activate the sol_thread target.  */
       current_inferior ()->push_target (&sol_thread_ops);
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 69f2991f5e6..37fc898d2aa 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -292,10 +292,10 @@ lm_addr_check (const struct so_list *so, bfd *abfd)
 	      && (l_addr & align) == ((l_dynaddr - dynaddr) & align))
 	    {
 	      if (info_verbose)
-		printf_unfiltered (_("Using PIC (Position Independent Code) "
-				     "prelink displacement %s for \"%s\".\n"),
-				   paddress (target_gdbarch (), l_addr),
-				   so->so_name);
+		printf_filtered (_("Using PIC (Position Independent Code) "
+				   "prelink displacement %s for \"%s\".\n"),
+				 paddress (target_gdbarch (), l_addr),
+				 so->so_name);
 	    }
 	  else
 	    {
@@ -2834,10 +2834,10 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
 	 the executable symbols/file has been already relocated to
 	 displacement.  */
 
-      printf_unfiltered (_("Using PIE (Position Independent Executable) "
-			   "displacement %s for \"%s\".\n"),
-			 paddress (target_gdbarch (), exec_displacement),
-			 bfd_get_filename (current_program_space->exec_bfd ()));
+      printf_filtered (_("Using PIE (Position Independent Executable) "
+			 "displacement %s for \"%s\".\n"),
+		       paddress (target_gdbarch (), exec_displacement),
+		       bfd_get_filename (current_program_space->exec_bfd ()));
     }
 
   *displacementp = exec_displacement;
diff --git a/gdb/solib.c b/gdb/solib.c
index b9b1d037187..7e71d1ea74b 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -940,11 +940,11 @@ solib_add (const char *pattern, int from_tty, int readsyms)
     {
       if (pattern != NULL)
 	{
-	  printf_unfiltered (_("Loading symbols for shared libraries: %s\n"),
-			     pattern);
+	  printf_filtered (_("Loading symbols for shared libraries: %s\n"),
+			   pattern);
 	}
       else
-	printf_unfiltered (_("Loading symbols for shared libraries.\n"));
+	printf_filtered (_("Loading symbols for shared libraries.\n"));
     }
 
   current_program_space->solib_add_generation++;
@@ -989,8 +989,8 @@ solib_add (const char *pattern, int from_tty, int readsyms)
 		  /* If no pattern was given, be quiet for shared
 		     libraries we have already loaded.  */
 		  if (pattern && (from_tty || info_verbose))
-		    printf_unfiltered (_("Symbols already loaded for %s\n"),
-				       gdb->so_name);
+		    printf_filtered (_("Symbols already loaded for %s\n"),
+				     gdb->so_name);
 		}
 	      else if (solib_read_symbols (gdb, add_flags))
 		loaded_any_symbols = true;
@@ -1001,7 +1001,7 @@ solib_add (const char *pattern, int from_tty, int readsyms)
       breakpoint_re_set ();
 
     if (from_tty && pattern && ! any_matches)
-      printf_unfiltered
+      printf_filtered
 	("No loaded shared libraries match the pattern `%s'.\n", pattern);
 
     if (loaded_any_symbols)
@@ -1277,7 +1277,7 @@ static void
 reload_shared_libraries_1 (int from_tty)
 {
   if (print_symbol_loading_p (from_tty, 0, 0))
-    printf_unfiltered (_("Loading symbols for shared libraries.\n"));
+    printf_filtered (_("Loading symbols for shared libraries.\n"));
 
   for (struct so_list *so : current_program_space->solibs ())
     {
diff --git a/gdb/target.c b/gdb/target.c
index 950f2f08e31..4a40ce3a720 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3631,11 +3631,11 @@ target_announce_detach (int from_tty)
   pid = inferior_ptid.pid ();
   exec_file = get_exec_file (0);
   if (exec_file == nullptr)
-    printf_unfiltered ("Detaching from pid %s\n",
-		       target_pid_to_str (ptid_t (pid)).c_str ());
+    printf_filtered ("Detaching from pid %s\n",
+		     target_pid_to_str (ptid_t (pid)).c_str ());
   else
-    printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
-		       target_pid_to_str (ptid_t (pid)).c_str ());
+    printf_filtered (_("Detaching from program: %s, %s\n"), exec_file,
+		     target_pid_to_str (ptid_t (pid)).c_str ());
 }
 
 /* See target.h  */
@@ -3649,11 +3649,11 @@ target_announce_attach (int from_tty, int pid)
   const char *exec_file = get_exec_file (0);
 
   if (exec_file != nullptr)
-    printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
-		       target_pid_to_str (ptid_t (pid)).c_str ());
+    printf_filtered ("Attaching to program: %s, %s\n", exec_file,
+		     target_pid_to_str (ptid_t (pid)).c_str ());
   else
-    printf_unfiltered ("Attaching to %s\n",
-		       target_pid_to_str (ptid_t (pid)).c_str ());
+    printf_filtered ("Attaching to %s\n",
+		     target_pid_to_str (ptid_t (pid)).c_str ());
 }
 
 /* The inferior process has died.  Long live the inferior!  */
diff --git a/gdb/thread.c b/gdb/thread.c
index 611be3f4633..7a4b21868f5 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -294,7 +294,7 @@ add_thread_with_info (process_stratum_target *targ, ptid_t ptid,
   result->priv.reset (priv);
 
   if (print_thread_events)
-    printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid).c_str ());
+    printf_filtered (_("[New %s]\n"), target_pid_to_str (ptid).c_str ());
 
   annotate_new_thread ();
   return result;
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 81e26fe4759..c933034346f 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -429,11 +429,11 @@ windows_delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p)
      here as well.  */
 
   if (info_verbose)
-    printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (ptid).c_str ());
+    printf_filtered ("[Deleting %s]\n", target_pid_to_str (ptid).c_str ());
   else if (print_thread_events && !main_thread_p)
-    printf_unfiltered (_("[%s exited with code %u]\n"),
-		       target_pid_to_str (ptid).c_str (),
-		       (unsigned) exit_code);
+    printf_filtered (_("[%s exited with code %u]\n"),
+		     target_pid_to_str (ptid).c_str (),
+		     (unsigned) exit_code);
 
   delete_thread (find_thread_ptid (&the_windows_nat_target, ptid));
 
@@ -1631,11 +1631,11 @@ windows_nat_target::get_windows_debug_event (int pid,
     default:
       if (saw_create != 1)
 	break;
-      printf_unfiltered ("gdb: kernel event for pid=%u tid=0x%x\n",
-			 (unsigned) current_event.dwProcessId,
-			 (unsigned) current_event.dwThreadId);
-      printf_unfiltered ("                 unknown event code %u\n",
-			 (unsigned) current_event.dwDebugEventCode);
+      printf_filtered ("gdb: kernel event for pid=%u tid=0x%x\n",
+		       (unsigned) current_event.dwProcessId,
+		       (unsigned) current_event.dwThreadId);
+      printf_filtered ("                 unknown event code %u\n",
+		       (unsigned) current_event.dwDebugEventCode);
       break;
     }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 03/19] Only have one API for unfiltered output
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
  2022-01-22  1:37 ` [PATCH 01/19] Use unfiltered output in annotate.c Tom Tromey
  2022-01-22  1:37 ` [PATCH 02/19] Remove some uses of printf_unfiltered Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 04/19] Add puts_unfiltered method to ui_file Tom Tromey
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

At the end of this series, the use of unfiltered output will be very
restricted -- only places that definitely need it will use it.  To
this end, I thought it would be good to reduce the number of
_unfiltered APIs that are exposed.  This patch changes gdb so that
only printf_unfiltered exists.  (After this patch, the f* variants
still exist as well, but those will be removed later.)
---
 gdb/event-top.c |  6 +-----
 gdb/top.c       |  8 ++------
 gdb/utils.c     | 12 ------------
 gdb/utils.h     |  4 ----
 4 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/gdb/event-top.c b/gdb/event-top.c
index 0e22f24f1df..039066a9d03 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -673,11 +673,7 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
   cmd_line_buffer->used_size = 0;
 
   if (from_tty && annotation_level > 1)
-    {
-      printf_unfiltered (("\n\032\032post-"));
-      puts_unfiltered (annotation_suffix);
-      printf_unfiltered (("\n"));
-    }
+    printf_unfiltered (("\n\032\032post-%s\n"), annotation_suffix);
 
 #define SERVER_COMMAND_PREFIX "server "
   server_command = startswith (cmd, SERVER_COMMAND_PREFIX);
diff --git a/gdb/top.c b/gdb/top.c
index a94ed5cebdb..5d90ebbdf19 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -873,7 +873,7 @@ gdb_readline_no_editing (const char *prompt)
       /* Don't use a _filtered function here.  It causes the assumed
 	 character position to be off, since the newline we read from
 	 the user is not accounted for.  */
-      puts_unfiltered (prompt);
+      printf_unfiltered ("%s", prompt);
       gdb_flush (gdb_stdout);
     }
 
@@ -1372,11 +1372,7 @@ command_line_input (const char *prompt_arg, const char *annotation_suffix)
 	++source_line_number;
 
       if (from_tty && annotation_level > 1)
-	{
-	  puts_unfiltered ("\n\032\032pre-");
-	  puts_unfiltered (annotation_suffix);
-	  puts_unfiltered ("\n");
-	}
+	printf_unfiltered ("\n\032\032pre-%s\n", annotation_suffix);
 
       /* Don't use fancy stuff if not talking to stdin.  */
       if (deprecated_readline_hook
diff --git a/gdb/utils.c b/gdb/utils.c
index f64ff68fa0d..48d68c6739d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1867,12 +1867,6 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
     fputs_filtered (str, stream);
 }
 
-int
-putchar_unfiltered (int c)
-{
-  return fputc_unfiltered (c, gdb_stdout);
-}
-
 /* Write character C to gdb_stdout using GDB's paging mechanism and return C.
    May return nonlocally.  */
 
@@ -2045,12 +2039,6 @@ puts_filtered (const char *string)
   fputs_filtered (string, gdb_stdout);
 }
 
-void
-puts_unfiltered (const char *string)
-{
-  fputs_unfiltered (string, gdb_stdout);
-}
-
 /* Return a pointer to N spaces and a null.  The pointer is good
    until the next call to here.  */
 const char *
diff --git a/gdb/utils.h b/gdb/utils.h
index 83211a008f1..e506650cbdd 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -240,12 +240,8 @@ extern int fputc_unfiltered (int c, struct ui_file *);
 
 extern int putchar_filtered (int c);
 
-extern int putchar_unfiltered (int c);
-
 extern void puts_filtered (const char *);
 
-extern void puts_unfiltered (const char *);
-
 extern void puts_filtered_tabular (char *string, int width, int right);
 
 extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 04/19] Add puts_unfiltered method to ui_file
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (2 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 03/19] Only have one API for unfiltered output Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 05/19] Add style-escape methods " Tom Tromey
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

When the pager is rewritten as a ui_file, gdb will still need a way to
bypass the filtering.  After examining a few approaches, I chose this
patch, which adds a puts_unfiltered method to ui_file.  For most
implementations of ui_file, this will just delegate to puts.  This
patch also switches printf_unfiltered to use the new method.
---
 gdb/ui-file.h | 14 ++++++++++++++
 gdb/utils.c   |  4 +++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 1a010e55564..101769d73a2 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -109,6 +109,14 @@ class ui_file
 
   void wrap_here (int indent);
 
+  /* Print STR, bypassing any paging that might be done by this
+     ui_file.  Note that nearly no code should call this -- it's
+     intended for use by printf_filtered, but nothing else.  */
+  virtual void puts_unfiltered (const char *str)
+  {
+    this->puts (str);
+  }
+
 private:
 
   /* Helper function for putstr and putstrn.  Print the character C on
@@ -317,6 +325,12 @@ class tee_file : public ui_file
     return m_one->can_page () || m_two->can_page ();
   }
 
+  void puts_unfiltered (const char *str) override
+  {
+    m_one->puts_unfiltered (str);
+    m_two->puts_unfiltered (str);
+  }
+
 private:
   /* The two underlying ui_files.  */
   ui_file *m_one;
diff --git a/gdb/utils.c b/gdb/utils.c
index 48d68c6739d..65b7668f583 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2024,7 +2024,9 @@ printf_unfiltered (const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_unfiltered (gdb_stdout, format, args);
+  string_file file (gdb_stdout->can_emit_style_escape ());
+  file.vprintf (format, args);
+  gdb_stdout->puts_unfiltered (file.string ().c_str ());
   va_end (args);
 }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 05/19] Add style-escape methods to ui_file
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (3 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 04/19] Add puts_unfiltered method to ui_file Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 06/19] Remove vfprintf_styled_no_gdbfmt Tom Tromey
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds emit_style_escape and reset_style methods to ui_file.  These
aren't used yet, but they will be once the pager is converted to be a
ui_file subclass.
---
 gdb/ui-file.c | 24 ++++++++++++++++++++++++
 gdb/ui-file.h | 19 +++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 354a7c3e3b6..2072fd81954 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -73,6 +73,30 @@ ui_file::vprintf (const char *format, va_list args)
 
 /* See ui-file.h.  */
 
+void
+ui_file::emit_style_escape (const ui_file_style &style)
+{
+  if (can_emit_style_escape () && style != m_applied_style)
+    {
+      m_applied_style = style;
+      this->puts (style.to_ansi ().c_str ());
+    }
+}
+
+/* See ui-file.h.  */
+
+void
+ui_file::reset_style ()
+{
+  if (can_emit_style_escape ())
+    {
+      m_applied_style = ui_file_style ();
+      this->puts (m_applied_style.to_ansi ().c_str ());
+    }
+}
+
+/* See ui-file.h.  */
+
 void
 ui_file::printchar (int c, int quoter, bool async_safe)
 {
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 101769d73a2..1ea2f60591c 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -109,6 +109,12 @@ class ui_file
 
   void wrap_here (int indent);
 
+  /* Emit an ANSI style escape for STYLE.  */
+  virtual void emit_style_escape (const ui_file_style &style);
+
+  /* Rest the current output style to the empty style.  */
+  virtual void reset_style ();
+
   /* Print STR, bypassing any paging that might be done by this
      ui_file.  Note that nearly no code should call this -- it's
      intended for use by printf_filtered, but nothing else.  */
@@ -117,6 +123,11 @@ class ui_file
     this->puts (str);
   }
 
+protected:
+
+  /* The currently applied style.  */
+  ui_file_style m_applied_style;
+
 private:
 
   /* Helper function for putstr and putstrn.  Print the character C on
@@ -351,6 +362,14 @@ class no_terminal_escape_file : public stdio_file
      sequences.  */
   void write (const char *buf, long length_buf) override;
   void puts (const char *linebuffer) override;
+
+  void emit_style_escape (const ui_file_style &style) override
+  {
+  }
+
+  void reset_style () override
+  {
+  }
 };
 
 /* A ui_file that optionally puts a timestamp at the start of each
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 06/19] Remove vfprintf_styled_no_gdbfmt
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (4 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 05/19] Add style-escape methods " Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 07/19] Change the pager to a ui_file Tom Tromey
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes vfprintf_styled_no_gdbfmt, inlining it at the sole point
of call.
---
 gdb/cli-out.c | 13 ++++++++-----
 gdb/utils.c   | 15 ---------------
 gdb/utils.h   |  8 --------
 3 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index b2daad11a51..a7fcc623897 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -230,11 +230,14 @@ cli_ui_out::do_message (const ui_file_style &style,
   if (m_suppress_output)
     return;
 
-  /* Use the "no_gdbfmt" variant here to avoid recursion.
-     vfprintf_styled calls into cli_ui_out::message to handle the
-     gdb-specific printf formats.  */
-  vfprintf_styled_no_gdbfmt (m_streams.back (), style,
-			     !test_flags (unfiltered_output), format, args);
+  std::string str = string_vprintf (format, args);
+  if (!str.empty ())
+    {
+      if (test_flags (unfiltered_output))
+	fputs_styled_unfiltered (str.c_str (), style, m_streams.back ());
+      else
+	fputs_styled (str.c_str (), style, m_streams.back ());
+    }
 }
 
 void
diff --git a/gdb/utils.c b/gdb/utils.c
index 65b7668f583..6dbb46f9719 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1992,21 +1992,6 @@ vfprintf_styled (struct ui_file *stream, const ui_file_style &style,
   set_output_style (stream, ui_file_style ());
 }
 
-/* See utils.h.  */
-
-void
-vfprintf_styled_no_gdbfmt (struct ui_file *stream, const ui_file_style &style,
-			   bool filter, const char *format, va_list args)
-{
-  std::string str = string_vprintf (format, args);
-  if (!str.empty ())
-    {
-      set_output_style (stream, style);
-      fputs_maybe_filtered (str.c_str (), stream, filter);
-      set_output_style (stream, ui_file_style ());
-    }
-}
-
 void
 printf_filtered (const char *format, ...)
 {
diff --git a/gdb/utils.h b/gdb/utils.h
index e506650cbdd..5d8ed670e66 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -286,14 +286,6 @@ extern void vfprintf_styled (struct ui_file *stream,
 			     va_list args)
   ATTRIBUTE_PRINTF (3, 0);
 
-/* Like vfprintf_styled, but do not process gdb-specific format
-   specifiers.  */
-extern void vfprintf_styled_no_gdbfmt (struct ui_file *stream,
-				       const ui_file_style &style,
-				       bool filter,
-				       const char *fmt, va_list args)
-  ATTRIBUTE_PRINTF (4, 0);
-
 /* Like fputs_filtered, but styles the output according to STYLE, when
    appropriate.  */
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 07/19] Change the pager to a ui_file
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (5 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 06/19] Remove vfprintf_styled_no_gdbfmt Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 08/19] Remove fputs_styled_unfiltered Tom Tromey
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites the output pager as a ui_file implementation.

A new header is introduced to declare the pager class.  The
implementation remains in utils.c for the time being, because there
are some static globals there that must be used by this code.  (This
could be cleaned up at some future date.)

I went through all the text output in gdb to ensure that this change
should be ok.  There are a few cases:

* Any existing call to printf_unfiltered is required to be avoid the
  pager.  This is ensured directly in the implementation.

* All remaining calls to the f*_unfiltered functions -- the ones that
  take an explicit ui_file -- either send to an unfiltered stream
  (e.g., gdb_stderr), which is obviously ok; or conditionally send to
  gdb_stdout

  I investigated all such calls by searching for:

    grep -e '\bf[a-z0-9_]*_unfiltered' *.[chyl] */*.[ch] | grep -v gdb_stdlog | grep -v gdb_stderr

  This yields a number of candidates to check.

  * The breakpoint _print_recreate family, and
    save_trace_state_variables.  These are used for "save" commands
    and so are fine.

  * Things printing to a temporary stream.  Obviously ok.

  * Disassembly selftests.

  * print_gdb_help - this is non-obvious, but ok because paging isn't
    yet enabled at this point during startup.

  * serial.c - doens't use gdb_stdout

  * The code in compile/.  This is all printing to a file.

  * DWARF DIE dumping - doesn't reference gdb_stdout.

* Calls to the _filtered form -- these are all clearly ok, because if
  they are using gdb_stdout, then filtering will still apply; and if
  not, then filtering never applied and still will not.

Therefore, at this point, there is no longer any distinction between
all the other _filtered and _unfiltered calls, and they can be
unified.

In this patch, take special note of the vfprintf_maybe_filtered and
ui_file::vprintf change.  This is one instance of the above idea,
erasing the distinction between filtered and unfiltered -- in this
part of the change, the "unfiltered_output" flag is never passe to
cli_ui_out.  Subsequent patches will go much further in this
direction.

Also note the can_emit_style_escape changes in ui-file.c.  Checking
against gdb_stdout or gdb_stderr was always a bit of a hack; and now
it is no longer needed, because this is decision can be more fully
delegated to the particular ui_file implementation.

ui_file::can_page is removed, because this patch removed the only call
to it.

I think this is the main part of fixing PR cli/7234.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7234
---
 gdb/cli/cli-cmds.c |   2 +-
 gdb/event-top.c    |   3 +-
 gdb/pager.h        | 109 +++++++++++++++++++++
 gdb/printcmd.c     |   2 +-
 gdb/top.c          |   3 +-
 gdb/tui/tui-io.c   |   3 +-
 gdb/ui-file.c      |  10 +-
 gdb/ui-file.h      |  26 ++---
 gdb/utils.c        | 239 ++++++++++++++++++---------------------------
 gdb/utils.h        |   4 -
 10 files changed, 227 insertions(+), 174 deletions(-)
 create mode 100644 gdb/pager.h

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2f5ce3e5fff..3cdc7cde9a5 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -838,7 +838,7 @@ echo_command (const char *text, int from_tty)
 	  printf_filtered ("%c", c);
       }
 
-  reset_terminal_style (gdb_stdout);
+  gdb_stdout->reset_style ();
 
   /* Force this output to appear now.  */
   gdb_stdout->wrap_here (0);
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 039066a9d03..5db2a2acdd2 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -42,6 +42,7 @@
 #include "gdbsupport/gdb-sigmask.h"
 #include "async-event.h"
 #include "bt-utils.h"
+#include "pager.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
@@ -1279,7 +1280,7 @@ gdb_setup_readline (int editing)
      mess it up here.  The sync stuff should really go away over
      time.  */
   if (!batch_silent)
-    gdb_stdout = new stdio_file (ui->outstream);
+    gdb_stdout = new pager_file (new stdio_file (ui->outstream));
   gdb_stderr = new stderr_file (ui->errstream);
   gdb_stdlog = new timestamped_file (gdb_stderr);
   gdb_stdtarg = gdb_stderr; /* for moment */
diff --git a/gdb/pager.h b/gdb/pager.h
new file mode 100644
index 00000000000..0151a283629
--- /dev/null
+++ b/gdb/pager.h
@@ -0,0 +1,109 @@
+/* Output pager for gdb
+   Copyright (C) 2021, 2022 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef GDB_PAGER_H
+#define GDB_PAGER_H
+
+#include "ui-file.h"
+
+/* A ui_file that implements output paging and unfiltered output.  */
+
+class pager_file : public ui_file
+{
+public:
+  /* Create a new pager_file.  The new object takes ownership of
+     STREAM.  */
+  explicit pager_file (ui_file *stream)
+    : m_stream (stream)
+  {
+  }
+
+  DISABLE_COPY_AND_ASSIGN (pager_file);
+
+  void write (const char *buf, long length_buf) override;
+
+  void puts (const char *str) override;
+
+  void write_async_safe (const char *buf, long length_buf) override
+  {
+    m_stream->write_async_safe (buf, length_buf);
+  }
+
+  bool term_out () override
+  {
+    return m_stream->term_out ();
+  }
+
+  bool isatty () override
+  {
+    return m_stream->isatty ();
+  }
+
+  bool can_emit_style_escape () override
+  {
+    return m_stream->can_emit_style_escape ();
+  }
+
+  void emit_style_escape (const ui_file_style &style) override;
+  void reset_style () override;
+
+  void flush () override;
+
+  int fd () const override
+  {
+    return m_stream->fd ();
+  }
+
+  void wrap_here (int indent) override;
+
+  void puts_unfiltered (const char *str) override
+  {
+    flush_wrap_buffer ();
+    m_stream->puts_unfiltered (str);
+  }
+
+private:
+
+  void prompt_for_continue ();
+
+  /* Flush the wrap buffer to STREAM, if necessary.  */
+  void flush_wrap_buffer ();
+
+  /* Contains characters which are waiting to be output (they have
+     already been counted in chars_printed).  */
+  std::string m_wrap_buffer;
+
+  /* Amount to indent by if the wrap occurs.  */
+  int m_wrap_indent = 0;
+
+  /* Column number on the screen where wrap_buffer begins, or 0 if
+     wrapping is not in effect.  */
+  int m_wrap_column = 0;
+
+  /* The style applied at the time that wrap_here was called.  */
+  ui_file_style m_wrap_style;
+
+  /* The unfiltered output stream.  */
+  ui_file_up m_stream;
+
+  /* This is temporarily set when paging.  This will cause some
+     methods to change their behavior to ignore the wrap buffer.  */
+  bool m_paging = false;
+};
+
+#endif /* GDB_PAGER_H */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ab87310965d..f5ce0404d48 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2894,7 +2894,7 @@ static void
 printf_command (const char *arg, int from_tty)
 {
   ui_printf (arg, gdb_stdout);
-  reset_terminal_style (gdb_stdout);
+  gdb_stdout->reset_style ();
   gdb_stdout->wrap_here (0);
   gdb_stdout->flush ();
 }
diff --git a/gdb/top.c b/gdb/top.c
index 5d90ebbdf19..f0ee9920847 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -56,6 +56,7 @@
 #include "gdbarch.h"
 #include "gdbsupport/pathstuff.h"
 #include "cli/cli-style.h"
+#include "pager.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
@@ -285,7 +286,7 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
     input_fd (fileno (instream)),
     input_interactive_p (ISATTY (instream)),
     prompt_state (PROMPT_NEEDED),
-    m_gdb_stdout (new stdio_file (outstream)),
+    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 (m_gdb_stderr),
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 718375f9cd4..7aed0248ee7 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -44,6 +44,7 @@
 #include "completer.h"
 #include "gdb_curses.h"
 #include <map>
+#include "pager.h"
 
 /* This redefines CTRL if it is not already defined, so it must come
    after terminal state releated include files like <term.h> and
@@ -903,7 +904,7 @@ tui_initialize_io (void)
 #endif
 
   /* Create tui output streams.  */
-  tui_stdout = new tui_file (stdout);
+  tui_stdout = new pager_file (new tui_file (stdout));
   tui_stderr = new tui_file (stderr);
   tui_stdlog = new timestamped_file (tui_stderr);
   tui_out = tui_out_new (tui_stdout);
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 2072fd81954..f6878f76cf1 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -24,6 +24,7 @@
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/gdb_select.h"
 #include "gdbsupport/filestuff.h"
+#include "cli-out.h"
 #include "cli/cli-style.h"
 #include <chrono>
 
@@ -68,7 +69,8 @@ ui_file::putc (int c)
 void
 ui_file::vprintf (const char *format, va_list args)
 {
-  vfprintf_unfiltered (this, format, args);
+  ui_out_flags flags = disallow_ui_out_field;
+  cli_ui_out (this, flags).vmessage (m_applied_style, format, args);
 }
 
 /* See ui-file.h.  */
@@ -349,8 +351,7 @@ stdio_file::isatty ()
 bool
 stdio_file::can_emit_style_escape ()
 {
-  return ((this == gdb_stdout || this == gdb_stderr)
-	  && this->isatty ()
+  return (this->isatty ()
 	  && term_cli_styling ());
 }
 
@@ -438,8 +439,7 @@ tee_file::term_out ()
 bool
 tee_file::can_emit_style_escape ()
 {
-  return ((this == gdb_stdout || this == gdb_stderr)
-	  && m_one->term_out ()
+  return (m_one->term_out ()
 	  && term_cli_styling ());
 }
 
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 1ea2f60591c..7de30ed5584 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -99,16 +99,10 @@ class ui_file
   virtual int fd () const
   { return -1; }
 
-  /* Return true if this object supports paging, false otherwise.  */
-  virtual bool can_page () const
+  virtual void wrap_here (int indent)
   {
-    /* Almost no file supports paging, which is why this is the
-       default.  */
-    return false;
   }
 
-  void wrap_here (int indent);
-
   /* Emit an ANSI style escape for STYLE.  */
   virtual void emit_style_escape (const ui_file_style &style);
 
@@ -250,11 +244,6 @@ class stdio_file : public ui_file
   int fd () const override
   { return m_fd; }
 
-  virtual bool can_page () const override
-  {
-    return m_file == stdout;
-  }
-
 private:
   /* Sets the internal stream to FILE, and saves the FILE's file
      descriptor in M_FD.  */
@@ -329,11 +318,16 @@ class tee_file : public ui_file
   bool can_emit_style_escape () override;
   void flush () override;
 
-  virtual bool can_page () const override
+  void emit_style_escape (const ui_file_style &style) override
+  {
+    m_one->emit_style_escape (style);
+    m_two->emit_style_escape (style);
+  }
+
+  void reset_style () override
   {
-    /* If one of the underlying files can page, then we allow it
-       here.  */
-    return m_one->can_page () || m_two->can_page ();
+    m_one->reset_style ();
+    m_two->reset_style ();
   }
 
   void puts_unfiltered (const char *str) override
diff --git a/gdb/utils.c b/gdb/utils.c
index 6dbb46f9719..fff914e92b0 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -77,6 +77,7 @@
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "bt-utils.h"
 #include "gdbsupport/buildargv.h"
+#include "pager.h"
 
 void (*deprecated_error_begin_hook) (void);
 
@@ -86,10 +87,6 @@ static void vfprintf_maybe_filtered (struct ui_file *, const char *,
 				     va_list, bool)
   ATTRIBUTE_PRINTF (2, 0);
 
-static void fputs_maybe_filtered (const char *, struct ui_file *, int);
-
-static void prompt_for_continue (void);
-
 static void set_screen_size (void);
 static void set_width (void);
 
@@ -1171,19 +1168,6 @@ static bool pagination_disabled_for_command;
 
 static bool filter_initialized = false;
 
-/* Contains characters which are waiting to be output (they have
-   already been counted in chars_printed).  */
-static std::string wrap_buffer;
-
-/* String to indent by if the wrap occurs.  */
-static int wrap_indent;
-
-/* Column number on the screen where wrap_buffer begins, or 0 if wrapping
-   is not in effect.  */
-static int wrap_column;
-
-/* The style applied at the time that wrap_here was called.  */
-static ui_file_style wrap_style;
 \f
 
 /* Initialize the number of lines per page and chars per line.  */
@@ -1315,7 +1299,6 @@ set_width (void)
   if (chars_per_line == 0)
     init_page_info ();
 
-  wrap_buffer.clear ();
   filter_initialized = true;
 }
 
@@ -1344,55 +1327,28 @@ set_screen_width_and_height (int width, int height)
   set_width ();
 }
 
-/* The currently applied style.  */
-
-static ui_file_style applied_style;
-
-/* Emit an ANSI style escape for STYLE.  If STREAM is nullptr, emit to
-   the wrap buffer; otherwise emit to STREAM.  */
-
-static void
-emit_style_escape (const ui_file_style &style,
-		   struct ui_file *stream = nullptr)
+void
+pager_file::emit_style_escape (const ui_file_style &style)
 {
-  if (applied_style != style)
+  if (can_emit_style_escape () && style != m_applied_style)
     {
-      applied_style = style;
-
-      if (stream == nullptr)
-	wrap_buffer.append (style.to_ansi ());
+      m_applied_style = style;
+      if (m_paging)
+	m_stream->emit_style_escape (style);
       else
-	stream->puts (style.to_ansi ().c_str ());
+	m_wrap_buffer.append (style.to_ansi ());
     }
 }
 
-/* Set the current output style.  This will affect future uses of the
-   _filtered output functions.  */
-
-static void
-set_output_style (struct ui_file *stream, const ui_file_style &style)
-{
-  if (!stream->can_emit_style_escape ())
-    return;
-
-  /* Note that we may not pass STREAM here, when we want to emit to
-     the wrap buffer, not directly to STREAM.  */
-  if (stream == gdb_stdout)
-    stream = nullptr;
-  emit_style_escape (style, stream);
-}
-
-/* See utils.h.  */
+/* See pager.h.  */
 
 void
-reset_terminal_style (struct ui_file *stream)
+pager_file::reset_style ()
 {
-  if (stream->can_emit_style_escape ())
+  if (can_emit_style_escape ())
     {
-      /* Force the setting, regardless of what we think the setting
-	 might already be.  */
-      applied_style = ui_file_style ();
-      wrap_buffer.append (applied_style.to_ansi ());
+      m_applied_style = ui_file_style ();
+      m_wrap_buffer.append (m_applied_style.to_ansi ());
     }
 }
 
@@ -1401,8 +1357,8 @@ reset_terminal_style (struct ui_file *stream)
    telling users what to do in the prompt is more user-friendly than
    expecting them to think of Ctrl-C/SIGINT.  */
 
-static void
-prompt_for_continue (void)
+void
+pager_file::prompt_for_continue ()
 {
   char cont_prompt[120];
   /* Used to add duration we waited for user to respond to
@@ -1411,12 +1367,13 @@ prompt_for_continue (void)
   steady_clock::time_point prompt_started = steady_clock::now ();
   bool disable_pagination = pagination_disabled_for_command;
 
+  scoped_restore save_paging = make_scoped_restore (&m_paging, true);
+
   /* Clear the current styling.  */
-  if (gdb_stdout->can_emit_style_escape ())
-    emit_style_escape (ui_file_style (), gdb_stdout);
+  m_stream->emit_style_escape (ui_file_style ());
 
   if (annotation_level > 1)
-    printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
+    m_stream->puts (("\n\032\032pre-prompt-for-continue\n"));
 
   strcpy (cont_prompt,
 	  "--Type <RET> for more, q to quit, "
@@ -1439,7 +1396,7 @@ prompt_for_continue (void)
   prompt_for_continue_wait_time += steady_clock::now () - prompt_started;
 
   if (annotation_level > 1)
-    printf_unfiltered (("\n\032\032post-prompt-for-continue\n"));
+    m_stream->puts (("\n\032\032post-prompt-for-continue\n"));
 
   if (ignore != NULL)
     {
@@ -1490,24 +1447,28 @@ reinitialize_more_filter (void)
   pagination_disabled_for_command = false;
 }
 
-/* Flush the wrap buffer to STREAM, if necessary.  */
-
-static void
-flush_wrap_buffer (struct ui_file *stream)
+void
+pager_file::flush_wrap_buffer ()
 {
-  if (stream == gdb_stdout && !wrap_buffer.empty ())
+  if (!m_paging && !m_wrap_buffer.empty ())
     {
-      stream->puts (wrap_buffer.c_str ());
-      wrap_buffer.clear ();
+      m_stream->puts (m_wrap_buffer.c_str ());
+      m_wrap_buffer.clear ();
     }
 }
 
+void
+pager_file::flush ()
+{
+  flush_wrap_buffer ();
+  m_stream->flush ();
+}
+
 /* See utils.h.  */
 
 void
 gdb_flush (struct ui_file *stream)
 {
-  flush_wrap_buffer (stream);
   stream->flush ();
 }
 
@@ -1522,28 +1483,28 @@ get_chars_per_line ()
 /* See ui-file.h.  */
 
 void
-ui_file::wrap_here (int indent)
+pager_file::wrap_here (int indent)
 {
   /* This should have been allocated, but be paranoid anyway.  */
   gdb_assert (filter_initialized);
 
-  flush_wrap_buffer (this);
+  flush_wrap_buffer ();
   if (chars_per_line == UINT_MAX)	/* No line overflow checking.  */
     {
-      wrap_column = 0;
+      m_wrap_column = 0;
     }
   else if (chars_printed >= chars_per_line)
     {
-      puts_filtered ("\n");
+      this->puts ("\n");
       if (indent != 0)
-	puts_filtered (n_spaces (indent));
-      wrap_column = 0;
+	this->puts (n_spaces (indent));
+      m_wrap_column = 0;
     }
   else
     {
-      wrap_column = chars_printed;
-      wrap_indent = indent;
-      wrap_style = applied_style;
+      m_wrap_column = chars_printed;
+      m_wrap_indent = indent;
+      m_wrap_style = m_applied_style;
     }
 }
 
@@ -1620,9 +1581,8 @@ begin_line (void)
    FILTER is true) (since prompt_for_continue may do so) so this
    routine should not be called when cleanups are not in place.  */
 
-static void
-fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
-		      int filter)
+void
+pager_file::puts (const char *linebuffer)
 {
   const char *lineptr;
 
@@ -1630,26 +1590,24 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
     return;
 
   /* Don't do any filtering if it is disabled.  */
-  if (!stream->can_page ()
-      || stream != gdb_stdout
-      || !pagination_enabled
+  if (!pagination_enabled
       || pagination_disabled_for_command
       || batch_flag
       || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
       || top_level_interpreter () == NULL
       || top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ())
     {
-      flush_wrap_buffer (stream);
-      stream->puts (linebuffer);
+      flush_wrap_buffer ();
+      m_stream->puts (linebuffer);
       return;
     }
 
   auto buffer_clearer
     = make_scope_exit ([&] ()
 		       {
-			 wrap_buffer.clear ();
-			 wrap_column = 0;
-			 wrap_indent = 0;
+			 m_wrap_buffer.clear ();
+			 m_wrap_column = 0;
+			 m_wrap_indent = 0;
 		       });
 
   /* Go through and output each character.  Show line extension
@@ -1662,7 +1620,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
       /* Possible new page.  Note that PAGINATION_DISABLED_FOR_COMMAND
 	 might be set during this loop, so we must continue to check
 	 it here.  */
-      if (filter && (lines_printed >= lines_per_page - 1)
+      if ((lines_printed >= lines_per_page - 1)
 	  && !pagination_disabled_for_command)
 	prompt_for_continue ();
 
@@ -1673,7 +1631,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 	  /* Print a single line.  */
 	  if (*lineptr == '\t')
 	    {
-	      wrap_buffer.push_back ('\t');
+	      m_wrap_buffer.push_back ('\t');
 	      /* Shifting right by 3 produces the number of tab stops
 		 we have already passed, and then adding one and
 		 shifting left 3 advances to the next tab stop.  */
@@ -1683,20 +1641,20 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 	  else if (*lineptr == '\033'
 		   && skip_ansi_escape (lineptr, &skip_bytes))
 	    {
-	      wrap_buffer.append (lineptr, skip_bytes);
+	      m_wrap_buffer.append (lineptr, skip_bytes);
 	      /* Note that we don't consider this a character, so we
 		 don't increment chars_printed here.  */
 	      lineptr += skip_bytes;
 	    }
 	  else if (*lineptr == '\r')
 	    {
-	      wrap_buffer.push_back (*lineptr);
+	      m_wrap_buffer.push_back (*lineptr);
 	      chars_printed = 0;
 	      lineptr++;
 	    }
 	  else
 	    {
-	      wrap_buffer.push_back (*lineptr);
+	      m_wrap_buffer.push_back (*lineptr);
 	      chars_printed++;
 	      lineptr++;
 	    }
@@ -1711,12 +1669,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 		 prompt is given; and to avoid emitting style
 		 sequences in the middle of a run of text, we track
 		 this as well.  */
-	      ui_file_style save_style = applied_style;
+	      ui_file_style save_style = m_applied_style;
 	      bool did_paginate = false;
 
 	      chars_printed = 0;
 	      lines_printed++;
-	      if (wrap_column)
+	      if (m_wrap_column)
 		{
 		  /* We are about to insert a newline at an historic
 		     location in the WRAP_BUFFER.  Before we do we want to
@@ -1724,22 +1682,16 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 		     need to insert an escape sequence we must restore the
 		     current applied style to how it was at the WRAP_COLUMN
 		     location.  */
-		  applied_style = wrap_style;
-		  if (stream->can_emit_style_escape ())
-		    emit_style_escape (ui_file_style (), stream);
+		  m_applied_style = m_wrap_style;
+		  m_stream->emit_style_escape (ui_file_style ());
 		  /* If we aren't actually wrapping, don't output
 		     newline -- if chars_per_line is right, we
 		     probably just overflowed anyway; if it's wrong,
 		     let us keep going.  */
-		  /* XXX: The ideal thing would be to call
-		     'stream->putc' here, but we can't because it
-		     currently calls 'fputc_unfiltered', which ends up
-		     calling us, which generates an infinite
-		     recursion.  */
-		  stream->puts ("\n");
+		  m_stream->puts ("\n");
 		}
 	      else
-		flush_wrap_buffer (stream);
+		this->flush_wrap_buffer ();
 
 	      /* Possible new page.  Note that
 		 PAGINATION_DISABLED_FOR_COMMAND might be set during
@@ -1752,44 +1704,37 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 		}
 
 	      /* Now output indentation and wrapped string.  */
-	      if (wrap_column)
+	      if (m_wrap_column)
 		{
-		  stream->puts (n_spaces (wrap_indent));
+		  m_stream->puts (n_spaces (m_wrap_indent));
 
 		  /* Having finished inserting the wrapping we should
 		     restore the style as it was at the WRAP_COLUMN.  */
-		  if (stream->can_emit_style_escape ())
-		    emit_style_escape (wrap_style, stream);
+		  m_stream->emit_style_escape (m_wrap_style);
 
 		  /* The WRAP_BUFFER will still contain content, and that
 		     content might set some alternative style.  Restore
 		     APPLIED_STYLE as it was before we started wrapping,
 		     this reflects the current style for the last character
 		     in WRAP_BUFFER.  */
-		  applied_style = save_style;
+		  m_applied_style = save_style;
 
 		  /* Note that this can set chars_printed > chars_per_line
 		     if we are printing a long string.  */
-		  chars_printed = wrap_indent + (save_chars - wrap_column);
-		  wrap_column = 0;	/* And disable fancy wrap */
+		  chars_printed = m_wrap_indent + (save_chars - m_wrap_column);
+		  m_wrap_column = 0;	/* And disable fancy wrap */
 		}
-	      else if (did_paginate && stream->can_emit_style_escape ())
-		emit_style_escape (save_style, stream);
+	      else if (did_paginate)
+		m_stream->emit_style_escape (save_style);
 	    }
 	}
 
       if (*lineptr == '\n')
 	{
 	  chars_printed = 0;
-	  stream->wrap_here (0); /* Spit out chars, cancel
-				    further wraps.  */
+	  wrap_here (0); /* Spit out chars, cancel further wraps.  */
 	  lines_printed++;
-	  /* XXX: The ideal thing would be to call
-	     'stream->putc' here, but we can't because it
-	     currently calls 'fputc_unfiltered', which ends up
-	     calling us, which generates an infinite
-	     recursion.  */
-	  stream->puts ("\n");
+	  m_stream->puts ("\n");
 	  lineptr++;
 	}
     }
@@ -1798,15 +1743,24 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
 }
 
 void
-fputs_filtered (const char *linebuffer, struct ui_file *stream)
+pager_file::write (const char *buf, long length_buf)
 {
-  fputs_maybe_filtered (linebuffer, stream, 1);
+  /* We have to make a string here because the pager uses
+     skip_ansi_escape, which requires NUL-termination.  */
+  std::string str (buf, length_buf);
+  this->puts (str.c_str ());
 }
 
 void
 fputs_unfiltered (const char *linebuffer, struct ui_file *stream)
 {
-  fputs_maybe_filtered (linebuffer, stream, 0);
+  stream->puts_unfiltered (linebuffer);
+}
+
+void
+fputs_filtered (const char *linebuffer, struct ui_file *stream)
+{
+  stream->puts (linebuffer);
 }
 
 /* See utils.h.  */
@@ -1815,9 +1769,9 @@ void
 fputs_styled (const char *linebuffer, const ui_file_style &style,
 	      struct ui_file *stream)
 {
-  set_output_style (stream, style);
-  fputs_maybe_filtered (linebuffer, stream, 1);
-  set_output_style (stream, ui_file_style ());
+  stream->emit_style_escape (style);
+  fputs_filtered (linebuffer, stream);
+  stream->emit_style_escape (ui_file_style ());
 }
 
 /* See utils.h.  */
@@ -1826,9 +1780,9 @@ void
 fputs_styled_unfiltered (const char *linebuffer, const ui_file_style &style,
 			 struct ui_file *stream)
 {
-  set_output_style (stream, style);
-  fputs_maybe_filtered (linebuffer, stream, 0);
-  set_output_style (stream, ui_file_style ());
+  stream->emit_style_escape (style);
+  stream->puts_unfiltered (linebuffer);
+  stream->emit_style_escape (ui_file_style ());
 }
 
 /* See utils.h.  */
@@ -1852,14 +1806,14 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
 	}
 
       /* Output pmatch with the highlight style.  */
-      set_output_style (stream, highlight_style.style ());
+      stream->emit_style_escape (highlight_style.style ());
       while (n_highlight > 0)
 	{
 	  fputc_filtered (*str, stream);
 	  n_highlight--;
 	  str++;
 	}
-      set_output_style (stream, ui_file_style ());
+      stream->emit_style_escape (ui_file_style ());
     }
 
   /* Output the trailing part of STR not matching HIGHLIGHT.  */
@@ -1915,10 +1869,7 @@ static void
 vfprintf_maybe_filtered (struct ui_file *stream, const char *format,
 			 va_list args, bool filter)
 {
-  ui_out_flags flags = disallow_ui_out_field;
-  if (!filter)
-    flags |= unfiltered_output;
-  cli_ui_out (stream, flags).vmessage (applied_style, format, args);
+  stream->vprintf (format, args);
 }
 
 
@@ -1974,11 +1925,11 @@ fprintf_styled (struct ui_file *stream, const ui_file_style &style,
 {
   va_list args;
 
-  set_output_style (stream, style);
+  stream->emit_style_escape (style);
   va_start (args, format);
   vfprintf_filtered (stream, format, args);
   va_end (args);
-  set_output_style (stream, ui_file_style ());
+  stream->emit_style_escape (ui_file_style ());
 }
 
 /* See utils.h.  */
@@ -1987,9 +1938,9 @@ void
 vfprintf_styled (struct ui_file *stream, const ui_file_style &style,
 		 const char *format, va_list args)
 {
-  set_output_style (stream, style);
+  stream->emit_style_escape (style);
   vfprintf_filtered (stream, format, args);
-  set_output_style (stream, ui_file_style ());
+  stream->emit_style_escape (ui_file_style ());
 }
 
 void
diff --git a/gdb/utils.h b/gdb/utils.h
index 5d8ed670e66..7ec8198b2ff 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -305,10 +305,6 @@ extern void fputs_styled_unfiltered (const char *linebuffer,
 extern void fputs_highlighted (const char *str, const compiled_regex &highlight,
 			       struct ui_file *stream);
 
-/* Reset the terminal style to the default, if needed.  */
-
-extern void reset_terminal_style (struct ui_file *stream);
-
 /* Return the address only having significant bits.  */
 extern CORE_ADDR address_significant (gdbarch *gdbarch, CORE_ADDR addr);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 08/19] Remove fputs_styled_unfiltered
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (6 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 07/19] Change the pager to a ui_file Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 09/19] Unify vprintf functions Tom Tromey
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

fputs_styled_unfiltered is only called from cli_ui_out, so remove it.
This area will be further simplified in future patches.
---
 gdb/cli-out.c | 14 ++++++++++----
 gdb/utils.c   | 11 -----------
 gdb/utils.h   |  6 ------
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index a7fcc623897..f6a508393ef 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -171,10 +171,13 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align,
 
   if (string)
     {
+      ui_file *stream = m_streams.back ();
+      stream->emit_style_escape (style);
       if (test_flags (unfiltered_output))
-	fputs_styled_unfiltered (string, style, m_streams.back ());
+	stream->puts_unfiltered (string);
       else
-	fputs_styled (string, style, m_streams.back ());
+	stream->puts (string);
+      stream->emit_style_escape (ui_file_style ());
     }
 
   if (after)
@@ -233,10 +236,13 @@ cli_ui_out::do_message (const ui_file_style &style,
   std::string str = string_vprintf (format, args);
   if (!str.empty ())
     {
+      ui_file *stream = m_streams.back ();
+      stream->emit_style_escape (style);
       if (test_flags (unfiltered_output))
-	fputs_styled_unfiltered (str.c_str (), style, m_streams.back ());
+	stream->puts_unfiltered (str.c_str ());
       else
-	fputs_styled (str.c_str (), style, m_streams.back ());
+	stream->puts (str.c_str ());
+      stream->emit_style_escape (ui_file_style ());
     }
 }
 
diff --git a/gdb/utils.c b/gdb/utils.c
index fff914e92b0..0254286e8ac 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1776,17 +1776,6 @@ fputs_styled (const char *linebuffer, const ui_file_style &style,
 
 /* See utils.h.  */
 
-void
-fputs_styled_unfiltered (const char *linebuffer, const ui_file_style &style,
-			 struct ui_file *stream)
-{
-  stream->emit_style_escape (style);
-  stream->puts_unfiltered (linebuffer);
-  stream->emit_style_escape (ui_file_style ());
-}
-
-/* See utils.h.  */
-
 void
 fputs_highlighted (const char *str, const compiled_regex &highlight,
 		   struct ui_file *stream)
diff --git a/gdb/utils.h b/gdb/utils.h
index 7ec8198b2ff..cb322c34396 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -293,12 +293,6 @@ extern void fputs_styled (const char *linebuffer,
 			  const ui_file_style &style,
 			  struct ui_file *stream);
 
-/* Unfiltered variant of fputs_styled.  */
-
-extern void fputs_styled_unfiltered (const char *linebuffer,
-				     const ui_file_style &style,
-				     struct ui_file *stream);
-
 /* Like fputs_styled, but uses highlight_style to highlight the
    parts of STR that match HIGHLIGHT.  */
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 09/19] Unify vprintf functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (7 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 08/19] Remove fputs_styled_unfiltered Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 10/19] Unify gdb puts functions Tom Tromey
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that filtered and unfiltered output can be treated identically, we
can unify the vprintf family of functions: vprintf_filtered,
vprintf_unfiltered, vfprintf_filtered and vfprintf_unfiltered.  (For
the gdb_stdout variants, recall that only printf_unfiltered gets truly
unfiltered output at this point.)  This removes one such function and
renames the remaining two to "gdb_vprintf".  All callers are updated.
Much of this patch was written by script.
---
 gdb/cli/cli-cmds.c        |  2 +-
 gdb/cli/cli-script.c      |  2 +-
 gdb/complaints.c          |  2 +-
 gdb/debug.c               |  2 +-
 gdb/disasm.c              |  2 +-
 gdb/exceptions.c          |  2 +-
 gdb/language.c            |  2 +-
 gdb/mi/mi-out.c           |  2 +-
 gdb/parse.c               |  4 +--
 gdb/remote-sim.c          |  8 +++---
 gdb/sol-thread.c          |  2 +-
 gdb/target-descriptions.c |  2 +-
 gdb/ui-file.c             |  2 +-
 gdb/utils.c               | 59 ++++++++-------------------------------
 gdb/utils.h               |  9 ++----
 15 files changed, 30 insertions(+), 72 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3cdc7cde9a5..aaa07b7dc50 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -2020,7 +2020,7 @@ ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
 {
   va_list ap;
   va_start (ap, format);
-  vprintf_filtered (format, ap);
+  gdb_vprintf (format, ap);
   va_end (ap);
 
   for (const auto &sal : sals)
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 55248de649b..67613aa0bc0 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -501,7 +501,7 @@ print_command_trace (const char *fmt, ...)
   va_list args;
 
   va_start (args, fmt);
-  vprintf_filtered (fmt, args);
+  gdb_vprintf (fmt, args);
   va_end (args);
   puts_filtered ("\n");
 }
diff --git a/gdb/complaints.c b/gdb/complaints.c
index 2c2d90a39d2..b582bf38f11 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -51,7 +51,7 @@ complaint_internal (const char *fmt, ...)
   else
     {
       fputs_filtered (_("During symbol reading: "), gdb_stderr);
-      vfprintf_filtered (gdb_stderr, fmt, args);
+      gdb_vprintf (gdb_stderr, fmt, args);
       fputs_filtered ("\n", gdb_stderr);
     }
 
diff --git a/gdb/debug.c b/gdb/debug.c
index 6f9cad0ddd0..b29a6620afe 100644
--- a/gdb/debug.c
+++ b/gdb/debug.c
@@ -30,5 +30,5 @@ int debug_print_depth = 0;
 void
 debug_vprintf (const char *fmt, va_list ap)
 {
-  vfprintf_unfiltered (gdb_stdlog, fmt, ap);
+  gdb_vprintf (gdb_stdlog, fmt, ap);
 }
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 3000e5dddad..9564f1ca8ec 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -171,7 +171,7 @@ gdb_disassembler::dis_asm_fprintf (void *stream, const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_filtered ((struct ui_file *) stream, format, args);
+  gdb_vprintf ((struct ui_file *) stream, format, args);
   va_end (args);
   /* Something non -ve.  */
   return 0;
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 16e26d5e4b1..b23ab0e4f33 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -127,7 +127,7 @@ exception_fprintf (struct ui_file *file, const struct gdb_exception &e,
 
       /* Print the prefix.  */
       va_start (args, prefix);
-      vfprintf_filtered (file, prefix, args);
+      gdb_vprintf (file, prefix, args);
       va_end (args);
 
       print_exception (file, e);
diff --git a/gdb/language.c b/gdb/language.c
index 0846b3e5eeb..c4d11758d10 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -414,7 +414,7 @@ range_error (const char *string,...)
     case range_check_off:
       /* FIXME: cagney/2002-01-30: Should this function print anything
 	 when range error is off?  */
-      vfprintf_filtered (gdb_stderr, string, args);
+      gdb_vprintf (gdb_stderr, string, args);
       fprintf_filtered (gdb_stderr, "\n");
       break;
     default:
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 53f7206addd..5145bea4b75 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -151,7 +151,7 @@ mi_ui_out::do_field_fmt (int fldno, int width, ui_align align,
     fprintf_unfiltered (stream, "%s=\"", fldname);
   else
     fputs_unfiltered ("\"", stream);
-  vfprintf_unfiltered (stream, format, args);
+  gdb_vprintf (stream, format, args);
   fputs_unfiltered ("\"", stream);
 }
 
diff --git a/gdb/parse.c b/gdb/parse.c
index a6595e3da06..abd6beac2d0 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -632,11 +632,11 @@ parser_fprintf (FILE *x, const char *y, ...)
 
   va_start (args, y);
   if (x == stderr)
-    vfprintf_unfiltered (gdb_stderr, y, args); 
+    gdb_vprintf (gdb_stderr, y, args); 
   else
     {
       fprintf_unfiltered (gdb_stderr, " Unknown FILE used.\n");
-      vfprintf_unfiltered (gdb_stderr, y, args);
+      gdb_vprintf (gdb_stderr, y, args);
     }
   va_end (args);
 }
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 39bddec77b3..a87e86aaeaf 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -401,16 +401,16 @@ gdb_os_printf_filtered (host_callback * p, const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_filtered (gdb_stdout, format, args);
+  gdb_vprintf (gdb_stdout, format, args);
   va_end (args);
 }
 
-/* GDB version of error vprintf_filtered.  */
+/* GDB version of error gdb_vprintf.  */
 
 static void ATTRIBUTE_PRINTF (2, 0)
 gdb_os_vprintf_filtered (host_callback * p, const char *format, va_list ap)
 {
-  vfprintf_filtered (gdb_stdout, format, ap);
+  gdb_vprintf (gdb_stdout, format, ap);
 }
 
 /* GDB version of error evprintf_filtered.  */
@@ -418,7 +418,7 @@ gdb_os_vprintf_filtered (host_callback * p, const char *format, va_list ap)
 static void ATTRIBUTE_PRINTF (2, 0)
 gdb_os_evprintf_filtered (host_callback * p, const char *format, va_list ap)
 {
-  vfprintf_filtered (gdb_stderr, format, ap);
+  gdb_vprintf (gdb_stderr, format, ap);
 }
 
 /* GDB version of error callback.  */
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 0bfdbdf5037..f1991bec342 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -882,7 +882,7 @@ ps_plog (const char *fmt, ...)
 
   va_start (args, fmt);
 
-  vfprintf_filtered (gdb_stderr, fmt, args);
+  gdb_vprintf (gdb_stderr, fmt, args);
 }
 
 /* Get size of extra register set.  Currently a noop.  */
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 7c380cdb60f..4c187754c65 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1581,7 +1581,7 @@ class print_c_tdesc : public tdesc_element_visitor
 
     va_list args;
     va_start (args, fmt);
-    vprintf_filtered (fmt, args);
+    gdb_vprintf (fmt, args);
     va_end (args);
   }
 
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index f6878f76cf1..ec441a73a8c 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -42,7 +42,7 @@ ui_file::printf (const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_unfiltered (this, format, args);
+  vprintf (format, args);
   va_end (args);
 }
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 0254286e8ac..4a3d5397bc7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -83,10 +83,6 @@ void (*deprecated_error_begin_hook) (void);
 
 /* Prototypes for local functions */
 
-static void vfprintf_maybe_filtered (struct ui_file *, const char *,
-				     va_list, bool)
-  ATTRIBUTE_PRINTF (2, 0);
-
 static void set_screen_size (void);
 static void set_width (void);
 
@@ -155,7 +151,7 @@ vwarning (const char *string, va_list args)
       gdb_flush (gdb_stdout);
       if (warning_pre_print)
 	fputs_unfiltered (warning_pre_print, gdb_stderr);
-      vfprintf_unfiltered (gdb_stderr, string, args);
+      gdb_vprintf (gdb_stderr, string, args);
       fprintf_unfiltered (gdb_stderr, "\n");
     }
 }
@@ -879,7 +875,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
       target_terminal::scoped_restore_terminal_state term_state;
       target_terminal::ours_for_output ();
       gdb_stdout->wrap_here (0);
-      vfprintf_filtered (gdb_stdout, ctlstr, args);
+      gdb_vprintf (gdb_stdout, ctlstr, args);
 
       printf_filtered (_("(%s or %s) [answered %c; "
 			 "input not from terminal]\n"),
@@ -1841,49 +1837,16 @@ fputc_filtered (int c, struct ui_file *stream)
   return c;
 }
 
-/* Print a variable number of ARGS using format FORMAT.  If this
-   information is going to put the amount written (since the last call
-   to REINITIALIZE_MORE_FILTER or the last page break) over the page size,
-   call prompt_for_continue to get the users permission to continue.
-
-   Unlike fprintf, this function does not return a value.
-
-   We implement three variants, vfprintf (takes a vararg list and stream),
-   fprintf (takes a stream to write on), and printf (the usual).
-
-   Note also that this may throw a quit (since prompt_for_continue may
-   do so).  */
-
-static void
-vfprintf_maybe_filtered (struct ui_file *stream, const char *format,
-			 va_list args, bool filter)
-{
-  stream->vprintf (format, args);
-}
-
-
-void
-vfprintf_filtered (struct ui_file *stream, const char *format, va_list args)
-{
-  vfprintf_maybe_filtered (stream, format, args, true);
-}
-
 void
-vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
+gdb_vprintf (struct ui_file *stream, const char *format, va_list args)
 {
-  vfprintf_maybe_filtered (stream, format, args, false);
-}
-
-void
-vprintf_filtered (const char *format, va_list args)
-{
-  vfprintf_filtered (gdb_stdout, format, args);
+  stream->vprintf (format, args);
 }
 
 void
-vprintf_unfiltered (const char *format, va_list args)
+gdb_vprintf (const char *format, va_list args)
 {
-  vfprintf_unfiltered (gdb_stdout, format, args);
+  gdb_stdout->vprintf (format, args);
 }
 
 void
@@ -1892,7 +1855,7 @@ fprintf_filtered (struct ui_file *stream, const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_filtered (stream, format, args);
+  gdb_vprintf (stream, format, args);
   va_end (args);
 }
 
@@ -1902,7 +1865,7 @@ fprintf_unfiltered (struct ui_file *stream, const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_unfiltered (stream, format, args);
+  gdb_vprintf (stream, format, args);
   va_end (args);
 }
 
@@ -1916,7 +1879,7 @@ fprintf_styled (struct ui_file *stream, const ui_file_style &style,
 
   stream->emit_style_escape (style);
   va_start (args, format);
-  vfprintf_filtered (stream, format, args);
+  gdb_vprintf (stream, format, args);
   va_end (args);
   stream->emit_style_escape (ui_file_style ());
 }
@@ -1928,7 +1891,7 @@ vfprintf_styled (struct ui_file *stream, const ui_file_style &style,
 		 const char *format, va_list args)
 {
   stream->emit_style_escape (style);
-  vfprintf_filtered (stream, format, args);
+  gdb_vprintf (stream, format, args);
   stream->emit_style_escape (ui_file_style ());
 }
 
@@ -1938,7 +1901,7 @@ printf_filtered (const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_filtered (gdb_stdout, format, args);
+  gdb_vprintf (gdb_stdout, format, args);
   va_end (args);
 }
 
diff --git a/gdb/utils.h b/gdb/utils.h
index cb322c34396..268886d716a 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -244,9 +244,9 @@ extern void puts_filtered (const char *);
 
 extern void puts_filtered_tabular (char *string, int width, int right);
 
-extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
+extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
 
-extern void vfprintf_filtered (struct ui_file *, const char *, va_list)
+extern void gdb_vprintf (struct ui_file *, const char *, va_list)
   ATTRIBUTE_PRINTF (2, 0);
 
 extern void fprintf_filtered (struct ui_file *, const char *, ...)
@@ -254,11 +254,6 @@ extern void fprintf_filtered (struct ui_file *, const char *, ...)
 
 extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
 
-extern void vprintf_unfiltered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
-
-extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list)
-  ATTRIBUTE_PRINTF (2, 0);
-
 extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 10/19] Unify gdb puts functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (8 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 09/19] Unify vprintf functions Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 11/19] Unify gdb putc functions Tom Tromey
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that filtered and unfiltered output can be treated identically, we
can unify the puts family of functions.  This is done under the name
"gdb_puts".  Most of this patch was written by script.
---
 gdb/ada-typeprint.c               |   4 +-
 gdb/ada-valprint.c                |  30 +-
 gdb/arm-tdep.c                    |  14 +-
 gdb/ax-general.c                  |   2 +-
 gdb/c-lang.c                      |   6 +-
 gdb/c-typeprint.c                 |  34 +-
 gdb/c-valprint.c                  |  16 +-
 gdb/cli-out.c                     |   4 +-
 gdb/cli/cli-decode.c              |  40 +-
 gdb/cli/cli-dump.c                |   2 +-
 gdb/cli/cli-script.c              |   4 +-
 gdb/cli/cli-style.c               |   2 +-
 gdb/compile/compile-c-support.c   | 128 +++---
 gdb/compile/compile-cplus-types.c |   6 +-
 gdb/compile/compile.c             |   2 +-
 gdb/complaints.c                  |   4 +-
 gdb/cp-valprint.c                 |  26 +-
 gdb/disasm.c                      |   6 +-
 gdb/dwarf2/loc.c                  |   2 +-
 gdb/dwarf2/read.c                 |   6 +-
 gdb/event-top.c                   |   4 +-
 gdb/exceptions.c                  |   2 +-
 gdb/exec.c                        |   2 +-
 gdb/expprint.c                    |  26 +-
 gdb/f-lang.h                      |   6 +-
 gdb/f-typeprint.c                 |  18 +-
 gdb/f-valprint.c                  |  30 +-
 gdb/gdbtypes.c                    |  60 +--
 gdb/gnu-v3-abi.c                  |   8 +-
 gdb/go-typeprint.c                |   2 +-
 gdb/go-valprint.c                 |   4 +-
 gdb/go32-nat.c                    |  62 +--
 gdb/guile/scm-ports.c             |   2 +-
 gdb/guile/scm-pretty-print.c      |  28 +-
 gdb/i387-tdep.c                   |  62 +--
 gdb/infcmd.c                      |  28 +-
 gdb/infrun.c                      |   6 +-
 gdb/jit.c                         |   4 +-
 gdb/linux-fork.c                  |   2 +-
 gdb/linux-tdep.c                  |   2 +-
 gdb/linux-thread-db.c             |   2 +-
 gdb/m2-lang.c                     |  32 +-
 gdb/m2-typeprint.c                |  24 +-
 gdb/m2-valprint.c                 |  16 +-
 gdb/macrocmd.c                    |  24 +-
 gdb/main.c                        |  20 +-
 gdb/maint-test-options.c          |   2 +-
 gdb/maint.c                       |   2 +-
 gdb/make-target-delegates         |   8 +-
 gdb/mi/mi-console.c               |   2 +-
 gdb/mi/mi-interp.c                |   8 +-
 gdb/mi/mi-main.c                  |  42 +-
 gdb/mi/mi-out.c                   |   4 +-
 gdb/mips-linux-nat.c              |   4 +-
 gdb/mips-tdep.c                   |  40 +-
 gdb/p-lang.c                      |  20 +-
 gdb/p-lang.h                      |   2 +-
 gdb/p-typeprint.c                 |  48 +-
 gdb/p-valprint.c                  |  42 +-
 gdb/printcmd.c                    |  26 +-
 gdb/psymtab.c                     |  90 ++--
 gdb/python/py-framefilter.c       |   4 +-
 gdb/python/py-prettyprint.c       |  28 +-
 gdb/remote-sim.c                  |   4 +-
 gdb/remote.c                      |  24 +-
 gdb/riscv-tdep.c                  |   2 +-
 gdb/rust-lang.c                   | 102 ++---
 gdb/rust-lang.h                   |   4 +-
 gdb/s12z-tdep.c                   |   2 +-
 gdb/ser-base.c                    |   6 +-
 gdb/serial.c                      |  24 +-
 gdb/source.c                      |   6 +-
 gdb/stack.c                       |  50 +-
 gdb/symfile.c                     |  14 +-
 gdb/symmisc.c                     |  22 +-
 gdb/symtab.c                      |   2 +-
 gdb/target-debug.h                |  14 +-
 gdb/target-delegates.c            | 736 +++++++++++++++---------------
 gdb/target-descriptions.c         |   2 +-
 gdb/target.c                      |   2 +-
 gdb/tui/tui-layout.c              |  10 +-
 gdb/typeprint.c                   |   8 +-
 gdb/utils.c                       |  48 +-
 gdb/utils.h                       |   8 +-
 gdb/valprint.c                    |  64 +--
 gdb/windows-nat.c                 |  58 +--
 86 files changed, 1195 insertions(+), 1203 deletions(-)

diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 5f225ffb633..ad8a2215558 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -880,7 +880,7 @@ print_func_type (struct type *type, struct ui_file *stream, const char *name,
 
   if (name != NULL && name[0] != '\0')
     {
-      fputs_filtered (" ", stream);
+      gdb_puts (" ", stream);
       fputs_styled (name, function_name_style.style (), stream);
     }
 
@@ -891,7 +891,7 @@ print_func_type (struct type *type, struct ui_file *stream, const char *name,
 	{
 	  if (i > 0)
 	    {
-	      fputs_filtered ("; ", stream);
+	      gdb_puts ("; ", stream);
 	      stream->wrap_here (4);
 	    }
 	  fprintf_filtered (stream, "a%d: ", i + 1);
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 43919aedcba..dc1694e9c93 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -351,9 +351,9 @@ ada_print_floating (const gdb_byte *valaddr, struct type *type,
 void
 ada_printchar (int c, struct type *type, struct ui_file *stream)
 {
-  fputs_filtered ("'", stream);
+  gdb_puts ("'", stream);
   ada_emit_char (c, type, stream, '\'', TYPE_LENGTH (type));
-  fputs_filtered ("'", stream);
+  gdb_puts ("'", stream);
 }
 
 /* [From print_type_scalar in typeprint.c].   Print VAL on STREAM in a
@@ -455,7 +455,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 
   if (length == 0)
     {
-      fputs_filtered ("\"\"", stream);
+      gdb_puts ("\"\"", stream);
       return;
     }
 
@@ -471,7 +471,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 
       if (need_comma)
 	{
-	  fputs_filtered (", ", stream);
+	  gdb_puts (", ", stream);
 	  need_comma = 0;
 	}
 
@@ -489,13 +489,13 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 	{
 	  if (in_quotes)
 	    {
-	      fputs_filtered ("\", ", stream);
+	      gdb_puts ("\", ", stream);
 	      in_quotes = 0;
 	    }
-	  fputs_filtered ("'", stream);
+	  gdb_puts ("'", stream);
 	  ada_emit_char (char_at (string, i, type_len, byte_order),
 			 elttype, stream, '\'', type_len);
-	  fputs_filtered ("'", stream);
+	  gdb_puts ("'", stream);
 	  fprintf_filtered (stream, _(" %p[<repeats %u times>%p]"),
 			    metadata_style.style ().ptr (), reps, nullptr);
 	  i = rep1 - 1;
@@ -506,7 +506,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 	{
 	  if (!in_quotes)
 	    {
-	      fputs_filtered ("\"", stream);
+	      gdb_puts ("\"", stream);
 	      in_quotes = 1;
 	    }
 	  ada_emit_char (char_at (string, i, type_len, byte_order),
@@ -517,10 +517,10 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
-    fputs_filtered ("\"", stream);
+    gdb_puts ("\"", stream);
 
   if (force_ellipses || i < length)
-    fputs_filtered ("...", stream);
+    gdb_puts ("...", stream);
 }
 
 void
@@ -622,7 +622,7 @@ print_field_values (struct value *value, struct value *outer_value,
 			ada_name_prefix_len (type->field (i).name ()),
 			type->field (i).name ());
       annotate_field_name_end ();
-      fputs_filtered (" => ", stream);
+      gdb_puts (" => ", stream);
       annotate_field_value ();
 
       if (TYPE_FIELD_PACKED (type, i))
@@ -723,7 +723,7 @@ ada_value_print_ptr (struct value *val,
       && TYPE_TARGET_TYPE (value_type (val))->code () == TYPE_CODE_INT
       && TYPE_LENGTH (TYPE_TARGET_TYPE (value_type (val))) == 0)
     {
-      fputs_filtered ("null", stream);
+      gdb_puts ("null", stream);
       return;
     }
 
@@ -791,7 +791,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
 	  fprintf_filtered (stream, "(");
 	  type_print (type, "", stream, -1);
 	  fprintf_filtered (stream, ") ");
-	  fputs_filtered (paddress (gdbarch, addr), stream);
+	  gdb_puts (paddress (gdbarch, addr), stream);
 	}
       else
 	{
@@ -800,7 +800,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
 	    {
 	      LONGEST c;
 
-	      fputs_filtered (" ", stream);
+	      gdb_puts (" ", stream);
 	      c = unpack_long (type, valaddr);
 	      ada_printchar (c, type, stream);
 	    }
@@ -960,7 +960,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr,
   deref_val_int = unpack_pointer (type, valaddr + offset_aligned);
   if (deref_val_int == 0)
     {
-      fputs_filtered ("(null)", stream);
+      gdb_puts ("(null)", stream);
       return;
     }
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index f6bd76a354d..fc83ff8b9b7 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4015,15 +4015,15 @@ static void
 print_fpu_flags (struct ui_file *file, int flags)
 {
   if (flags & (1 << 0))
-    fputs_filtered ("IVO ", file);
+    gdb_puts ("IVO ", file);
   if (flags & (1 << 1))
-    fputs_filtered ("DVZ ", file);
+    gdb_puts ("DVZ ", file);
   if (flags & (1 << 2))
-    fputs_filtered ("OFL ", file);
+    gdb_puts ("OFL ", file);
   if (flags & (1 << 3))
-    fputs_filtered ("UFL ", file);
+    gdb_puts ("UFL ", file);
   if (flags & (1 << 4))
-    fputs_filtered ("INX ", file);
+    gdb_puts ("INX ", file);
   fputc_filtered ('\n', file);
 }
 
@@ -4042,10 +4042,10 @@ arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
   else
     fprintf_filtered (file, _("Software FPU type %d\n"), type);
   /* i18n: [floating point unit] mask */
-  fputs_filtered (_("mask: "), file);
+  gdb_puts (_("mask: "), file);
   print_fpu_flags (file, status >> 16);
   /* i18n: [floating point unit] flags */
-  fputs_filtered (_("flags: "), file);
+  gdb_puts (_("flags: "), file);
   print_fpu_flags (file, status);
 }
 
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index f85301db4fd..f829b32e015 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -398,7 +398,7 @@ ax_print (struct ui_file *f, struct agent_expr *x)
       fprintf_filtered (f, "%3d  %s", i, aop_map[op].name);
       if (aop_map[op].op_size > 0)
 	{
-	  fputs_filtered (" ", f);
+	  gdb_puts (" ", f);
 
 	  print_longest (f, 'd', 0,
 			 read_const (x, i + 1, aop_map[op].op_size));
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index ed7554fadea..fa1b73c718f 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -206,13 +206,13 @@ c_printstr (struct ui_file *stream, struct type *type,
     case C_STRING:
       break;
     case C_WIDE_STRING:
-      fputs_filtered ("L", stream);
+      gdb_puts ("L", stream);
       break;
     case C_STRING_16:
-      fputs_filtered ("u", stream);
+      gdb_puts ("u", stream);
       break;
     case C_STRING_32:
-      fputs_filtered ("U", stream);
+      gdb_puts ("U", stream);
       break;
     }
 
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a24ada66434..89da2688f0b 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -91,7 +91,7 @@ print_name_maybe_canonical (const char *name,
 				     find_typedef_for_canonicalize,
 				     (void *) flags);
 
-  fputs_filtered (s != nullptr ? s.get () : name, stream);
+  gdb_puts (s != nullptr ? s.get () : name, stream);
 }
 
 \f
@@ -120,9 +120,9 @@ c_print_type_1 (struct type *type,
   if (local_name != NULL)
     {
       c_type_print_modifier (type, stream, 0, 1, language);
-      fputs_filtered (local_name, stream);
+      gdb_puts (local_name, stream);
       if (varstring != NULL && *varstring != '\0')
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
     }
   else
     {
@@ -138,7 +138,7 @@ c_print_type_1 (struct type *type,
 		  || code == TYPE_CODE_MEMBERPTR
 		  || code == TYPE_CODE_METHODPTR
 		  || TYPE_IS_REFERENCE (type))))
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
       need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
       c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
 				   language, flags, podata);
@@ -251,7 +251,7 @@ cp_type_print_derivation_info (struct ui_file *stream,
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
     {
       stream->wrap_here (8);
-      fputs_filtered (i == 0 ? ": " : ", ", stream);
+      gdb_puts (i == 0 ? ": " : ", ", stream);
       fprintf_filtered (stream, "%s%s ",
 			BASETYPE_VIA_PUBLIC (type, i)
 			? "public" : (TYPE_FIELD_PROTECTED (type, i)
@@ -265,7 +265,7 @@ cp_type_print_derivation_info (struct ui_file *stream,
     }
   if (i > 0)
     {
-      fputs_filtered (" ", stream);
+      gdb_puts (" ", stream);
     }
 }
 
@@ -287,7 +287,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
 			   language_cplus, DMGL_ANSI);
   fprintf_symbol_filtered (stream, varstring,
 			   language_cplus, DMGL_ANSI);
-  fputs_filtered ("(", stream);
+  gdb_puts ("(", stream);
 
   /* Skip the class variable.  We keep this here to accommodate older
      compilers and debug formats which may not support artificial
@@ -894,7 +894,7 @@ c_type_print_template_args (const struct type_print_options *flags,
 	}
       else
 	{
-	  fputs_filtered (", ", stream);
+	  gdb_puts (", ", stream);
 	  stream->wrap_here (9);
 	  fprintf_filtered (stream, "%s = ", sym->linkage_name ());
 	}
@@ -903,7 +903,7 @@ c_type_print_template_args (const struct type_print_options *flags,
     }
 
   if (!first)
-    fputs_filtered (_("] "), stream);
+    gdb_puts (_("] "), stream);
 }
 
 /* Use 'print_spaces_filtered', but take into consideration the
@@ -1079,7 +1079,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 	 here.  */
       print_name_maybe_canonical (type->name (), flags, stream);
       if (show > 0)
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
     }
 
   if (show < 0)
@@ -1300,7 +1300,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 		    (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
 		     "", stream, -1, 0, language, &local_flags, podata);
 
-		  fputs_filtered (" ", stream);
+		  gdb_puts (" ", stream);
 		}
 	      if (TYPE_FN_FIELD_STUB (f, j))
 		{
@@ -1352,10 +1352,10 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 		      int length = p - demangled_no_class;
 		      std::string demangled_no_static (demangled_no_class,
 						       length);
-		      fputs_filtered (demangled_no_static.c_str (), stream);
+		      gdb_puts (demangled_no_static.c_str (), stream);
 		    }
 		  else
-		    fputs_filtered (demangled_no_class, stream);
+		    gdb_puts (demangled_no_class, stream);
 		}
 
 	      fprintf_filtered (stream, ";\n");
@@ -1556,7 +1556,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 	{
 	  print_name_maybe_canonical (type->name (), flags, stream);
 	  if (show > 0)
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 	}
 
       stream->wrap_here (4);
@@ -1620,7 +1620,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 	print_name_maybe_canonical (type->name (), flags, stream);
 	if (show > 0)
 	  {
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 	    fprintf_filtered (stream, "{\n");
 	    if (type->num_fields () == 0)
 	      {
@@ -1684,8 +1684,8 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
       break;
 
     case TYPE_CODE_NAMESPACE:
-      fputs_filtered ("namespace ", stream);
-      fputs_filtered (type->name (), stream);
+      gdb_puts ("namespace ", stream);
+      gdb_puts (type->name (), stream);
       break;
 
     default:
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 461763075e8..a11c228c897 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -158,7 +158,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 					 demangle);
   else if (options->addressprint)
     {
-      fputs_filtered (paddress (gdbarch, address), stream);
+      gdb_puts (paddress (gdbarch, address), stream);
       want_space = 1;
     }
 
@@ -169,7 +169,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
       && address != 0)
     {
       if (want_space)
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
       val_print_string (unresolved_elttype, NULL, address, -1, stream, options);
     }
   else if (cp_is_vtbl_member (type))
@@ -185,10 +185,10 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	  && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
 	{
 	  if (want_space)
-	    fputs_filtered (" ", stream);
-	  fputs_filtered (" <", stream);
-	  fputs_filtered (msymbol.minsym->print_name (), stream);
-	  fputs_filtered (">", stream);
+	    gdb_puts (" ", stream);
+	  gdb_puts (" <", stream);
+	  gdb_puts (msymbol.minsym->print_name (), stream);
+	  gdb_puts (">", stream);
 	  want_space = 1;
 	}
 
@@ -199,7 +199,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	  struct type *wtype;
 
 	  if (want_space)
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 
 	  if (msymbol.minsym != NULL)
 	    {
@@ -408,7 +408,7 @@ c_value_print_int (struct value *val, struct ui_file *stream,
       const gdb_byte *valaddr = value_contents_for_printing (val).data ();
       if (c_textual_element_type (type, options->format))
 	{
-	  fputs_filtered (" ", stream);
+	  gdb_puts (" ", stream);
 	  LA_PRINT_CHAR (unpack_long (type, valaddr), type, stream);
 	}
     }
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index f6a508393ef..0c87a820568 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -221,9 +221,9 @@ cli_ui_out::do_text (const char *string)
     return;
 
   if (test_flags (unfiltered_output))
-    fputs_unfiltered (string, m_streams.back ());
+    gdb_puts (string, m_streams.back ());
   else
-    fputs_filtered (string, m_streams.back ());
+    gdb_puts (string, m_streams.back ());
 }
 
 void
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index e583d9b8786..bf6b634c14f 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1331,7 +1331,7 @@ fput_alias_definition_styled (const cmd_list_element &c,
 			      struct ui_file *stream)
 {
   gdb_assert (c.is_alias ());
-  fputs_filtered ("  alias ", stream);
+  gdb_puts ("  alias ", stream);
   fput_command_name_styled (c, stream);
   fprintf_filtered (stream, " = ");
   fput_command_name_styled (*c.alias_target, stream);
@@ -1389,13 +1389,13 @@ fput_command_names_styled (const cmd_list_element &c,
       if (!print_alias (alias))
 	continue;
 
-      fputs_filtered (", ", stream);
+      gdb_puts (", ", stream);
       stream->wrap_here (3);
       fput_command_name_styled (alias, stream);
     }
 
   if (print_something)
-    fputs_filtered (postfix, stream);
+    gdb_puts (postfix, stream);
 }
 
 /* If VERBOSE, print the full help for command C and highlight the
@@ -1411,21 +1411,21 @@ print_doc_of_command (const cmd_list_element &c, const char *prefix,
      this documentation from the previous command help, in the likely
      case that apropos finds several commands.  */
   if (verbose)
-    fputs_filtered ("\n", stream);
+    gdb_puts ("\n", stream);
 
   fput_command_names_styled (c, true,
 			     verbose ? "" : " -- ", stream);
   if (verbose)
     {
-      fputs_filtered ("\n", stream);
+      gdb_puts ("\n", stream);
       fput_aliases_definition_styled (c, stream);
       fputs_highlighted (c.doc, highlight, stream);
-      fputs_filtered ("\n", stream);
+      gdb_puts ("\n", stream);
     }
   else
     {
       print_doc_line (stream, c.doc, false);
-      fputs_filtered ("\n", stream);
+      gdb_puts ("\n", stream);
       fput_aliases_definition_styled (c, stream);
     }
 }
@@ -1549,8 +1549,8 @@ help_cmd (const char *command, struct ui_file *stream)
      the false indicates to not output the (single) command name.  */
   fput_command_names_styled (*c, false, "\n", stream);
   fput_aliases_definition_styled (*c, stream);
-  fputs_filtered (c->doc, stream);
-  fputs_filtered ("\n", stream);
+  gdb_puts (c->doc, stream);
+  gdb_puts ("\n", stream);
 
   if (!c->is_prefix () && !c->is_command_class_help ())
     return;
@@ -1637,18 +1637,18 @@ Type \"help all\" for the list of all commands.");
   fprintf_filtered (stream, "\nType \"help%s\" followed by %scommand name ",
 		    cmdtype1, cmdtype2);
   stream->wrap_here (0);
-  fputs_filtered ("for ", stream);
+  gdb_puts ("for ", stream);
   stream->wrap_here (0);
-  fputs_filtered ("full ", stream);
+  gdb_puts ("full ", stream);
   stream->wrap_here (0);
-  fputs_filtered ("documentation.\n", stream);
-  fputs_filtered ("Type \"apropos word\" to search "
-		  "for commands related to \"word\".\n", stream);
-  fputs_filtered ("Type \"apropos -v word\" for full documentation", stream);
+  gdb_puts ("documentation.\n", stream);
+  gdb_puts ("Type \"apropos word\" to search "
+	    "for commands related to \"word\".\n", stream);
+  gdb_puts ("Type \"apropos -v word\" for full documentation", stream);
   stream->wrap_here (0);
-  fputs_filtered (" of commands related to \"word\".\n", stream);
-  fputs_filtered ("Command name abbreviations are allowed if unambiguous.\n",
-		  stream);
+  gdb_puts (" of commands related to \"word\".\n", stream);
+  gdb_puts ("Command name abbreviations are allowed if unambiguous.\n",
+	    stream);
 }
 
 static void
@@ -1732,7 +1732,7 @@ print_doc_line (struct ui_file *stream, const char *str,
     }
   else
     line_buffer[p - str] = '\0';
-  fputs_filtered (line_buffer, stream);
+  gdb_puts (line_buffer, stream);
 }
 
 /* Print one-line help for command C.
@@ -1744,7 +1744,7 @@ print_help_for_command (const cmd_list_element &c,
 {
   fput_command_names_styled (c, true, " -- ", stream);
   print_doc_line (stream, c.doc, false);
-  fputs_filtered ("\n", stream);
+  gdb_puts ("\n", stream);
   if (!c.default_args.empty ())
     fput_alias_definition_styled (c, stream);
   fput_aliases_definition_styled (c, stream);
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 5324f647d80..d3cc560a00c 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -433,7 +433,7 @@ restore_one_section (bfd *ibfd, asection *isec,
 			       (unsigned long) sec_start + sec_offset
 				+ load_offset + sec_load_count));
   else
-    puts_filtered ("\n");
+    gdb_puts ("\n");
 
   /* Write the data.  */
   ret = target_write_memory (sec_start + sec_offset + load_offset,
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 67613aa0bc0..fe4682d8513 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -503,7 +503,7 @@ print_command_trace (const char *fmt, ...)
   va_start (args, fmt);
   gdb_vprintf (fmt, args);
   va_end (args);
-  puts_filtered ("\n");
+  gdb_puts ("\n");
 }
 
 /* Helper for execute_control_command.  */
@@ -1655,7 +1655,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
       if (cmdlines)
 	{
 	  print_command_lines (current_uiout, cmdlines, 1);
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	}
     }
 
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 2fd00e9cc3e..652184475e2 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -182,7 +182,7 @@ do_show (const char *what, struct ui_file *file,
 	 const char *value)
 {
   cli_style_option *cso = (cli_style_option *) cmd->context ();
-  fputs_filtered (_("The "), file);
+  gdb_puts (_("The "), file);
   fprintf_styled (file, cso->style (), _("\"%s\" style"), cso->name ());
   fprintf_filtered (file, _(" %s is: %s\n"), what, value);
 }
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index dd0dc914d97..76a95aa8147 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -167,14 +167,14 @@ print_one_macro (const char *name, const struct macro_definition *macro,
     {
       int i;
 
-      fputs_filtered ("(", file);
+      gdb_puts ("(", file);
       for (i = 0; i < macro->argc; i++)
 	{
-	  fputs_filtered (macro->argv[i], file);
+	  gdb_puts (macro->argv[i], file);
 	  if (i + 1 < macro->argc)
-	    fputs_filtered (", ", file);
+	    gdb_puts (", ", file);
 	}
-      fputs_filtered (")", file);
+      gdb_puts (")", file);
     }
 
   fprintf_filtered (file, " %s\n#endif\n", macro->replacement);
@@ -218,8 +218,8 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
   int i;
   int seen = 0;
 
-  fputs_unfiltered ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n",
-		    stream);
+  gdb_puts ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n",
+	    stream);
 
   if (!registers_used.empty ())
     for (i = 0; i < gdbarch_num_regs (gdbarch); ++i)
@@ -241,7 +241,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
 	       register types (typically flags or vectors), emit a
 	       maximally-aligned array of the correct size.  */
 
-	    fputs_unfiltered ("  ", stream);
+	    gdb_puts ("  ", stream);
 	    switch (regtype->code ())
 	      {
 	      case TYPE_CODE_PTR:
@@ -257,7 +257,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
 		  if (mode != NULL)
 		    {
 		      if (regtype->is_unsigned ())
-			fputs_unfiltered ("unsigned ", stream);
+			gdb_puts ("unsigned ", stream);
 		      fprintf_unfiltered (stream,
 					  "int %s"
 					  " __attribute__ ((__mode__(__%s__)))",
@@ -277,15 +277,15 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
 				    regname.c_str (),
 				    pulongest (TYPE_LENGTH (regtype)));
 	      }
-	    fputs_unfiltered (";\n", stream);
+	    gdb_puts (";\n", stream);
 	  }
       }
 
   if (!seen)
-    fputs_unfiltered ("  char " COMPILE_I_SIMPLE_REGISTER_DUMMY ";\n",
-		      stream);
+    gdb_puts ("  char " COMPILE_I_SIMPLE_REGISTER_DUMMY ";\n",
+	      stream);
 
-  fputs_unfiltered ("};\n\n", stream);
+  gdb_puts ("};\n\n", stream);
 }
 
 /* C-language policy to emit a push user expression pragma into BUF.  */
@@ -294,7 +294,7 @@ struct c_push_user_expression
 {
   void push_user_expression (struct ui_file *buf)
   {
-    fputs_unfiltered ("#pragma GCC user_expression\n", buf);
+    gdb_puts ("#pragma GCC user_expression\n", buf);
   }
 };
 
@@ -320,32 +320,32 @@ struct c_add_code_header
     switch (type)
       {
       case COMPILE_I_SIMPLE_SCOPE:
-	fputs_unfiltered ("void "
-			  GCC_FE_WRAPPER_FUNCTION
-			  " (struct "
-			  COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
-			  " *"
-			  COMPILE_I_SIMPLE_REGISTER_ARG_NAME
-			  ") {\n",
-			  buf);
+	gdb_puts ("void "
+		  GCC_FE_WRAPPER_FUNCTION
+		  " (struct "
+		  COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
+		  " *"
+		  COMPILE_I_SIMPLE_REGISTER_ARG_NAME
+		  ") {\n",
+		  buf);
 	break;
 
       case COMPILE_I_PRINT_ADDRESS_SCOPE:
       case COMPILE_I_PRINT_VALUE_SCOPE:
 	/* <string.h> is needed for a memcpy call below.  */
-	fputs_unfiltered ("#include <string.h>\n"
-			  "void "
-			  GCC_FE_WRAPPER_FUNCTION
-			  " (struct "
-			  COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
-			  " *"
-			  COMPILE_I_SIMPLE_REGISTER_ARG_NAME
-			  ", "
-			  COMPILE_I_PRINT_OUT_ARG_TYPE
-			  " "
-			  COMPILE_I_PRINT_OUT_ARG
-			  ") {\n",
-			  buf);
+	gdb_puts ("#include <string.h>\n"
+		  "void "
+		  GCC_FE_WRAPPER_FUNCTION
+		  " (struct "
+		  COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
+		  " *"
+		  COMPILE_I_SIMPLE_REGISTER_ARG_NAME
+		  ", "
+		  COMPILE_I_PRINT_OUT_ARG_TYPE
+		  " "
+		  COMPILE_I_PRINT_OUT_ARG
+		  ") {\n",
+		  buf);
 	break;
 
       case COMPILE_I_RAW_SCOPE:
@@ -369,7 +369,7 @@ struct c_add_code_footer
       case COMPILE_I_SIMPLE_SCOPE:
       case COMPILE_I_PRINT_ADDRESS_SCOPE:
       case COMPILE_I_PRINT_VALUE_SCOPE:
-	fputs_unfiltered ("}\n", buf);
+	gdb_puts ("}\n", buf);
 	break;
 
       case COMPILE_I_RAW_SCOPE:
@@ -405,10 +405,10 @@ struct c_add_input
 	break;
 
       default:
-	fputs_unfiltered (input, buf);
+	gdb_puts (input, buf);
 	break;
       }
-    fputs_unfiltered ("\n", buf);
+    gdb_puts ("\n", buf);
   }
 };
 
@@ -419,7 +419,7 @@ struct cplus_push_user_expression
 {
   void push_user_expression (struct ui_file *buf)
   {
-    fputs_unfiltered ("#pragma GCC push_user_expression\n", buf);
+    gdb_puts ("#pragma GCC push_user_expression\n", buf);
   }
 };
 
@@ -429,7 +429,7 @@ struct cplus_pop_user_expression
 {
   void pop_user_expression (struct ui_file *buf)
   {
-    fputs_unfiltered ("#pragma GCC pop_user_expression\n", buf);
+    gdb_puts ("#pragma GCC pop_user_expression\n", buf);
   }
 };
 
@@ -444,33 +444,33 @@ struct cplus_add_code_header
   switch (type)
     {
     case COMPILE_I_SIMPLE_SCOPE:
-      fputs_unfiltered ("void "
-			GCC_FE_WRAPPER_FUNCTION
-			" (struct "
-			COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
-			" *"
-			COMPILE_I_SIMPLE_REGISTER_ARG_NAME
-			") {\n",
-			buf);
+      gdb_puts ("void "
+		GCC_FE_WRAPPER_FUNCTION
+		" (struct "
+		COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
+		" *"
+		COMPILE_I_SIMPLE_REGISTER_ARG_NAME
+		") {\n",
+		buf);
       break;
 
     case COMPILE_I_PRINT_ADDRESS_SCOPE:
     case COMPILE_I_PRINT_VALUE_SCOPE:
-      fputs_unfiltered (
-			"#include <cstring>\n"
-			"#include <bits/move.h>\n"
-			"void "
-			GCC_FE_WRAPPER_FUNCTION
-			" (struct "
-			COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
-			" *"
-			COMPILE_I_SIMPLE_REGISTER_ARG_NAME
-			", "
-			COMPILE_I_PRINT_OUT_ARG_TYPE
-			" "
-			COMPILE_I_PRINT_OUT_ARG
-			") {\n",
-			buf);
+      gdb_puts (
+		"#include <cstring>\n"
+		"#include <bits/move.h>\n"
+		"void "
+		GCC_FE_WRAPPER_FUNCTION
+		" (struct "
+		COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
+		" *"
+		COMPILE_I_SIMPLE_REGISTER_ARG_NAME
+		", "
+		COMPILE_I_PRINT_OUT_ARG_TYPE
+		" "
+		COMPILE_I_PRINT_OUT_ARG
+		") {\n",
+		buf);
       break;
 
     case COMPILE_I_RAW_SCOPE:
@@ -512,10 +512,10 @@ struct cplus_add_input
 	break;
 
       default:
-	fputs_unfiltered (input, buf);
+	gdb_puts (input, buf);
 	break;
       }
-    fputs_unfiltered ("\n", buf);
+    gdb_puts ("\n", buf);
   }
 };
 
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index ce8b9452685..a76abea977a 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -1246,9 +1246,9 @@ static void
 compile_cplus_debug_output_1 (const char *arg)
 {
   if (arg == nullptr)
-    fputs_unfiltered ("NULL", gdb_stdlog);
+    gdb_puts ("NULL", gdb_stdlog);
   else
-    fputs_unfiltered (arg, gdb_stdlog);
+    gdb_puts (arg, gdb_stdlog);
 }
 
 static void
@@ -1275,7 +1275,7 @@ compile_cplus_debug_output (T arg, Targs... Args)
 #define OUTPUT_DEBUG_RESULT(R)			  \
   if (debug_compile_cplus_types)		  \
     {						  \
-      fputs_unfiltered (": ", gdb_stdlog);	  \
+      gdb_puts (": ", gdb_stdlog);		  \
       compile_cplus_debug_output (R);		  \
       fputc_unfiltered ('\n', gdb_stdlog);	  \
     }						  \
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 6794c93d60e..b27b86e3cc1 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -647,7 +647,7 @@ get_args (const compile_instance *compiler, struct gdbarch *gdbarch)
 static void
 print_callback (void *ignore, const char *message)
 {
-  fputs_filtered (message, gdb_stderr);
+  gdb_puts (message, gdb_stderr);
 }
 
 /* Process the compilation request.  On success it returns the object
diff --git a/gdb/complaints.c b/gdb/complaints.c
index b582bf38f11..b1757d4bdd0 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -50,9 +50,9 @@ complaint_internal (const char *fmt, ...)
     (*deprecated_warning_hook) (fmt, args);
   else
     {
-      fputs_filtered (_("During symbol reading: "), gdb_stderr);
+      gdb_puts (_("During symbol reading: "), gdb_stderr);
       gdb_vprintf (gdb_stderr, fmt, args);
-      fputs_filtered ("\n", gdb_stderr);
+      gdb_puts ("\n", gdb_stderr);
     }
 
   va_end (args);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 8e2b631c839..07e0492044f 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -198,9 +198,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 
 	  if (fields_seen)
 	    {
-	      fputs_filtered (",", stream);
+	      gdb_puts (",", stream);
 	      if (!options->prettyformat)
-		fputs_filtered (" ", stream);
+		gdb_puts (" ", stream);
 	    }
 	  else if (n_baseclasses > 0)
 	    {
@@ -208,9 +208,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
-		  fputs_filtered ("members of ", stream);
-		  fputs_filtered (type->name (), stream);
-		  fputs_filtered (":", stream);
+		  gdb_puts ("members of ", stream);
+		  gdb_puts (type->name (), stream);
+		  gdb_puts (":", stream);
 		}
 	    }
 	  fields_seen = 1;
@@ -229,7 +229,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 
 	  if (field_is_static (&type->field (i)))
 	    {
-	      fputs_filtered ("static ", stream);
+	      gdb_puts ("static ", stream);
 	      fprintf_symbol_filtered (stream,
 				       type->field (i).name (),
 				       current_language->la_language,
@@ -247,7 +247,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  /* Do not print leading '=' in case of anonymous
 	     unions.  */
 	  if (strcmp (type->field (i).name (), ""))
-	    fputs_filtered (" = ", stream);
+	    gdb_puts (" = ", stream);
 	  else
 	    {
 	      /* If this is an anonymous field then we want to consider it
@@ -481,11 +481,11 @@ cp_print_value (struct value *val, struct ui_file *stream,
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
 	}
-      fputs_filtered ("<", stream);
+      gdb_puts ("<", stream);
       /* Not sure what the best notation is in the case where there is
 	 no baseclass name.  */
-      fputs_filtered (basename ? basename : "", stream);
-      fputs_filtered ("> = ", stream);
+      gdb_puts (basename ? basename : "", stream);
+      gdb_puts ("> = ", stream);
 
       if (skip < 0)
 	val_print_unavailable (stream);
@@ -516,7 +516,7 @@ cp_print_value (struct value *val, struct ui_file *stream,
 				       0);
 	    }
 	}
-      fputs_filtered (", ", stream);
+      gdb_puts (", ", stream);
 
     flush_it:
       ;
@@ -701,10 +701,10 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type,
     {
       const char *name;
 
-      fputs_filtered (prefix, stream);
+      gdb_puts (prefix, stream);
       name = self_type->name ();
       if (name)
-	fputs_filtered (name, stream);
+	gdb_puts (name, stream);
       else
 	c_type_print_base (self_type, stream, 0, 0, &type_print_raw_options);
       fprintf_filtered (stream, "::");
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 9564f1ca8ec..832dc6309ec 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -1061,9 +1061,9 @@ show_disassembler_options_sfunc (struct ui_file *file, int from_tty,
 
   if (valid_options_and_args == NULL)
     {
-      fputs_filtered (_("There are no disassembler options available "
-			"for this architecture.\n"),
-		      file);
+      gdb_puts (_("There are no disassembler options available "
+		  "for this architecture.\n"),
+		file);
       return;
     }
 
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 69b480e6e86..a9aa0d5b7a0 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -902,7 +902,7 @@ chain_candidate (struct gdbarch *gdbarch,
       fprintf_unfiltered (gdb_stdlog, "tailcall: reduced:");
       for (idx = 0; idx < (*resultp)->callers; idx++)
 	tailcall_dump (gdbarch, (*resultp)->call_site[idx]);
-      fputs_unfiltered (" |", gdb_stdlog);
+      gdb_puts (" |", gdb_stdlog);
       for (idx = 0; idx < (*resultp)->callees; idx++)
 	tailcall_dump (gdbarch,
 		       (*resultp)->call_site[(*resultp)->length
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f7cb95b40cb..31003ccae0f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -23014,7 +23014,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
 	case DW_FORM_addrx:
 	case DW_FORM_GNU_addr_index:
 	  fprintf_unfiltered (f, "address: ");
-	  fputs_filtered (hex_string (die->attrs[i].as_address ()), f);
+	  gdb_puts (hex_string (die->attrs[i].as_address ()), f);
 	  break;
 	case DW_FORM_block2:
 	case DW_FORM_block4:
@@ -23032,11 +23032,11 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
 	  break;
 	case DW_FORM_ref_addr:
 	  fprintf_unfiltered (f, "ref address: ");
-	  fputs_filtered (hex_string (die->attrs[i].as_unsigned ()), f);
+	  gdb_puts (hex_string (die->attrs[i].as_unsigned ()), f);
 	  break;
 	case DW_FORM_GNU_ref_alt:
 	  fprintf_unfiltered (f, "alt ref address: ");
-	  fputs_filtered (hex_string (die->attrs[i].as_unsigned ()), f);
+	  gdb_puts (hex_string (die->attrs[i].as_unsigned ()), f);
 	  break;
 	case DW_FORM_ref1:
 	case DW_FORM_ref2:
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 5db2a2acdd2..b503816956d 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1215,8 +1215,8 @@ async_disconnect (gdb_client_data arg)
 
   catch (const gdb_exception &exception)
     {
-      fputs_filtered ("Could not kill the program being debugged",
-		      gdb_stderr);
+      gdb_puts ("Could not kill the program being debugged",
+		gdb_stderr);
       exception_print (gdb_stderr, exception);
     }
 
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index b23ab0e4f33..73c4818a285 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -81,7 +81,7 @@ print_exception (struct ui_file *file, const struct gdb_exception &e)
     {
       end = strchr (start, '\n');
       if (end == NULL)
-	fputs_filtered (start, file);
+	gdb_puts (start, file);
       else
 	{
 	  end++;
diff --git a/gdb/exec.c b/gdb/exec.c
index 43ecb730a65..caf790a0dfb 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -980,7 +980,7 @@ exec_target::files_info ()
     print_section_info (&current_program_space->target_sections (),
 			current_program_space->exec_bfd ());
   else
-    puts_filtered (_("\t<no file loaded>\n"));
+    gdb_puts (_("\t<no file loaded>\n"));
 }
 
 static void
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 381a10d85be..4dab3a27a94 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -138,9 +138,9 @@ dump_for_expression (struct ui_file *stream, int depth,
 {
   fprintf_filtered (stream, _("%*sType flags: "), depth, "");
   if (flags & TYPE_INSTANCE_FLAG_CONST)
-    fputs_filtered ("const ", stream);
+    gdb_puts ("const ", stream);
   if (flags & TYPE_INSTANCE_FLAG_VOLATILE)
-    fputs_filtered ("volatile", stream);
+    gdb_puts ("volatile", stream);
   fprintf_filtered (stream, "\n");
 }
 
@@ -152,24 +152,24 @@ dump_for_expression (struct ui_file *stream, int depth,
   switch (flags & ~C_CHAR)
     {
     case C_WIDE_STRING:
-      fputs_filtered (_("wide "), stream);
+      gdb_puts (_("wide "), stream);
       break;
     case C_STRING_16:
-      fputs_filtered (_("u16 "), stream);
+      gdb_puts (_("u16 "), stream);
       break;
     case C_STRING_32:
-      fputs_filtered (_("u32 "), stream);
+      gdb_puts (_("u32 "), stream);
       break;
     default:
-      fputs_filtered (_("ordinary "), stream);
+      gdb_puts (_("ordinary "), stream);
       break;
     }
 
   if ((flags & C_CHAR) != 0)
-    fputs_filtered (_("char"), stream);
+    gdb_puts (_("char"), stream);
   else
-    fputs_filtered (_("string"), stream);
-  fputs_filtered ("\n", stream);
+    gdb_puts (_("string"), stream);
+  gdb_puts ("\n", stream);
 }
 
 void
@@ -178,13 +178,13 @@ dump_for_expression (struct ui_file *stream, int depth,
 {
   fprintf_filtered (stream, _("%*sRange:"), depth, "");
   if ((flags & RANGE_LOW_BOUND_DEFAULT) != 0)
-    fputs_filtered (_("low-default "), stream);
+    gdb_puts (_("low-default "), stream);
   if ((flags & RANGE_HIGH_BOUND_DEFAULT) != 0)
-    fputs_filtered (_("high-default "), stream);
+    gdb_puts (_("high-default "), stream);
   if ((flags & RANGE_HIGH_BOUND_EXCLUSIVE) != 0)
-    fputs_filtered (_("high-exclusive "), stream);
+    gdb_puts (_("high-exclusive "), stream);
   if ((flags & RANGE_HAS_STRIDE) != 0)
-    fputs_filtered (_("has-stride"), stream);
+    gdb_puts (_("has-stride"), stream);
   fprintf_filtered (stream, "\n");
 }
 
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 11debd5569f..2a1f6c7e737 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -161,9 +161,9 @@ class f_language : public language_defn
   void printchar (int ch, struct type *chtype,
 		  struct ui_file *stream) const override
   {
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
     emitchar (ch, chtype, stream, '\'');
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
   }
 
   /* See language.h.  */
@@ -176,7 +176,7 @@ class f_language : public language_defn
     const char *type_encoding = get_encoding (elttype);
 
     if (TYPE_LENGTH (elttype) == 4)
-      fputs_filtered ("4_", stream);
+      gdb_puts ("4_", stream);
 
     if (!encoding || !*encoding)
       encoding = type_encoding;
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 6fd3d519c86..a1c46a7abde 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -69,14 +69,14 @@ f_language::print_type (struct type *type, const char *varstring,
 			  == TYPE_CODE_METHOD)
 		      || (TYPE_TARGET_TYPE (type)->code ()
 			  == TYPE_CODE_ARRAY))))))
-    fputs_filtered (" ", stream);
+    gdb_puts (" ", stream);
   f_type_print_varspec_prefix (type, stream, show, 0);
 
   if (varstring != NULL)
     {
       int demangled_args;
 
-      fputs_filtered (varstring, stream);
+      gdb_puts (varstring, stream);
 
       /* For demangled function names, we have the arglist as part of the name,
 	 so don't print an additional pair of ()'s.  */
@@ -208,7 +208,7 @@ f_language::f_type_print_varspec_suffix (struct type *type,
 	    {
 	      LONGEST upper_bound = f77_get_upperbound (type);
 
-	      fputs_filtered (plongest (upper_bound), stream);
+	      gdb_puts (plongest (upper_bound), stream);
 	    }
 	}
 
@@ -249,7 +249,7 @@ f_language::f_type_print_varspec_suffix (struct type *type,
 	    {
 	      if (i > 0)
 		{
-		  fputs_filtered (", ", stream);
+		  gdb_puts (", ", stream);
 		  stream->wrap_here (4);
 		}
 	      print_type (type->field (i).type (), "", stream, -1, 0, 0);
@@ -395,25 +395,25 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
 	fprintf_filtered (stream, "%*sType, C_Union :: ", level, "");
       else
 	fprintf_filtered (stream, "%*sType ", level, "");
-      fputs_filtered (type->name (), stream);
+      gdb_puts (type->name (), stream);
       /* According to the definition,
 	 we only print structure elements in case show > 0.  */
       if (show > 0)
 	{
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	  for (index = 0; index < type->num_fields (); index++)
 	    {
 	      f_type_print_base (type->field (index).type (), stream,
 				 show - 1, level + 4);
-	      fputs_filtered (" :: ", stream);
+	      gdb_puts (" :: ", stream);
 	      fputs_styled (type->field (index).name (),
 			    variable_name_style.style (), stream);
 	      f_type_print_varspec_suffix (type->field (index).type (),
 					   stream, show - 1, 0, 0, 0, false);
-	      fputs_filtered ("\n", stream);
+	      gdb_puts ("\n", stream);
 	    }
 	  fprintf_filtered (stream, "%*sEnd Type ", level, "");
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	}
       break;
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 3d13eb11fb0..fa036355c1c 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -144,7 +144,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
   {
     bool cont = should_continue && (m_elts < m_options->print_max);
     if (!cont && should_continue)
-      fputs_filtered ("...", m_stream);
+      gdb_puts ("...", m_stream);
     return cont;
   }
 
@@ -162,7 +162,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 	m_stats[dim_indx].nelts = nelts;
       }
 
-    fputs_filtered ("(", m_stream);
+    gdb_puts ("(", m_stream);
   }
 
   /* Called when we finish processing a batch of items within a dimension
@@ -171,9 +171,9 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
      separators between elements, and dimensions of the array.  */
   void finish_dimension (bool inner_p, bool last_p)
   {
-    fputs_filtered (")", m_stream);
+    gdb_puts (")", m_stream);
     if (!last_p)
-      fputs_filtered (" ", m_stream);
+      gdb_puts (" ", m_stream);
 
     m_dimension--;
   }
@@ -218,7 +218,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 			      nullptr);
 	    annotate_elt_rep_end ();
 	    if (!repeated)
-	      fputs_filtered (" ", m_stream);
+	      gdb_puts (" ", m_stream);
 	    m_elts += nrepeats * m_stats[dim_indx + 1].nelts;
 	  }
 	else
@@ -245,7 +245,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 		nrepeats++;
 	      }
 	    else if (last_p)
-	      fputs_filtered ("...", m_stream);
+	      gdb_puts ("...", m_stream);
 	  }
       }
 
@@ -301,7 +301,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 		    common_val_print (e_val, m_stream, m_recurse, m_options,
 				      current_language);
 		    if (i > 1)
-		      fputs_filtered (", ", m_stream);
+		      gdb_puts (", ", m_stream);
 		  }
 	      }
 	    printed = true;
@@ -314,14 +314,14 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 	      = value_from_component (m_val, elt_type, elt_off);
 
 	    if (printed)
-	      fputs_filtered (", ", m_stream);
+	      gdb_puts (", ", m_stream);
 	    maybe_print_array_index (m_stats[dim_indx].index_type, index,
 				     m_stream, m_options);
 	    common_val_print (e_val, m_stream, m_recurse, m_options,
 			      current_language);
 	  }
 	if (!last_p)
-	  fputs_filtered (", ", m_stream);
+	  gdb_puts (", ", m_stream);
       }
 
     m_elt_type_prev = elt_type;
@@ -490,7 +490,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 						 stream, demangle);
 	  else if (options->addressprint && options->format != 's')
 	    {
-	      fputs_filtered (paddress (gdbarch, addr), stream);
+	      gdb_puts (paddress (gdbarch, addr), stream);
 	      want_space = 1;
 	    }
 
@@ -502,7 +502,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 	      && addr != 0)
 	    {
 	      if (want_space)
-		fputs_filtered (" ", stream);
+		gdb_puts (" ", stream);
 	      val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
 				stream, options);
 	    }
@@ -527,14 +527,14 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 	      const char *field_name;
 
 	      if (printed_field > 0)
-		fputs_filtered (", ", stream);
+		gdb_puts (", ", stream);
 
 	      field_name = type->field (index).name ();
 	      if (field_name != NULL)
 		{
 		  fputs_styled (field_name, variable_name_style.style (),
 				stream);
-		  fputs_filtered (" = ", stream);
+		  gdb_puts (" = ", stream);
 		}
 
 	      common_val_print (field, stream, recurse + 1,
@@ -561,9 +561,9 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 	     represented.  Different compilers use different non zero
 	     values to represent logical true.  */
 	  if (longval == 0)
-	    fputs_filtered (f_decorations.false_name, stream);
+	    gdb_puts (f_decorations.false_name, stream);
 	  else
-	    fputs_filtered (f_decorations.true_name, stream);
+	    gdb_puts (f_decorations.true_name, stream);
 	}
       break;
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 8af96c79e6c..7293a4a00a5 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4852,7 +4852,7 @@ print_bit_vector (B_TYPE *bits, int nbits)
     {
       if ((bitno % 8) == 0)
 	{
-	  puts_filtered (" ");
+	  gdb_puts (" ");
 	}
       if (B_TST (bits, bitno))
 	printf_filtered (("1"));
@@ -4983,7 +4983,7 @@ print_cplus_stuff (struct type *type, int spaces)
 
       print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
 			TYPE_N_BASECLASSES (type));
-      puts_filtered ("\n");
+      gdb_puts ("\n");
     }
   if (type->num_fields () > 0)
     {
@@ -4995,7 +4995,7 @@ print_cplus_stuff (struct type *type, int spaces)
 	     host_address_to_string (TYPE_FIELD_PRIVATE_BITS (type)));
 	  print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
 			    type->num_fields ());
-	  puts_filtered ("\n");
+	  gdb_puts ("\n");
 	}
       if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
 	{
@@ -5005,7 +5005,7 @@ print_cplus_stuff (struct type *type, int spaces)
 	     host_address_to_string (TYPE_FIELD_PROTECTED_BITS (type)));
 	  print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
 			    type->num_fields ());
-	  puts_filtered ("\n");
+	  gdb_puts ("\n");
 	}
     }
   if (TYPE_NFN_FIELDS (type) > 0)
@@ -5187,7 +5187,7 @@ recursive_dump_type (struct type *type, int spaces)
       printf_filtered ("(UNKNOWN TYPE CODE)");
       break;
     }
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   printf_filtered ("%*slength %s\n", spaces, "",
 		   pulongest (TYPE_LENGTH (type)));
   if (type->is_objfile_owned ())
@@ -5212,87 +5212,87 @@ recursive_dump_type (struct type *type, int spaces)
 		   (unsigned) type->instance_flags ());
   if (TYPE_CONST (type))
     {
-      puts_filtered (" TYPE_CONST");
+      gdb_puts (" TYPE_CONST");
     }
   if (TYPE_VOLATILE (type))
     {
-      puts_filtered (" TYPE_VOLATILE");
+      gdb_puts (" TYPE_VOLATILE");
     }
   if (TYPE_CODE_SPACE (type))
     {
-      puts_filtered (" TYPE_CODE_SPACE");
+      gdb_puts (" TYPE_CODE_SPACE");
     }
   if (TYPE_DATA_SPACE (type))
     {
-      puts_filtered (" TYPE_DATA_SPACE");
+      gdb_puts (" TYPE_DATA_SPACE");
     }
   if (TYPE_ADDRESS_CLASS_1 (type))
     {
-      puts_filtered (" TYPE_ADDRESS_CLASS_1");
+      gdb_puts (" TYPE_ADDRESS_CLASS_1");
     }
   if (TYPE_ADDRESS_CLASS_2 (type))
     {
-      puts_filtered (" TYPE_ADDRESS_CLASS_2");
+      gdb_puts (" TYPE_ADDRESS_CLASS_2");
     }
   if (TYPE_RESTRICT (type))
     {
-      puts_filtered (" TYPE_RESTRICT");
+      gdb_puts (" TYPE_RESTRICT");
     }
   if (TYPE_ATOMIC (type))
     {
-      puts_filtered (" TYPE_ATOMIC");
+      gdb_puts (" TYPE_ATOMIC");
     }
-  puts_filtered ("\n");
+  gdb_puts ("\n");
 
   printf_filtered ("%*sflags", spaces, "");
   if (type->is_unsigned ())
     {
-      puts_filtered (" TYPE_UNSIGNED");
+      gdb_puts (" TYPE_UNSIGNED");
     }
   if (type->has_no_signedness ())
     {
-      puts_filtered (" TYPE_NOSIGN");
+      gdb_puts (" TYPE_NOSIGN");
     }
   if (type->endianity_is_not_default ())
     {
-      puts_filtered (" TYPE_ENDIANITY_NOT_DEFAULT");
+      gdb_puts (" TYPE_ENDIANITY_NOT_DEFAULT");
     }
   if (type->is_stub ())
     {
-      puts_filtered (" TYPE_STUB");
+      gdb_puts (" TYPE_STUB");
     }
   if (type->target_is_stub ())
     {
-      puts_filtered (" TYPE_TARGET_STUB");
+      gdb_puts (" TYPE_TARGET_STUB");
     }
   if (type->is_prototyped ())
     {
-      puts_filtered (" TYPE_PROTOTYPED");
+      gdb_puts (" TYPE_PROTOTYPED");
     }
   if (type->has_varargs ())
     {
-      puts_filtered (" TYPE_VARARGS");
+      gdb_puts (" TYPE_VARARGS");
     }
   /* This is used for things like AltiVec registers on ppc.  Gcc emits
      an attribute for the array type, which tells whether or not we
      have a vector, instead of a regular array.  */
   if (type->is_vector ())
     {
-      puts_filtered (" TYPE_VECTOR");
+      gdb_puts (" TYPE_VECTOR");
     }
   if (type->is_fixed_instance ())
     {
-      puts_filtered (" TYPE_FIXED_INSTANCE");
+      gdb_puts (" TYPE_FIXED_INSTANCE");
     }
   if (type->stub_is_supported ())
     {
-      puts_filtered (" TYPE_STUB_SUPPORTED");
+      gdb_puts (" TYPE_STUB_SUPPORTED");
     }
   if (TYPE_NOTTEXT (type))
     {
-      puts_filtered (" TYPE_NOTTEXT");
+      gdb_puts (" TYPE_NOTTEXT");
     }
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   printf_filtered ("%*snfields %d ", spaces, "", type->num_fields ());
   if (TYPE_ASSOCIATED_PROP (type) != nullptr
       || TYPE_ALLOCATED_PROP (type) != nullptr)
@@ -5360,10 +5360,10 @@ recursive_dump_type (struct type *type, int spaces)
 	printf_filtered ("%*sfloatformat ", spaces, "");
 	if (TYPE_FLOATFORMAT (type) == NULL
 	    || TYPE_FLOATFORMAT (type)->name == NULL)
-	  puts_filtered ("(null)");
+	  gdb_puts ("(null)");
 	else
-	  puts_filtered (TYPE_FLOATFORMAT (type)->name);
-	puts_filtered ("\n");
+	  gdb_puts (TYPE_FLOATFORMAT (type)->name);
+	gdb_puts ("\n");
 	break;
 
       case TYPE_SPECIFIC_FUNC:
@@ -5380,7 +5380,7 @@ recursive_dump_type (struct type *type, int spaces)
       case TYPE_SPECIFIC_FIXED_POINT:
 	printf_filtered ("%*sfixed_point_info ", spaces, "");
 	print_fixed_point_type_info (type, spaces);
-	puts_filtered ("\n");
+	gdb_puts ("\n");
 	break;
 
     case TYPE_SPECIFIC_INT:
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 270a8b4b46f..b30c7f5cb5f 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -649,18 +649,18 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
 
 	  fprintf_filtered (stream, "&virtual ");
 	  if (demangled_name == NULL)
-	    fputs_filtered (physname, stream);
+	    gdb_puts (physname, stream);
 	  else
-	    fputs_filtered (demangled_name.get (), stream);
+	    gdb_puts (demangled_name.get (), stream);
 	  return;
 	}
     }
   else if (ptr_value != 0)
     {
       /* Found a non-virtual function: print out the type.  */
-      fputs_filtered ("(", stream);
+      gdb_puts ("(", stream);
       c_print_type (type, "", stream, -1, 0, &type_print_raw_options);
-      fputs_filtered (") ", stream);
+      gdb_puts (") ", stream);
     }
 
   /* We didn't find it; print the raw data.  */
diff --git a/gdb/go-typeprint.c b/gdb/go-typeprint.c
index 0a463871546..f8f155fbb64 100644
--- a/gdb/go-typeprint.c
+++ b/gdb/go-typeprint.c
@@ -54,7 +54,7 @@ go_language::print_type (struct type *type, const char *varstring,
   if (type->code () == TYPE_CODE_ARRAY
       && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR)
     {
-      fputs_filtered ("string", stream);
+      gdb_puts ("string", stream);
       return;
     }
 
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 32bb6790cba..ade99c9620a 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -66,8 +66,8 @@ print_go_string (struct type *type,
   /* TODO(dje): Print address of struct or actual string?  */
   if (options->addressprint)
     {
-      fputs_filtered (paddress (gdbarch, addr), stream);
-      fputs_filtered (" ", stream);
+      gdb_puts (paddress (gdbarch, addr), stream);
+      gdb_puts (" ", stream);
     }
 
   if (length < 0)
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 91fae3dd7f4..eb6cf7c0453 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -1060,7 +1060,7 @@ print_mem (unsigned long datum, const char *header, int in_pages_p)
     {
       if (in_pages_p)
 	datum <<= 12;
-      puts_filtered (header);
+      gdb_puts (header);
       if (datum > 1024)
 	{
 	  printf_filtered ("%lu KB", datum >> 10);
@@ -1069,7 +1069,7 @@ print_mem (unsigned long datum, const char *header, int in_pages_p)
 	}
       else
 	printf_filtered ("%lu Bytes", datum);
-      puts_filtered ("\n");
+      gdb_puts ("\n");
     }
 }
 
@@ -1137,7 +1137,7 @@ go32_sysinfo (const char *arg, int from_tty)
   printf_filtered ("CPU Type.......................%s", u.machine);
   if (cpuid_vendor[0])
     printf_filtered (" (%s)", cpuid_vendor);
-  puts_filtered ("\n");
+  gdb_puts ("\n");
 
   /* CPUID with EAX = 1 returns processor signature and features.  */
   if (cpuid_max >= 1)
@@ -1262,39 +1262,39 @@ go32_sysinfo (const char *arg, int from_tty)
 	  || ((cpuid_edx & 1) == 0)
 	  || ((amd_p || hygon_p) && (cpuid_edx & (3 << 30)) != 0))
 	{
-	  puts_filtered ("CPU Features...................");
+	  gdb_puts ("CPU Features...................");
 	  /* We only list features which might be useful in the DPMI
 	     environment.  */
 	  if ((cpuid_edx & 1) == 0)
-	    puts_filtered ("No FPU "); /* It's unusual to not have an FPU.  */
+	    gdb_puts ("No FPU "); /* It's unusual to not have an FPU.  */
 	  if ((cpuid_edx & (1 << 1)) != 0)
-	    puts_filtered ("VME ");
+	    gdb_puts ("VME ");
 	  if ((cpuid_edx & (1 << 2)) != 0)
-	    puts_filtered ("DE ");
+	    gdb_puts ("DE ");
 	  if ((cpuid_edx & (1 << 4)) != 0)
-	    puts_filtered ("TSC ");
+	    gdb_puts ("TSC ");
 	  if ((cpuid_edx & (1 << 23)) != 0)
-	    puts_filtered ("MMX ");
+	    gdb_puts ("MMX ");
 	  if ((cpuid_edx & (1 << 25)) != 0)
-	    puts_filtered ("SSE ");
+	    gdb_puts ("SSE ");
 	  if ((cpuid_edx & (1 << 26)) != 0)
-	    puts_filtered ("SSE2 ");
+	    gdb_puts ("SSE2 ");
 	  if (amd_p || hygon_p)
 	    {
 	      if ((cpuid_edx & (1 << 31)) != 0)
-		puts_filtered ("3DNow! ");
+		gdb_puts ("3DNow! ");
 	      if ((cpuid_edx & (1 << 30)) != 0)
-		puts_filtered ("3DNow!Ext");
+		gdb_puts ("3DNow!Ext");
 	    }
-	  puts_filtered ("\n");
+	  gdb_puts ("\n");
 	}
     }
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   printf_filtered ("DOS Version....................%s %s.%s",
 		   _os_flavor, u.release, u.version);
   if (true_dos_version != advertized_dos_version)
     printf_filtered (" (disguised as v%d.%d)", _osmajor, _osminor);
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   if (!windows_major)
     go32_get_windows_version ();
   if (windows_major != 0xff)
@@ -1337,7 +1337,7 @@ go32_sysinfo (const char *arg, int from_tty)
   else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
     printf_filtered ("Windows Version................"
 		     "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   /* On some versions of Windows, __dpmi_get_capabilities returns
      zero, but the buffer is not filled with info, so we fill the
      buffer with a known pattern and test for it afterwards.  */
@@ -1384,7 +1384,7 @@ go32_sysinfo (const char *arg, int from_tty)
 		       a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ? "LDT" : "GDT",
 		       (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ? "" : "out");
     }
-  puts_filtered ("\n");
+  gdb_puts ("\n");
   __dpmi_get_free_memory_information (&mem_info);
   print_mem (mem_info.total_number_of_physical_pages,
 	     "DPMI Total Physical Memory.....", 1);
@@ -1542,7 +1542,7 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force)
 
   /* Get the descriptor from the table.  */
   if (idx == 0 && type == 0)
-    puts_filtered ("0x000: null descriptor\n");
+    gdb_puts ("0x000: null descriptor\n");
   else if (get_descriptor (base_addr, idx, &descr) != -1)
     {
       /* For each type of descriptor table, this has a bit set if the
@@ -1580,7 +1580,7 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force)
 				 descr.stype == 3 ? "" : "in");
 		break;
 	      case 2:
-		puts_filtered (" LDT");
+		gdb_puts (" LDT");
 		break;
 	      case 4:
 		memcpy (&gate, &descr, sizeof gate);
@@ -1654,7 +1654,7 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force)
 		printf_filtered ("Unknown type 0x%02x", descr.stype);
 		break;
 	    }
-	  puts_filtered ("\n");
+	  gdb_puts ("\n");
 	}
       else if (force)
 	{
@@ -1662,7 +1662,7 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force)
 			   type == 1
 			   ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
 	  if (!descr.present)
-	    puts_filtered ("Segment not present\n");
+	    gdb_puts ("Segment not present\n");
 	  else
 	    printf_filtered ("Segment type 0x%02x is invalid in this table\n",
 			     descr.stype);
@@ -1700,7 +1700,7 @@ go32_sldt (const char *arg, int from_tty)
   __asm__ __volatile__ ("sldt   %0" : "=m" (ldtr) : /* no inputs */ );
   ldt_idx = ldtr / 8;
   if (ldt_idx == 0)
-    puts_filtered ("There is no LDT.\n");
+    gdb_puts ("There is no LDT.\n");
   /* LDT's entry in the GDT must have the type LDT, which is 2.  */
   else if (get_descriptor (gdtr.base, ldt_idx, &ldt_descr) != 2)
     printf_filtered ("LDT is present (at %#x), but unreadable by GDB.\n",
@@ -1941,9 +1941,9 @@ display_ptable_entry (unsigned long entry, int is_dir, int force, unsigned off)
     {
       printf_filtered ("Base=0x%05lx000", entry >> 12);
       if ((entry & 0x100) && !is_dir)
-	puts_filtered (" Global");
+	gdb_puts (" Global");
       if ((entry & 0x40) && !is_dir)
-	puts_filtered (" Dirty");
+	gdb_puts (" Dirty");
       printf_filtered (" %sAcc.", (entry & 0x20) ? "" : "Not-");
       printf_filtered (" %sCached", (entry & 0x10) ? "" : "Not-");
       printf_filtered (" Write-%s", (entry & 8) ? "Thru" : "Back");
@@ -1951,7 +1951,7 @@ display_ptable_entry (unsigned long entry, int is_dir, int force, unsigned off)
       printf_filtered (" Read-%s", (entry & 2) ? "Write" : "Only");
       if (off)
 	printf_filtered (" +0x%x", off);
-      puts_filtered ("\n");
+      gdb_puts ("\n");
     }
   else if (force)
     printf_filtered ("Page%s not present or not supported; value=0x%lx.\n",
@@ -1977,8 +1977,8 @@ go32_pde (const char *arg, int from_tty)
 
   pdbr = get_cr3 ();
   if (!pdbr)
-    puts_filtered ("Access to Page Directories is "
-		   "not supported on this system.\n");
+    gdb_puts ("Access to Page Directories is "
+	      "not supported on this system.\n");
   else if (pde_idx >= 0)
     display_ptable_entry (get_pde (pde_idx), 1, 1, 0);
   else
@@ -2002,7 +2002,7 @@ display_page_table (long n, int force)
 		       "Page Directory entry 0x%lx:\n", n);
       for (i = 0; i < 1024; i++)
 	display_ptable_entry (get_pte (pde, i), 0, 0, 0);
-      puts_filtered ("\n");
+      gdb_puts ("\n");
     }
   else if (force)
     printf_filtered ("Page Table not present; value=0x%lx.\n", pde >> 1);
@@ -2027,7 +2027,7 @@ go32_pte (const char *arg, int from_tty)
 
   pdbr = get_cr3 ();
   if (!pdbr)
-    puts_filtered ("Access to Page Tables is not supported on this system.\n");
+    gdb_puts ("Access to Page Tables is not supported on this system.\n");
   else if (pde_idx >= 0)
     display_page_table (pde_idx, 1);
   else
@@ -2052,7 +2052,7 @@ go32_pte_for_address (const char *arg, int from_tty)
 
   pdbr = get_cr3 ();
   if (!pdbr)
-    puts_filtered ("Access to Page Tables is not supported on this system.\n");
+    gdb_puts ("Access to Page Tables is not supported on this system.\n");
   else
     {
       int pde_idx = (addr >> 22) & 0x3ff;
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index dde7882b425..c61ca1dafc4 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -202,7 +202,7 @@ fputsn_filtered (const char *s, size_t size, struct ui_file *stream)
   for (i = 0; i < size; ++i)
     {
       if (s[i] == '\0')
-	fputs_filtered ("\\000", stream);
+	gdb_puts ("\\000", stream);
       else
 	fputc_filtered (s[i], stream);
     }
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index c64e8346938..8a5c02d0adb 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -687,7 +687,7 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
 	  for (i = 0; i < length; ++i)
 	    {
 	      if (string.get ()[i] == '\0')
-		fputs_filtered ("\\000", stream);
+		gdb_puts ("\\000", stream);
 	      else
 		fputc_filtered (string.get ()[i], stream);
 	    }
@@ -826,10 +826,10 @@ ppscm_print_children (SCM printer, enum display_hint hint,
       if (i == 0)
 	{
 	  if (!printed_nothing)
-	    fputs_filtered (" = ", stream);
+	    gdb_puts (" = ", stream);
 	}
       else if (! is_map || i % 2 == 0)
-	fputs_filtered (pretty ? "," : ", ", stream);
+	gdb_puts (pretty ? "," : ", ", stream);
 
       /* Skip printing children if max_depth has been reached.  This check
 	 is performed after print_string_repr and the "=" separator so that
@@ -839,7 +839,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	goto done;
       else if (i == 0)
 	/* Print initial "{" to bookend children.  */
-	fputs_filtered ("{", stream);
+	gdb_puts ("{", stream);
 
       /* In summary mode, we just want to print "= {...}" if there is
 	 a value.  */
@@ -857,7 +857,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	{
 	  if (pretty)
 	    {
-	      fputs_filtered ("\n", stream);
+	      gdb_puts ("\n", stream);
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 	  else
@@ -865,7 +865,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	}
 
       if (is_map && i % 2 == 0)
-	fputs_filtered ("[", stream);
+	gdb_puts ("[", stream);
       else if (is_array)
 	{
 	  /* We print the index, not whatever the child method
@@ -875,8 +875,8 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	}
       else if (! is_map)
 	{
-	  fputs_filtered (name.get (), stream);
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (name.get (), stream);
+	  gdb_puts (" = ", stream);
 	}
 
       if (lsscm_is_lazy_string (v_scm))
@@ -890,7 +890,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	{
 	  gdb::unique_xmalloc_ptr<char> output
 	    = gdbscm_scm_to_c_string (v_scm);
-	  fputs_filtered (output.get (), stream);
+	  gdb_puts (output.get (), stream);
 	}
       else
 	{
@@ -920,7 +920,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	}
 
       if (is_map && i % 2 == 0)
-	fputs_filtered ("] = ", stream);
+	gdb_puts ("] = ", stream);
     }
 
   if (i)
@@ -929,17 +929,17 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	{
 	  if (pretty)
 	    {
-	      fputs_filtered ("\n", stream);
+	      gdb_puts ("\n", stream);
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
-	  fputs_filtered ("...", stream);
+	  gdb_puts ("...", stream);
 	}
       if (pretty)
 	{
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	  print_spaces_filtered (2 * recurse, stream);
 	}
-      fputs_filtered ("}", stream);
+      gdb_puts ("}", stream);
     }
 
  done:
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 2f0b6509457..57f23c0e1d3 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -70,13 +70,13 @@ print_i387_ext (struct gdbarch *gdbarch,
 	fprintf_filtered (file, " %cInf", (sign ? '-' : '+'));
       else if (sign && fraction[0] == 0x00000000 && fraction[1] == 0x40000000)
 	/* Real Indefinite (QNaN).  */
-	fputs_filtered (" Real Indefinite (QNaN)", file);
+	gdb_puts (" Real Indefinite (QNaN)", file);
       else if (fraction[1] & 0x40000000)
 	/* QNaN.  */
-	fputs_filtered (" QNaN", file);
+	gdb_puts (" QNaN", file);
       else
 	/* SNaN.  */
-	fputs_filtered (" SNaN", file);
+	gdb_puts (" SNaN", file);
     }
   else if (exponent < 0x7fff && exponent > 0x0000 && integer)
     /* Normal.  */
@@ -88,14 +88,14 @@ print_i387_ext (struct gdbarch *gdbarch,
       
       if (integer)
 	/* Pseudo-denormal.  */
-	fputs_filtered (" Pseudo-denormal", file);
+	gdb_puts (" Pseudo-denormal", file);
       else if (fraction[0] || fraction[1])
 	/* Denormal.  */
-	fputs_filtered (" Denormal", file);
+	gdb_puts (" Denormal", file);
     }
   else
     /* Unsupported.  */
-    fputs_filtered (" Unsupported", file);
+    gdb_puts (" Unsupported", file);
 }
 
 /* Print the status word STATUS.  If STATUS_P is false, then STATUS
@@ -113,24 +113,24 @@ print_i387_status_word (int status_p,
     }
 
   fprintf_filtered (file, "%s", hex_string_custom (status, 4));
-  fputs_filtered ("  ", file);
+  gdb_puts ("  ", file);
   fprintf_filtered (file, " %s", (status & 0x0001) ? "IE" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0002) ? "DE" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0004) ? "ZE" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0008) ? "OE" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0010) ? "UE" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0020) ? "PE" : "  ");
-  fputs_filtered ("  ", file);
+  gdb_puts ("  ", file);
   fprintf_filtered (file, " %s", (status & 0x0080) ? "ES" : "  ");
-  fputs_filtered ("  ", file);
+  gdb_puts ("  ", file);
   fprintf_filtered (file, " %s", (status & 0x0040) ? "SF" : "  ");
-  fputs_filtered ("  ", file);
+  gdb_puts ("  ", file);
   fprintf_filtered (file, " %s", (status & 0x0100) ? "C0" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0200) ? "C1" : "  ");
   fprintf_filtered (file, " %s", (status & 0x0400) ? "C2" : "  ");
   fprintf_filtered (file, " %s", (status & 0x4000) ? "C3" : "  ");
 
-  fputs_filtered ("\n", file);
+  gdb_puts ("\n", file);
 
   fprintf_filtered (file,
 		    "                       TOP: %d\n", ((status >> 11) & 7));
@@ -151,7 +151,7 @@ print_i387_control_word (int control_p,
     }
 
   fprintf_filtered (file, "%s", hex_string_custom (control, 4));
-  fputs_filtered ("  ", file);
+  gdb_puts ("  ", file);
   fprintf_filtered (file, " %s", (control & 0x0001) ? "IM" : "  ");
   fprintf_filtered (file, " %s", (control & 0x0002) ? "DM" : "  ");
   fprintf_filtered (file, " %s", (control & 0x0004) ? "ZM" : "  ");
@@ -159,39 +159,39 @@ print_i387_control_word (int control_p,
   fprintf_filtered (file, " %s", (control & 0x0010) ? "UM" : "  ");
   fprintf_filtered (file, " %s", (control & 0x0020) ? "PM" : "  ");
 
-  fputs_filtered ("\n", file);
+  gdb_puts ("\n", file);
 
-  fputs_filtered ("                       PC: ", file);
+  gdb_puts ("                       PC: ", file);
   switch ((control >> 8) & 3)
     {
     case 0:
-      fputs_filtered ("Single Precision (24-bits)\n", file);
+      gdb_puts ("Single Precision (24-bits)\n", file);
       break;
     case 1:
-      fputs_filtered ("Reserved\n", file);
+      gdb_puts ("Reserved\n", file);
       break;
     case 2:
-      fputs_filtered ("Double Precision (53-bits)\n", file);
+      gdb_puts ("Double Precision (53-bits)\n", file);
       break;
     case 3:
-      fputs_filtered ("Extended Precision (64-bits)\n", file);
+      gdb_puts ("Extended Precision (64-bits)\n", file);
       break;
     }
       
-  fputs_filtered ("                       RC: ", file);
+  gdb_puts ("                       RC: ", file);
   switch ((control >> 10) & 3)
     {
     case 0:
-      fputs_filtered ("Round to nearest\n", file);
+      gdb_puts ("Round to nearest\n", file);
       break;
     case 1:
-      fputs_filtered ("Round down\n", file);
+      gdb_puts ("Round down\n", file);
       break;
     case 2:
-      fputs_filtered ("Round up\n", file);
+      gdb_puts ("Round up\n", file);
       break;
     case 3:
-      fputs_filtered ("Round toward zero\n", file);
+      gdb_puts ("Round toward zero\n", file);
       break;
     }
 }
@@ -263,21 +263,21 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 	      switch (tag)
 		{
 		case 0:
-		  fputs_filtered ("Valid   ", file);
+		  gdb_puts ("Valid   ", file);
 		  break;
 		case 1:
-		  fputs_filtered ("Zero    ", file);
+		  gdb_puts ("Zero    ", file);
 		  break;
 		case 2:
-		  fputs_filtered ("Special ", file);
+		  gdb_puts ("Special ", file);
 		  break;
 		case 3:
-		  fputs_filtered ("Empty   ", file);
+		  gdb_puts ("Empty   ", file);
 		  break;
 		}
 	    }
 	  else
-	    fputs_filtered ("Unknown ", file);
+	    gdb_puts ("Unknown ", file);
 
 	  regnum = (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep);
 	  regval = get_frame_register_value (frame, regnum);
@@ -286,7 +286,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 	    {
 	      const gdb_byte *raw = value_contents (regval).data ();
 
-	      fputs_filtered ("0x", file);
+	      gdb_puts ("0x", file);
 	      for (i = 9; i >= 0; i--)
 		fprintf_filtered (file, "%02x", raw[i]);
 
@@ -296,11 +296,11 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 	  else
 	    fprintf_filtered (file, "%s", _("<unavailable>"));
 
-	  fputs_filtered ("\n", file);
+	  gdb_puts ("\n", file);
 	}
     }
 
-  fputs_filtered ("\n", file);
+  gdb_puts ("\n", file);
   print_i387_status_word (fstat_p, fstat, file);
   print_i387_control_word (fctrl_p, fctrl, file);
   fprintf_filtered (file, "Tag Word:            %s\n",
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index e82286f5c1c..2197df28cbf 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1103,7 +1103,7 @@ jump_command (const char *arg, int from_tty)
   if (from_tty)
     {
       printf_filtered (_("Continuing at "));
-      puts_filtered (paddress (gdbarch, addr));
+      gdb_puts (paddress (gdbarch, addr));
       printf_filtered (".\n");
     }
 
@@ -1907,16 +1907,16 @@ environment_info (const char *var, int from_tty)
 
       if (val)
 	{
-	  puts_filtered (var);
-	  puts_filtered (" = ");
-	  puts_filtered (val);
-	  puts_filtered ("\n");
+	  gdb_puts (var);
+	  gdb_puts (" = ");
+	  gdb_puts (val);
+	  gdb_puts ("\n");
 	}
       else
 	{
-	  puts_filtered ("Environment variable \"");
-	  puts_filtered (var);
-	  puts_filtered ("\" not defined.\n");
+	  gdb_puts ("Environment variable \"");
+	  gdb_puts (var);
+	  gdb_puts ("\" not defined.\n");
 	}
     }
   else
@@ -1925,8 +1925,8 @@ environment_info (const char *var, int from_tty)
 
       for (int idx = 0; envp[idx] != NULL; ++idx)
 	{
-	  puts_filtered (envp[idx]);
-	  puts_filtered ("\n");
+	  gdb_puts (envp[idx]);
+	  gdb_puts ("\n");
 	}
     }
 }
@@ -2014,9 +2014,9 @@ static const char path_var_name[] = "PATH";
 static void
 path_info (const char *args, int from_tty)
 {
-  puts_filtered ("Executable and object file path: ");
-  puts_filtered (current_inferior ()->environment.get (path_var_name));
-  puts_filtered ("\n");
+  gdb_puts ("Executable and object file path: ");
+  gdb_puts (current_inferior ()->environment.get (path_var_name));
+  gdb_puts ("\n");
 }
 
 /* Add zero or more directories to the front of the execution path.  */
@@ -2116,7 +2116,7 @@ default_print_one_register_info (struct ui_file *file,
 	}
     }
 
-  fputs_filtered (format_stream.c_str (), file);
+  gdb_puts (format_stream.c_str (), file);
   fprintf_filtered (file, "\n");
 }
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 03e3489c91e..daef9aa7b3a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -176,9 +176,9 @@ show_disable_randomization (struct ui_file *file, int from_tty,
 			"virtual address space is %s.\n"),
 		      value);
   else
-    fputs_filtered (_("Disabling randomization of debuggee's "
-		      "virtual address space is unsupported on\n"
-		      "this platform.\n"), file);
+    gdb_puts (_("Disabling randomization of debuggee's "
+		"virtual address space is unsupported on\n"
+		"this platform.\n"), file);
 }
 
 static void
diff --git a/gdb/jit.c b/gdb/jit.c
index 42776b95683..d66959c6fa2 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -719,8 +719,8 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
       (code_entry->symfile_addr, code_entry->symfile_size, gnutarget));
   if (nbfd == NULL)
     {
-      fputs_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"),
-			gdb_stderr);
+      gdb_puts (_("Error opening JITed symbol file, ignoring it.\n"),
+		gdb_stderr);
       return;
     }
 
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 4baab3c80c7..e7e25b5eae6 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -580,7 +580,7 @@ info_checkpoints_command (const char *arg, int from_tty)
       if (fi.num == 0)
 	printf_filtered (_(" (main process)"));
       printf_filtered (_(" at "));
-      puts_filtered (paddress (gdbarch, pc));
+      gdb_puts (paddress (gdbarch, pc));
 
       symtab_and_line sal = find_pc_line (pc, 0);
       if (sal.symtab)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 1b48b7fef25..1f9f092dd5c 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -935,7 +935,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
       gdb::unique_xmalloc_ptr<char> status
 	= target_fileio_read_stralloc (NULL, filename);
       if (status)
-	puts_filtered (status.get ());
+	gdb_puts (status.get ());
       else
 	warning (_("unable to open /proc file '%s'"), filename);
     }
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 52e8c9a0e43..30b0eb86919 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -778,7 +778,7 @@ check_thread_db (struct thread_db_info *info, bool log_progress)
   catch (const gdb_exception_error &except)
     {
       if (warning_pre_print)
-	fputs_unfiltered (warning_pre_print, gdb_stderr);
+	gdb_puts (warning_pre_print, gdb_stderr);
 
       exception_fprintf (gdb_stderr, except,
 			 _("libthread_db integrity checks failed: "));
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 7673426b7a8..bc82bc5380e 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -145,9 +145,9 @@ void
 m2_language::printchar (int c, struct type *type,
 			struct ui_file *stream) const
 {
-  fputs_filtered ("'", stream);
+  gdb_puts ("'", stream);
   emitchar (c, type, stream, '\'');
-  fputs_filtered ("'", stream);
+  gdb_puts ("'", stream);
 }
 
 /* See language.h.  */
@@ -165,7 +165,7 @@ m2_language::printstr (struct ui_file *stream, struct type *elttype,
 
   if (length == 0)
     {
-      puts_filtered ("\"\"");
+      gdb_puts ("\"\"");
       return;
     }
 
@@ -181,7 +181,7 @@ m2_language::printstr (struct ui_file *stream, struct type *elttype,
 
       if (need_comma)
 	{
-	  fputs_filtered (", ", stream);
+	  gdb_puts (", ", stream);
 	  need_comma = 0;
 	}
 
@@ -197,7 +197,7 @@ m2_language::printstr (struct ui_file *stream, struct type *elttype,
 	{
 	  if (in_quotes)
 	    {
-	      fputs_filtered ("\", ", stream);
+	      gdb_puts ("\", ", stream);
 	      in_quotes = 0;
 	    }
 	  printchar (string[i], elttype, stream);
@@ -210,7 +210,7 @@ m2_language::printstr (struct ui_file *stream, struct type *elttype,
 	{
 	  if (!in_quotes)
 	    {
-	      fputs_filtered ("\"", stream);
+	      gdb_puts ("\"", stream);
 	      in_quotes = 1;
 	    }
 	  emitchar (string[i], elttype, stream, '"');
@@ -220,10 +220,10 @@ m2_language::printstr (struct ui_file *stream, struct type *elttype,
 
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
-    fputs_filtered ("\"", stream);
+    gdb_puts ("\"", stream);
 
   if (force_ellipses || i < length)
-    fputs_filtered ("...", stream);
+    gdb_puts ("...", stream);
 }
 
 /* See language.h.  */
@@ -237,7 +237,7 @@ m2_language::emitchar (int ch, struct type *chtype,
   if (PRINT_LITERAL_FORM (ch))
     {
       if (ch == '\\' || ch == quoter)
-	fputs_filtered ("\\", stream);
+	gdb_puts ("\\", stream);
       fprintf_filtered (stream, "%c", ch);
     }
   else
@@ -245,25 +245,25 @@ m2_language::emitchar (int ch, struct type *chtype,
       switch (ch)
 	{
 	case '\n':
-	  fputs_filtered ("\\n", stream);
+	  gdb_puts ("\\n", stream);
 	  break;
 	case '\b':
-	  fputs_filtered ("\\b", stream);
+	  gdb_puts ("\\b", stream);
 	  break;
 	case '\t':
-	  fputs_filtered ("\\t", stream);
+	  gdb_puts ("\\t", stream);
 	  break;
 	case '\f':
-	  fputs_filtered ("\\f", stream);
+	  gdb_puts ("\\f", stream);
 	  break;
 	case '\r':
-	  fputs_filtered ("\\r", stream);
+	  gdb_puts ("\\r", stream);
 	  break;
 	case '\033':
-	  fputs_filtered ("\\e", stream);
+	  gdb_puts ("\\e", stream);
 	  break;
 	case '\007':
-	  fputs_filtered ("\\a", stream);
+	  gdb_puts ("\\a", stream);
 	  break;
 	default:
 	  fprintf_filtered (stream, "\\%.3o", (unsigned int) ch);
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index f3685f75b72..dfe334c890a 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -179,7 +179,7 @@ void
 m2_type_name (struct type *type, struct ui_file *stream)
 {
   if (type->name () != NULL)
-    fputs_filtered (type->name (), stream);
+    gdb_puts (type->name (), stream);
 }
 
 /* m2_range - displays a Modula-2 subrange type.  */
@@ -213,8 +213,8 @@ m2_typedef (struct type *type, struct ui_file *stream, int show,
 {
   if (type->name () != NULL)
     {
-      fputs_filtered (type->name (), stream);
-      fputs_filtered (" = ", stream);
+      gdb_puts (type->name (), stream);
+      gdb_puts (" = ", stream);
     }
   m2_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level, flags);
 }
@@ -235,9 +235,9 @@ static void m2_array (struct type *type, struct ui_file *stream,
 	  m2_print_bounds (type->index_type (), stream, show, -1, 1);
 	}
       else
-	fputs_filtered (pulongest ((TYPE_LENGTH (type)
-				    / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))),
-			stream);
+	gdb_puts (pulongest ((TYPE_LENGTH (type)
+			      / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))),
+		  stream);
     }
   fprintf_filtered (stream, "] OF ");
   m2_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level, flags);
@@ -291,7 +291,7 @@ m2_procedure (struct type *type, struct ui_file *stream,
 	{
 	  if (i > 0)
 	    {
-	      fputs_filtered (", ", stream);
+	      gdb_puts (", ", stream);
 	      stream->wrap_here (4);
 	    }
 	  m2_print_type (type->field (i).type (), "", stream, -1, 0, flags);
@@ -442,10 +442,10 @@ m2_long_set (struct type *type, struct ui_file *stream, int show, int level,
     {
       if (type->name () != NULL)
 	{
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	  if (show == 0)
 	    return 1;
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (" = ", stream);
 	}
 
       if (get_long_set_bounds (type, &low, &high))
@@ -516,7 +516,7 @@ m2_unbounded_array (struct type *type, struct ui_file *stream, int show,
     {
       if (show > 0)
 	{
-	  fputs_filtered ("ARRAY OF ", stream);
+	  gdb_puts ("ARRAY OF ", stream);
 	  m2_print_type (TYPE_TARGET_TYPE (type->field (0).type ()),
 			 "", stream, 0, level, flags);
 	}
@@ -534,7 +534,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
     {
       if (!startswith (type->name (), "$$"))
 	{
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	  if (show > 0)
 	    fprintf_filtered (stream, " = ");
 	}
@@ -565,7 +565,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
 	  print_spaces_filtered (level + 4, stream);
 	  fputs_styled (type->field (i).name (),
 			variable_name_style.style (), stream);
-	  fputs_filtered (" : ", stream);
+	  gdb_puts (" : ", stream);
 	  m2_print_type (type->field (i).type (),
 			 "",
 			 stream, 0, level + 4, flags);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 3fd46b25a38..3fe9ad83b70 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -200,7 +200,7 @@ print_unpacked_pointer (struct type *type,
 
   if (options->addressprint && options->format != 's')
     {
-      fputs_filtered (paddress (gdbarch, address), stream);
+      gdb_puts (paddress (gdbarch, address), stream);
       want_space = 1;
     }
 
@@ -213,7 +213,7 @@ print_unpacked_pointer (struct type *type,
       && addr != 0)
     {
       if (want_space)
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
       return val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
 			       stream, options);
     }
@@ -233,7 +233,7 @@ print_variable_at_address (struct type *type,
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
   fprintf_filtered (stream, "[");
-  fputs_filtered (paddress (gdbarch, addr), stream);
+  gdb_puts (paddress (gdbarch, addr), stream);
   fprintf_filtered (stream, "] : ");
   
   if (elttype->code () != TYPE_CODE_UNDEF)
@@ -244,7 +244,7 @@ print_variable_at_address (struct type *type,
       common_val_print (deref_val, stream, recurse, options, current_language);
     }
   else
-    fputs_filtered ("???", stream);
+    gdb_puts ("???", stream);
 }
 
 
@@ -397,7 +397,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 	  int i;
 	  int need_comma = 0;
 
-	  fputs_filtered ("{", stream);
+	  gdb_puts ("{", stream);
 
 	  i = get_discrete_bounds (range, &low_bound, &high_bound) ? 0 : -1;
 	maybe_bad_bstring:
@@ -420,7 +420,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 	      if (element)
 		{
 		  if (need_comma)
-		    fputs_filtered (", ", stream);
+		    gdb_puts (", ", stream);
 		  print_type_scalar (range, i, stream);
 		  need_comma = 1;
 
@@ -429,7 +429,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 		    {
 		      int j = i;
 
-		      fputs_filtered ("..", stream);
+		      gdb_puts ("..", stream);
 		      while (i + 1 <= high_bound
 			     && value_bit_index (type, valaddr, ++i))
 			j = i;
@@ -438,7 +438,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 		}
 	    }
 	done:
-	  fputs_filtered ("}", stream);
+	  gdb_puts ("}", stream);
 	}
       break;
 
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 07714644fca..e1caeefdff9 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -41,7 +41,7 @@ static struct cmd_list_element *macrolist;
 static void
 macro_inform_no_debuginfo (void)
 {
-  puts_filtered ("GDB has no preprocessor macro information for that code.\n");
+  gdb_puts ("GDB has no preprocessor macro information for that code.\n");
 }
 
 static void
@@ -63,9 +63,9 @@ macro_expand_command (const char *exp, int from_tty)
     {
       gdb::unique_xmalloc_ptr<char> expanded = macro_expand (exp, *ms);
 
-      puts_filtered ("expands to: ");
-      puts_filtered (expanded.get ());
-      puts_filtered ("\n");
+      gdb_puts ("expands to: ");
+      gdb_puts (expanded.get ());
+      gdb_puts ("\n");
     }
   else
     macro_inform_no_debuginfo ();
@@ -91,9 +91,9 @@ macro_expand_once_command (const char *exp, int from_tty)
     {
       gdb::unique_xmalloc_ptr<char> expanded = macro_expand_once (exp, *ms);
 
-      puts_filtered ("expands to: ");
-      puts_filtered (expanded.get ());
-      puts_filtered ("\n");
+      gdb_puts ("expands to: ");
+      gdb_puts (expanded.get ());
+      gdb_puts ("\n");
     }
   else
     macro_inform_no_debuginfo ();
@@ -117,7 +117,7 @@ show_pp_source_pos (struct ui_file *stream,
   while (file->included_by)
     {
       fullname = macro_source_fullname (file->included_by);
-      fputs_filtered (_("  included at "), stream);
+      gdb_puts (_("  included at "), stream);
       fputs_styled (fullname.c_str (), file_name_style.style (), stream);
       fprintf_filtered (stream, ":%d\n", file->included_at_line);
       file = file->included_by;
@@ -149,14 +149,14 @@ print_macro_definition (const char *name,
     {
       int i;
 
-      puts_filtered ("(");
+      gdb_puts ("(");
       for (i = 0; i < d->argc; i++)
 	{
-	  puts_filtered (d->argv[i]);
+	  gdb_puts (d->argv[i]);
 	  if (i + 1 < d->argc)
-	    puts_filtered (", ");
+	    gdb_puts (", ");
 	}
-      puts_filtered (")");
+      gdb_puts (")");
     }
 
   if (line != 0)
diff --git a/gdb/main.c b/gdb/main.c
index 8f944d86545..15ba37c59ce 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1391,12 +1391,12 @@ print_gdb_help (struct ui_file *stream)
   /* Note: The options in the list below are only approximately sorted
      in the alphabetical order, so as to group closely related options
      together.  */
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
 This is the GNU debugger.  Usage:\n\n\
     gdb [options] [executable-file [core-file or process-id]]\n\
     gdb [options] --args executable-file [inferior-arguments ...]\n\n\
 "), stream);
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
 Selection of debuggee and its files:\n\n\
   --args             Arguments after executable-file are passed to inferior.\n\
   --core=COREFILE    Analyze the core dump COREFILE.\n\
@@ -1409,7 +1409,7 @@ Selection of debuggee and its files:\n\n\
   --readnever        Do not read symbol files.\n\
   --write            Set writing into executable and core files.\n\n\
 "), stream);
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
 Initial commands and command files:\n\n\
   --command=FILE, -x Execute GDB commands from FILE.\n\
   --init-command=FILE, -ix\n\
@@ -1423,7 +1423,7 @@ Initial commands and command files:\n\n\
   --nh               Do not read ~/.gdbinit.\n\
   --nx               Do not read any .gdbinit files in any directory.\n\n\
 "), stream);
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
 Output and user interface control:\n\n\
   --fullname         Output information used by emacs-GDB interface.\n\
   --interpreter=INTERP\n\
@@ -1433,16 +1433,16 @@ Output and user interface control:\n\n\
   --nw               Do not use the GUI interface.\n\
 "), stream);
 #if defined(TUI)
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
   --tui              Use a terminal user interface.\n\
 "), stream);
 #endif
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
   --dbx              DBX compatibility mode.\n\
   -q, --quiet, --silent\n\
 		     Do not print version number on startup.\n\n\
 "), stream);
-  fputs_unfiltered (_("\
+  gdb_puts (_("\
 Operating modes:\n\n\
   --batch            Exit after processing options.\n\
   --batch-silent     Like --batch, but suppress all gdb stdout output.\n\
@@ -1459,7 +1459,7 @@ Other options:\n\n\
   --data-directory=DIR, -D\n\
 		     Set GDB's data-directory to DIR.\n\
 "), stream);
-  fputs_unfiltered (_("\n\
+  gdb_puts (_("\n\
 At startup, GDB reads the following early init files and executes their\n\
 commands:\n\
 "), stream);
@@ -1470,7 +1470,7 @@ commands:\n\
   if (home_gdbearlyinit.empty ())
     fprintf_unfiltered (stream, _("\
    None found.\n"));
-  fputs_unfiltered (_("\n\
+  gdb_puts (_("\n\
 At startup, GDB reads the following init files and executes their commands:\n\
 "), stream);
   if (!system_gdbinit.empty ())
@@ -1498,7 +1498,7 @@ At startup, GDB reads the following init files and executes their commands:\n\
       && local_gdbinit.empty ())
     fprintf_unfiltered (stream, _("\
    None found.\n"));
-  fputs_unfiltered (_("\n\
+  gdb_puts (_("\n\
 For more information, type \"help\" from within GDB, or consult the\n\
 GDB manual (available as on-line info or a printed manual).\n\
 "), stream);
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c
index b9b538d78bb..fd9fe6c4c17 100644
--- a/gdb/maint-test-options.c
+++ b/gdb/maint-test-options.c
@@ -279,7 +279,7 @@ static void
 maintenance_show_test_options_completion_result (const char *args,
 						 int from_tty)
 {
-  puts_filtered (maintenance_test_options_command_completion_text.c_str ());
+  gdb_puts (maintenance_test_options_command_completion_text.c_str ());
 }
 
 /* Save the completion result in the global variables read by the
diff --git a/gdb/maint.c b/gdb/maint.c
index 189b14643a8..a0d255a9e10 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -363,7 +363,7 @@ static void
 maint_print_all_sections (const char *header, bfd *abfd, objfile *objfile,
 			  const char *arg)
 {
-  puts_filtered (header);
+  gdb_puts (header);
   gdb_stdout->wrap_here (8);
   printf_filtered ("`%s', ", bfd_get_filename (abfd));
   gdb_stdout->wrap_here (8);
diff --git a/gdb/make-target-delegates b/gdb/make-target-delegates
index f759b5507ca..d2bb804cd3c 100755
--- a/gdb/make-target-delegates
+++ b/gdb/make-target-delegates
@@ -322,18 +322,18 @@ sub write_debugmethod($$$@) {
     print "  fprintf_unfiltered (gdb_stdlog, \"<- %s->$name (\", this->beneath ()->shortname ());\n";
     for my $i (0 .. $#argtypes) {
 	if ($i > 0) {
-	    print "  fputs_unfiltered (\", \", gdb_stdlog);\n"
+	    print "  gdb_puts (\", \", gdb_stdlog);\n"
 	}
 	my $printer = munge_type ($argtypes[$i]);
 	print "  $printer ($names[$i]);\n";
     }
     if ($return_type ne 'void') {
-	print "  fputs_unfiltered (\") = \", gdb_stdlog);\n";
+	print "  gdb_puts (\") = \", gdb_stdlog);\n";
 	my $printer = munge_type ($return_type);
 	print "  $printer (result);\n";
-	print "  fputs_unfiltered (\"\\n\", gdb_stdlog);\n";
+	print "  gdb_puts (\"\\n\", gdb_stdlog);\n";
     } else {
-	print "  fputs_unfiltered (\")\\n\", gdb_stdlog);\n";
+	print "  gdb_puts (\")\\n\", gdb_stdlog);\n";
     }
 
     if ($return_type ne 'void') {
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index 9db87fe180c..5043e9b475d 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -76,7 +76,7 @@ mi_console_file::flush ()
       size_t length_buf = str.size ();
       const char *buf = str.data ();
 
-      fputs_unfiltered (m_prefix, m_raw);
+      gdb_puts (m_prefix, m_raw);
       if (m_quote)
 	{
 	  fputc_unfiltered (m_quote, m_raw);
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index e69ad9aff2d..22a0f0506ad 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -98,7 +98,7 @@ display_mi_prompt (struct mi_interp *mi)
 {
   struct ui *ui = current_ui;
 
-  fputs_unfiltered ("(gdb) \n", mi->raw_stdout);
+  gdb_puts ("(gdb) \n", mi->raw_stdout);
   gdb_flush (mi->raw_stdout);
   ui->prompt_state = PROMPTED;
 }
@@ -664,11 +664,11 @@ mi_on_normal_stop_1 (struct bpstat *bs, int print_frame)
 	mi_uiout->field_signed ("core", core);
     }
   
-  fputs_unfiltered ("*stopped", mi->raw_stdout);
+  gdb_puts ("*stopped", mi->raw_stdout);
   mi_out_put (mi_uiout, mi->raw_stdout);
   mi_out_rewind (mi_uiout);
   mi_print_timing_maybe (mi->raw_stdout);
-  fputs_unfiltered ("\n", mi->raw_stdout);
+  gdb_puts ("\n", mi->raw_stdout);
   gdb_flush (mi->raw_stdout);
 }
 
@@ -1008,7 +1008,7 @@ mi_on_resume_1 (struct mi_interp *mi,
 	 even if it cannot actually accept any input.  This will be
 	 surely removed for MI3, and may be removed even earlier.  */
       if (current_ui->prompt_state == PROMPT_BLOCKED)
-	fputs_unfiltered ("(gdb) \n", mi->raw_stdout);
+	gdb_puts ("(gdb) \n", mi->raw_stdout);
     }
   gdb_flush (mi->raw_stdout);
 }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 4860da7536a..19cac0d78a0 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -153,8 +153,8 @@ mi_cmd_gdb_exit (const char *command, char **argv, int argc)
 
   /* We have to print everything right here because we never return.  */
   if (current_token)
-    fputs_unfiltered (current_token, mi->raw_stdout);
-  fputs_unfiltered ("^exit\n", mi->raw_stdout);
+    gdb_puts (current_token, mi->raw_stdout);
+  gdb_puts ("^exit\n", mi->raw_stdout);
   mi_out_put (current_uiout, mi->raw_stdout);
   gdb_flush (mi->raw_stdout);
   /* FIXME: The function called is not yet a formal libgdb function.  */
@@ -1800,15 +1800,15 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
 	 uiout will most likely crash in the mi_out_* routines.  */
       if (!running_result_record_printed)
 	{
-	  fputs_unfiltered (context->token, mi->raw_stdout);
+	  gdb_puts (context->token, mi->raw_stdout);
 	  /* There's no particularly good reason why target-connect results
 	     in not ^done.  Should kill ^connected for MI3.  */
-	  fputs_unfiltered (strcmp (context->command, "target-select") == 0
-			    ? "^connected" : "^done", mi->raw_stdout);
+	  gdb_puts (strcmp (context->command, "target-select") == 0
+		    ? "^connected" : "^done", mi->raw_stdout);
 	  mi_out_put (uiout, mi->raw_stdout);
 	  mi_out_rewind (uiout);
 	  mi_print_timing_maybe (mi->raw_stdout);
-	  fputs_unfiltered ("\n", mi->raw_stdout);
+	  gdb_puts ("\n", mi->raw_stdout);
 	}
       else
 	/* The command does not want anything to be printed.  In that
@@ -1839,12 +1839,12 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
 	  {
 	    if (!running_result_record_printed)
 	      {
-		fputs_unfiltered (context->token, mi->raw_stdout);
-		fputs_unfiltered ("^done", mi->raw_stdout);
+		gdb_puts (context->token, mi->raw_stdout);
+		gdb_puts ("^done", mi->raw_stdout);
 		mi_out_put (uiout, mi->raw_stdout);
 		mi_out_rewind (uiout);
 		mi_print_timing_maybe (mi->raw_stdout);
-		fputs_unfiltered ("\n", mi->raw_stdout);
+		gdb_puts ("\n", mi->raw_stdout);
 	      }
 	    else
 	      mi_out_rewind (uiout);
@@ -1861,22 +1861,22 @@ mi_print_exception (const char *token, const struct gdb_exception &exception)
 {
   struct mi_interp *mi = (struct mi_interp *) current_interpreter ();
 
-  fputs_unfiltered (token, mi->raw_stdout);
-  fputs_unfiltered ("^error,msg=\"", mi->raw_stdout);
+  gdb_puts (token, mi->raw_stdout);
+  gdb_puts ("^error,msg=\"", mi->raw_stdout);
   if (exception.message == NULL)
-    fputs_unfiltered ("unknown error", mi->raw_stdout);
+    gdb_puts ("unknown error", mi->raw_stdout);
   else
     mi->raw_stdout->putstr (exception.what (), '"');
-  fputs_unfiltered ("\"", mi->raw_stdout);
+  gdb_puts ("\"", mi->raw_stdout);
 
   switch (exception.error)
     {
       case UNDEFINED_COMMAND_ERROR:
-	fputs_unfiltered (",code=\"undefined-command\"", mi->raw_stdout);
+	gdb_puts (",code=\"undefined-command\"", mi->raw_stdout);
 	break;
     }
 
-  fputs_unfiltered ("\n", mi->raw_stdout);
+  gdb_puts ("\n", mi->raw_stdout);
 }
 
 /* Determine whether the parsed command already notifies the
@@ -2143,8 +2143,8 @@ mi_load_progress (const char *section_name,
       previous_sect_name = xstrdup (section_name);
 
       if (current_token)
-	fputs_unfiltered (current_token, mi->raw_stdout);
-      fputs_unfiltered ("+download", mi->raw_stdout);
+	gdb_puts (current_token, mi->raw_stdout);
+      gdb_puts ("+download", mi->raw_stdout);
       {
 	ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
 	uiout->field_string ("section", section_name);
@@ -2152,7 +2152,7 @@ mi_load_progress (const char *section_name,
 	uiout->field_signed ("total-size", grand_total);
       }
       mi_out_put (uiout.get (), mi->raw_stdout);
-      fputs_unfiltered ("\n", mi->raw_stdout);
+      gdb_puts ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }
 
@@ -2161,8 +2161,8 @@ mi_load_progress (const char *section_name,
     {
       last_update = time_now;
       if (current_token)
-	fputs_unfiltered (current_token, mi->raw_stdout);
-      fputs_unfiltered ("+download", mi->raw_stdout);
+	gdb_puts (current_token, mi->raw_stdout);
+      gdb_puts ("+download", mi->raw_stdout);
       {
 	ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
 	uiout->field_string ("section", section_name);
@@ -2172,7 +2172,7 @@ mi_load_progress (const char *section_name,
 	uiout->field_signed ("total-size", grand_total);
       }
       mi_out_put (uiout.get (), mi->raw_stdout);
-      fputs_unfiltered ("\n", mi->raw_stdout);
+      gdb_puts ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }
 }
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 5145bea4b75..ff93cb3ba10 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -150,9 +150,9 @@ mi_ui_out::do_field_fmt (int fldno, int width, ui_align align,
   if (fldname)
     fprintf_unfiltered (stream, "%s=\"", fldname);
   else
-    fputs_unfiltered ("\"", stream);
+    gdb_puts ("\"", stream);
   gdb_vprintf (stream, format, args);
-  fputs_unfiltered ("\"", stream);
+  gdb_puts ("\"", stream);
 }
 
 void
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 20e12b6889e..3756f9883dc 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -508,7 +508,7 @@ mips_show_dr (const char *func, CORE_ADDR addr,
 {
   int i;
 
-  fputs_unfiltered (func, gdb_stdlog);
+  gdb_puts (func, gdb_stdlog);
   if (addr || len)
     fprintf_unfiltered (gdb_stdlog,
 			" (addr=%s, len=%d, type=%s)",
@@ -518,7 +518,7 @@ mips_show_dr (const char *func, CORE_ADDR addr,
 			   : (type == hw_access ? "data-read/write"
 			      : (type == hw_execute ? "instruction-execute"
 				 : "??unknown??"))));
-  fputs_unfiltered (":\n", gdb_stdlog);
+  gdb_puts (":\n", gdb_stdlog);
 
   for (i = 0; i < MAX_DEBUG_REGISTER; i++)
     fprintf_unfiltered (gdb_stdlog, "\tDR%d: lo=%s, hi=%s\n", i,
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index e5f8c6b2053..299e8a0cc52 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6391,7 +6391,7 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
 
   val = get_frame_register_value (frame, regnum);
 
-  fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
+  gdb_puts (gdbarch_register_name (gdbarch, regnum), file);
 
   /* The problem with printing numeric register names (r26, etc.) is that
      the user can't use them on input.  Probably the best solution is to
@@ -6412,17 +6412,17 @@ static void
 print_fpu_flags (struct ui_file *file, int flags)
 {
   if (flags & (1 << 0))
-    fputs_filtered (" inexact", file);
+    gdb_puts (" inexact", file);
   if (flags & (1 << 1))
-    fputs_filtered (" uflow", file);
+    gdb_puts (" uflow", file);
   if (flags & (1 << 2))
-    fputs_filtered (" oflow", file);
+    gdb_puts (" oflow", file);
   if (flags & (1 << 3))
-    fputs_filtered (" div0", file);
+    gdb_puts (" div0", file);
   if (flags & (1 << 4))
-    fputs_filtered (" inval", file);
+    gdb_puts (" inval", file);
   if (flags & (1 << 5))
-    fputs_filtered (" unimp", file);
+    gdb_puts (" unimp", file);
   fputc_filtered ('\n', file);
 }
 
@@ -6452,39 +6452,39 @@ mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
   fprintf_filtered (file, "reg size: %d bits\n",
 		    register_size (gdbarch, mips_regnum (gdbarch)->fp0) * 8);
 
-  fputs_filtered ("cond    :", file);
+  gdb_puts ("cond    :", file);
   if (fcs & (1 << 23))
-    fputs_filtered (" 0", file);
+    gdb_puts (" 0", file);
   for (i = 1; i <= 7; i++)
     if (fcs & (1 << (24 + i)))
       fprintf_filtered (file, " %d", i);
   fputc_filtered ('\n', file);
 
-  fputs_filtered ("cause   :", file);
+  gdb_puts ("cause   :", file);
   print_fpu_flags (file, (fcs >> 12) & 0x3f);
   fputs ("mask    :", stdout);
   print_fpu_flags (file, (fcs >> 7) & 0x1f);
   fputs ("flags   :", stdout);
   print_fpu_flags (file, (fcs >> 2) & 0x1f);
 
-  fputs_filtered ("rounding: ", file);
+  gdb_puts ("rounding: ", file);
   switch (fcs & 3)
     {
-    case 0: fputs_filtered ("nearest\n", file); break;
-    case 1: fputs_filtered ("zero\n", file); break;
-    case 2: fputs_filtered ("+inf\n", file); break;
-    case 3: fputs_filtered ("-inf\n", file); break;
+    case 0: gdb_puts ("nearest\n", file); break;
+    case 1: gdb_puts ("zero\n", file); break;
+    case 2: gdb_puts ("+inf\n", file); break;
+    case 3: gdb_puts ("-inf\n", file); break;
     }
 
-  fputs_filtered ("flush   :", file);
+  gdb_puts ("flush   :", file);
   if (fcs & (1 << 21))
-    fputs_filtered (" nearest", file);
+    gdb_puts (" nearest", file);
   if (fcs & (1 << 22))
-    fputs_filtered (" override", file);
+    gdb_puts (" override", file);
   if (fcs & (1 << 24))
-    fputs_filtered (" zero", file);
+    gdb_puts (" zero", file);
   if ((fcs & (0xb << 21)) == 0)
-    fputs_filtered (" no", file);
+    gdb_puts (" no", file);
   fputc_filtered ('\n', file);
 
   fprintf_filtered (file, "nan2008 : %s\n", fcs & (1 << 18) ? "yes" : "no");
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 70ff404bac3..3f6ee25dfaa 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -152,11 +152,11 @@ pascal_language::print_one_char (int c, struct ui_file *stream,
   if (c == '\'' || ((unsigned int) c <= 0xff && (PRINT_LITERAL_FORM (c))))
     {
       if (!(*in_quotes))
-	fputs_filtered ("'", stream);
+	gdb_puts ("'", stream);
       *in_quotes = 1;
       if (c == '\'')
 	{
-	  fputs_filtered ("''", stream);
+	  gdb_puts ("''", stream);
 	}
       else
 	fprintf_filtered (stream, "%c", c);
@@ -164,7 +164,7 @@ pascal_language::print_one_char (int c, struct ui_file *stream,
   else
     {
       if (*in_quotes)
-	fputs_filtered ("'", stream);
+	gdb_puts ("'", stream);
       *in_quotes = 0;
       fprintf_filtered (stream, "#%d", (unsigned int) c);
     }
@@ -180,7 +180,7 @@ pascal_language::printchar (int c, struct type *type,
 
   print_one_char (c, stream, &in_quotes);
   if (in_quotes)
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
 }
 
 \f
@@ -249,7 +249,7 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 
   if (length == 0)
     {
-      fputs_filtered ("''", stream);
+      gdb_puts ("''", stream);
       return;
     }
 
@@ -266,7 +266,7 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 
       if (need_comma)
 	{
-	  fputs_filtered (", ", stream);
+	  gdb_puts (", ", stream);
 	  need_comma = 0;
 	}
 
@@ -287,7 +287,7 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 	{
 	  if (in_quotes)
 	    {
-	      fputs_filtered ("', ", stream);
+	      gdb_puts ("', ", stream);
 	      in_quotes = 0;
 	    }
 	  printchar (current_char, elttype, stream);
@@ -302,7 +302,7 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 	{
 	  if ((!in_quotes) && (PRINT_LITERAL_FORM (current_char)))
 	    {
-	      fputs_filtered ("'", stream);
+	      gdb_puts ("'", stream);
 	      in_quotes = 1;
 	    }
 	  print_one_char (current_char, stream, &in_quotes);
@@ -312,10 +312,10 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
 
   if (force_ellipses || i < length)
-    fputs_filtered ("...", stream);
+    gdb_puts ("...", stream);
 }
 
 /* Single instance of the Pascal language class.  */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 429ef23aea4..eae73e19346 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -116,7 +116,7 @@ class pascal_language : public language_defn
 
     print_one_char (ch, stream, &in_quotes);
     if (in_quotes)
-      fputs_filtered ("'", stream);
+      gdb_puts ("'", stream);
   }
 
   /* See language.h.  */
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 18c9ab9facb..98bbee97988 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -55,13 +55,13 @@ pascal_language::print_type (struct type *type, const char *varstring,
       type_print_varspec_prefix (type, stream, show, 0, flags);
     }
   /* first the name */
-  fputs_filtered (varstring, stream);
+  gdb_puts (varstring, stream);
 
   if ((varstring != NULL && *varstring != '\0')
       && !(code == TYPE_CODE_FUNC
 	   || code == TYPE_CODE_METHOD))
     {
-      fputs_filtered (" : ", stream);
+      gdb_puts (" : ", stream);
     }
 
   if (!(code == TYPE_CODE_FUNC
@@ -104,7 +104,7 @@ pascal_language::type_print_derivation_info (struct ui_file *stream,
 
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
     {
-      fputs_filtered (i == 0 ? ": " : ", ", stream);
+      gdb_puts (i == 0 ? ": " : ", ", stream);
       fprintf_filtered (stream, "%s%s ",
 			BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
 			BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
@@ -113,7 +113,7 @@ pascal_language::type_print_derivation_info (struct ui_file *stream,
     }
   if (i > 0)
     {
-      fputs_filtered (" ", stream);
+      gdb_puts (" ", stream);
     }
 }
 
@@ -132,11 +132,11 @@ pascal_language::type_print_method_args (const char *physname,
       physname += 6;
     }
 
-  fputs_filtered (methodname, stream);
+  gdb_puts (methodname, stream);
 
   if (physname && (*physname != 0))
     {
-      fputs_filtered (" (", stream);
+      gdb_puts (" (", stream);
       /* We must demangle this.  */
       while (isdigit (physname[0]))
 	{
@@ -157,10 +157,10 @@ pascal_language::type_print_method_args (const char *physname,
 	  physname += i;
 	  if (physname[0] != 0)
 	    {
-	      fputs_filtered (", ", stream);
+	      gdb_puts (", ", stream);
 	    }
 	}
-      fputs_filtered (")", stream);
+      gdb_puts (")", stream);
     }
 }
 
@@ -286,7 +286,7 @@ pascal_language::print_func_args (struct type *type, struct ui_file *stream,
     {
       if (i > 0)
 	{
-	  fputs_filtered (", ", stream);
+	  gdb_puts (", ", stream);
 	  stream->wrap_here (4);
 	}
       /*  Can we find if it is a var parameter ??
@@ -430,8 +430,8 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
   if ((type->code () == TYPE_CODE_PTR)
       && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_VOID))
     {
-      fputs_filtered (type->name () ? type->name () : "pointer",
-		      stream);
+      gdb_puts (type->name () ? type->name () : "pointer",
+		stream);
       return;
     }
   /* When SHOW is zero or less, and there is a valid type name, then always
@@ -440,7 +440,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
   if (show <= 0
       && type->name () != NULL)
     {
-      fputs_filtered (type->name (), stream);
+      gdb_puts (type->name (), stream);
       return;
     }
 
@@ -465,8 +465,8 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
     case TYPE_CODE_STRUCT:
       if (type->name () != NULL)
 	{
-	  fputs_filtered (type->name (), stream);
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (type->name (), stream);
+	  gdb_puts (" = ", stream);
 	}
       if (HAVE_CPLUS_STRUCT (type))
 	{
@@ -481,8 +481,8 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
     case TYPE_CODE_UNION:
       if (type->name () != NULL)
 	{
-	  fputs_filtered (type->name (), stream);
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (type->name (), stream);
+	  gdb_puts (" = ", stream);
 	}
       fprintf_filtered (stream, "case <?> of ");
 
@@ -668,7 +668,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 		  if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
 		      && TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE(f, j))->code () != TYPE_CODE_VOID)
 		    {
-		      fputs_filtered (" : ", stream);
+		      gdb_puts (" : ", stream);
 		      type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
 				  "", stream, -1);
 		    }
@@ -685,9 +685,9 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
     case TYPE_CODE_ENUM:
       if (type->name () != NULL)
 	{
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	  if (show > 0)
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 	}
       /* enum is just defined by
 	 type enume_name = (enum_member1,enum_member2,...)  */
@@ -710,7 +710,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 	      if (i)
 		fprintf_filtered (stream, ", ");
 	      stream->wrap_here (4);
-	      fputs_filtered (type->field (i).name (), stream);
+	      gdb_puts (type->field (i).name (), stream);
 	      if (lastval != type->field (i).loc_enumval ())
 		{
 		  fprintf_filtered (stream,
@@ -742,19 +742,19 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 	struct type *target = TYPE_TARGET_TYPE (type);
 
 	print_type_scalar (target, type->bounds ()->low.const_val (), stream);
-	fputs_filtered ("..", stream);
+	gdb_puts ("..", stream);
 	print_type_scalar (target, type->bounds ()->high.const_val (), stream);
       }
       break;
 
     case TYPE_CODE_SET:
-      fputs_filtered ("set of ", stream);
+      gdb_puts ("set of ", stream);
       print_type (type->index_type (), "", stream,
 			 show - 1, level, flags);
       break;
 
     case TYPE_CODE_STRING:
-      fputs_filtered ("String", stream);
+      gdb_puts ("String", stream);
       break;
 
     default:
@@ -764,7 +764,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 	 is no type name, then complain.  */
       if (type->name () != NULL)
 	{
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	}
       else
 	{
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 635d7ed5e4d..362206275c6 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -176,7 +176,7 @@ pascal_language::value_print_inner (struct value *val,
 
       if (options->addressprint && options->format != 's')
 	{
-	  fputs_filtered (paddress (gdbarch, addr), stream);
+	  gdb_puts (paddress (gdbarch, addr), stream);
 	  want_space = 1;
 	}
 
@@ -191,7 +191,7 @@ pascal_language::value_print_inner (struct value *val,
 	  && addr != 0)
 	{
 	  if (want_space)
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 	  /* No wide string yet.  */
 	  i = val_print_string (elttype, NULL, addr, -1, stream, options);
 	}
@@ -208,7 +208,7 @@ pascal_language::value_print_inner (struct value *val,
 	  gdb_byte *buffer;
 
 	  if (want_space)
-	    fputs_filtered (" ", stream);
+	    gdb_puts (" ", stream);
 	  buffer = (gdb_byte *) xmalloc (length_size);
 	  read_memory (addr + length_pos, buffer, length_size);
 	  string_length = extract_unsigned_integer (buffer, length_size,
@@ -231,10 +231,10 @@ pascal_language::value_print_inner (struct value *val,
 	      && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
 	    {
 	      if (want_space)
-		fputs_filtered (" ", stream);
-	      fputs_filtered ("<", stream);
-	      fputs_filtered (msymbol.minsym->print_name (), stream);
-	      fputs_filtered (">", stream);
+		gdb_puts (" ", stream);
+	      gdb_puts ("<", stream);
+	      gdb_puts (msymbol.minsym->print_name (), stream);
+	      gdb_puts (">", stream);
 	      want_space = 1;
 	    }
 	  if (vt_address && options->vtblprint)
@@ -244,7 +244,7 @@ pascal_language::value_print_inner (struct value *val,
 	      struct type *wtype;
 
 	      if (want_space)
-		fputs_filtered (" ", stream);
+		gdb_puts (" ", stream);
 
 	      if (msymbol.minsym != NULL)
 		{
@@ -341,7 +341,7 @@ pascal_language::value_print_inner (struct value *val,
 	  LONGEST low_bound, high_bound;
 	  int need_comma = 0;
 
-	  fputs_filtered ("[", stream);
+	  gdb_puts ("[", stream);
 
 	  int bound_info = (get_discrete_bounds (range, &low_bound, &high_bound)
 			    ? 0 : -1);
@@ -372,7 +372,7 @@ pascal_language::value_print_inner (struct value *val,
 	      if (element)
 		{
 		  if (need_comma)
-		    fputs_filtered (", ", stream);
+		    gdb_puts (", ", stream);
 		  print_type_scalar (range, i, stream);
 		  need_comma = 1;
 
@@ -381,7 +381,7 @@ pascal_language::value_print_inner (struct value *val,
 		    {
 		      int j = i;
 
-		      fputs_filtered ("..", stream);
+		      gdb_puts ("..", stream);
 		      while (i + 1 <= high_bound
 			     && value_bit_index (type, valaddr, ++i))
 			j = i;
@@ -390,7 +390,7 @@ pascal_language::value_print_inner (struct value *val,
 		}
 	    }
 	done:
-	  fputs_filtered ("]", stream);
+	  gdb_puts ("]", stream);
 	}
       break;
 
@@ -560,9 +560,9 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
-		  fputs_filtered ("members of ", stream);
-		  fputs_filtered (type->name (), stream);
-		  fputs_filtered (": ", stream);
+		  gdb_puts ("members of ", stream);
+		  gdb_puts (type->name (), stream);
+		  gdb_puts (": ", stream);
 		}
 	    }
 	  fields_seen = 1;
@@ -581,7 +581,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 
 	  if (field_is_static (&type->field (i)))
 	    {
-	      fputs_filtered ("static ", stream);
+	      gdb_puts ("static ", stream);
 	      fprintf_symbol_filtered (stream,
 				       type->field (i).name (),
 				       current_language->la_language,
@@ -591,7 +591,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	    fputs_styled (type->field (i).name (),
 			  variable_name_style.style (), stream);
 	  annotate_field_name_end ();
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (" = ", stream);
 	  annotate_field_value ();
 
 	  if (!field_is_static (&type->field (i))
@@ -764,12 +764,12 @@ pascal_object_print_value (struct value *val, struct ui_file *stream,
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
 	}
-      fputs_filtered ("<", stream);
+      gdb_puts ("<", stream);
       /* Not sure what the best notation is in the case where there is no
 	 baseclass name.  */
 
-      fputs_filtered (basename ? basename : "", stream);
-      fputs_filtered ("> = ", stream);
+      gdb_puts (basename ? basename : "", stream);
+      gdb_puts ("> = ", stream);
 
       if (skip < 0)
 	val_print_unavailable (stream);
@@ -780,7 +780,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream,
 	  (base_value, stream, recurse, options,
 	   (struct type **) obstack_base (&dont_print_vb_obstack),
 	   0);
-      fputs_filtered (", ", stream);
+      gdb_puts (", ", stream);
 
     flush_it:
       ;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index f5ce0404d48..948cf85dbc5 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -567,11 +567,11 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
 			      &offset, &filename, &line, &unmapped))
     return 0;
 
-  fputs_filtered (leadin, stream);
+  gdb_puts (leadin, stream);
   if (unmapped)
-    fputs_filtered ("<*", stream);
+    gdb_puts ("<*", stream);
   else
-    fputs_filtered ("<", stream);
+    gdb_puts ("<", stream);
   fputs_styled (name.c_str (), function_name_style.style (), stream);
   if (offset != 0)
     fprintf_filtered (stream, "%+d", offset);
@@ -580,15 +580,15 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
      line # of this addr, if we have it; else line # of the nearest symbol.  */
   if (print_symbol_filename && !filename.empty ())
     {
-      fputs_filtered (line == -1 ? " in " : " at ", stream);
+      gdb_puts (line == -1 ? " in " : " at ", stream);
       fputs_styled (filename.c_str (), file_name_style.style (), stream);
       if (line != -1)
 	fprintf_filtered (stream, ":%d", line);
     }
   if (unmapped)
-    fputs_filtered ("*>", stream);
+    gdb_puts ("*>", stream);
   else
-    fputs_filtered (">", stream);
+    gdb_puts (">", stream);
 
   return 1;
 }
@@ -1155,7 +1155,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
 	}
 
       if (format == 'i')
-	puts_filtered (pc_prefix (next_address));
+	gdb_puts (pc_prefix (next_address));
       print_address (next_gdbarch, next_address, gdb_stdout);
       printf_filtered (":");
       for (i = maxelts;
@@ -1683,7 +1683,7 @@ info_address_command (const char *exp, int from_tty)
     }
 
   printf_filtered ("Symbol \"");
-  puts_filtered (sym->print_name ());
+  gdb_puts (sym->print_name ());
   printf_filtered ("\" is ");
   val = SYMBOL_VALUE (sym);
   if (SYMBOL_OBJFILE_OWNED (sym))
@@ -2161,7 +2161,7 @@ do_one_display (struct display *d)
 
       annotate_display_expression ();
 
-      puts_filtered (d->exp_string.c_str ());
+      gdb_puts (d->exp_string.c_str ());
       annotate_display_expression_end ();
 
       if (d->format.count != 1 || d->format.format == 'i')
@@ -2200,7 +2200,7 @@ do_one_display (struct display *d)
 
       annotate_display_expression ();
 
-      puts_filtered (d->exp_string.c_str ());
+      gdb_puts (d->exp_string.c_str ());
       annotate_display_expression_end ();
 
       printf_filtered (" = ");
@@ -2287,7 +2287,7 @@ Num Enb Expression\n"));
 			 d->format.format);
       else if (d->format.format)
 	printf_filtered ("/%c ", d->format.format);
-      puts_filtered (d->exp_string.c_str ());
+      gdb_puts (d->exp_string.c_str ());
       if (d->block && !contained_in (get_selected_block (0), d->block, true))
 	printf_filtered (_(" (cannot be evaluated in the current context)"));
       printf_filtered ("\n");
@@ -2629,7 +2629,7 @@ printf_floating (struct ui_file *stream, const char *format,
   /* Convert the value to a string and print it.  */
   std::string str
     = target_float_to_string (value_contents (value).data (), fmt_type, format);
-  fputs_filtered (str.c_str (), stream);
+  gdb_puts (str.c_str (), stream);
 }
 
 /* Subroutine of ui_printf to simplify it.
@@ -2867,7 +2867,7 @@ ui_printf (const char *arg, struct ui_file *stream)
 	    /* Print a portion of the format string that has no
 	       directives.  Note that this will not include any
 	       ordinary %-specs, but it might include "%%".  That is
-	       why we use printf_filtered and not puts_filtered here.
+	       why we use printf_filtered and not gdb_puts here.
 	       Also, we pass a dummy argument because some platforms
 	       have modified GCC to include -Wformat-security by
 	       default, which will warn here if there is no
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ce077c67cbb..a9e5bcabca3 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -668,84 +668,84 @@ print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
 	  fprintf_filtered (outfile, "  `%s'",
 			    p->ginfo.demangled_name ());
 	}
-      fputs_filtered (", ", outfile);
+      gdb_puts (", ", outfile);
       switch (p->domain)
 	{
 	case UNDEF_DOMAIN:
-	  fputs_filtered ("undefined domain, ", outfile);
+	  gdb_puts ("undefined domain, ", outfile);
 	  break;
 	case VAR_DOMAIN:
 	  /* This is the usual thing -- don't print it.  */
 	  break;
 	case STRUCT_DOMAIN:
-	  fputs_filtered ("struct domain, ", outfile);
+	  gdb_puts ("struct domain, ", outfile);
 	  break;
 	case MODULE_DOMAIN:
-	  fputs_filtered ("module domain, ", outfile);
+	  gdb_puts ("module domain, ", outfile);
 	  break;
 	case LABEL_DOMAIN:
-	  fputs_filtered ("label domain, ", outfile);
+	  gdb_puts ("label domain, ", outfile);
 	  break;
 	case COMMON_BLOCK_DOMAIN:
-	  fputs_filtered ("common block domain, ", outfile);
+	  gdb_puts ("common block domain, ", outfile);
 	  break;
 	default:
-	  fputs_filtered ("<invalid domain>, ", outfile);
+	  gdb_puts ("<invalid domain>, ", outfile);
 	  break;
 	}
       switch (p->aclass)
 	{
 	case LOC_UNDEF:
-	  fputs_filtered ("undefined", outfile);
+	  gdb_puts ("undefined", outfile);
 	  break;
 	case LOC_CONST:
-	  fputs_filtered ("constant int", outfile);
+	  gdb_puts ("constant int", outfile);
 	  break;
 	case LOC_STATIC:
-	  fputs_filtered ("static", outfile);
+	  gdb_puts ("static", outfile);
 	  break;
 	case LOC_REGISTER:
-	  fputs_filtered ("register", outfile);
+	  gdb_puts ("register", outfile);
 	  break;
 	case LOC_ARG:
-	  fputs_filtered ("pass by value", outfile);
+	  gdb_puts ("pass by value", outfile);
 	  break;
 	case LOC_REF_ARG:
-	  fputs_filtered ("pass by reference", outfile);
+	  gdb_puts ("pass by reference", outfile);
 	  break;
 	case LOC_REGPARM_ADDR:
-	  fputs_filtered ("register address parameter", outfile);
+	  gdb_puts ("register address parameter", outfile);
 	  break;
 	case LOC_LOCAL:
-	  fputs_filtered ("stack parameter", outfile);
+	  gdb_puts ("stack parameter", outfile);
 	  break;
 	case LOC_TYPEDEF:
-	  fputs_filtered ("type", outfile);
+	  gdb_puts ("type", outfile);
 	  break;
 	case LOC_LABEL:
-	  fputs_filtered ("label", outfile);
+	  gdb_puts ("label", outfile);
 	  break;
 	case LOC_BLOCK:
-	  fputs_filtered ("function", outfile);
+	  gdb_puts ("function", outfile);
 	  break;
 	case LOC_CONST_BYTES:
-	  fputs_filtered ("constant bytes", outfile);
+	  gdb_puts ("constant bytes", outfile);
 	  break;
 	case LOC_UNRESOLVED:
-	  fputs_filtered ("unresolved", outfile);
+	  gdb_puts ("unresolved", outfile);
 	  break;
 	case LOC_OPTIMIZED_OUT:
-	  fputs_filtered ("optimized out", outfile);
+	  gdb_puts ("optimized out", outfile);
 	  break;
 	case LOC_COMPUTED:
-	  fputs_filtered ("computed at runtime", outfile);
+	  gdb_puts ("computed at runtime", outfile);
 	  break;
 	default:
-	  fputs_filtered ("<invalid location>", outfile);
+	  gdb_puts ("<invalid location>", outfile);
 	  break;
 	}
-      fputs_filtered (", ", outfile);
-      fputs_filtered (paddress (gdbarch, p->unrelocated_address ()), outfile);
+      gdb_puts (", ", outfile);
+      gdb_puts (paddress (gdbarch, p->unrelocated_address ()), outfile);
       fprintf_filtered (outfile, "\n");
     }
 }
@@ -780,9 +780,9 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
        host_address_to_string (psymtab->get_compunit_symtab (objfile)));
 
   fprintf_filtered (outfile, "  Symbols cover text addresses ");
-  fputs_filtered (paddress (gdbarch, psymtab->text_low (objfile)), outfile);
+  gdb_puts (paddress (gdbarch, psymtab->text_low (objfile)), outfile);
   fprintf_filtered (outfile, "-");
-  fputs_filtered (paddress (gdbarch, psymtab->text_high (objfile)), outfile);
+  gdb_puts (paddress (gdbarch, psymtab->text_high (objfile)), outfile);
   fprintf_filtered (outfile, "\n");
   fprintf_filtered (outfile, "  Address map supported - %s.\n",
 		    psymtab->psymtabs_addrmap_supported ? "yes" : "no");
@@ -1421,9 +1421,9 @@ partial_symtab::expand_dependencies (struct objfile *objfile)
 	  /* Inform about additional files to be read in.  */
 	  if (info_verbose)
 	    {
-	      puts_filtered (" ");
+	      gdb_puts (" ");
 	      gdb_stdout->wrap_here (0);
-	      puts_filtered ("and ");
+	      gdb_puts ("and ");
 	      gdb_stdout->wrap_here (0);
 	      printf_filtered ("%s...", dependencies[i]->filename);
 	      gdb_stdout->wrap_here (0);	/* Flush output */
@@ -1696,11 +1696,11 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
 				     psymtab->fullname
 				     ? psymtab->fullname : "(null)");
 		    printf_filtered ("    text addresses ");
-		    puts_filtered (paddress (gdbarch,
-					     psymtab->text_low (objfile)));
+		    gdb_puts (paddress (gdbarch,
+					psymtab->text_low (objfile)));
 		    printf_filtered (" -- ");
-		    puts_filtered (paddress (gdbarch,
-					     psymtab->text_high (objfile)));
+		    gdb_puts (paddress (gdbarch,
+					psymtab->text_high (objfile)));
 		    printf_filtered ("\n");
 		    printf_filtered ("    psymtabs_addrmap_supported %s\n",
 				     (psymtab->psymtabs_addrmap_supported
@@ -1789,11 +1789,11 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 	      if (ps->text_high (objfile) < ps->text_low (objfile))
 		{
 		  printf_filtered ("Psymtab ");
-		  puts_filtered (ps->filename);
+		  gdb_puts (ps->filename);
 		  printf_filtered (" covers bad range ");
-		  puts_filtered (paddress (gdbarch, ps->text_low (objfile)));
+		  gdb_puts (paddress (gdbarch, ps->text_low (objfile)));
 		  printf_filtered (" - ");
-		  puts_filtered (paddress (gdbarch, ps->text_high (objfile)));
+		  gdb_puts (paddress (gdbarch, ps->text_high (objfile)));
 		  printf_filtered ("\n");
 		  continue;
 		}
@@ -1817,9 +1817,9 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 		  if (!sym)
 		    {
 		      printf_filtered ("Static symbol `");
-		      puts_filtered (psym->ginfo.linkage_name ());
+		      gdb_puts (psym->ginfo.linkage_name ());
 		      printf_filtered ("' only found in ");
-		      puts_filtered (ps->filename);
+		      gdb_puts (ps->filename);
 		      printf_filtered (" psymtab\n");
 		    }
 		}
@@ -1832,9 +1832,9 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 		  if (!sym)
 		    {
 		      printf_filtered ("Global symbol `");
-		      puts_filtered (psym->ginfo.linkage_name ());
+		      gdb_puts (psym->ginfo.linkage_name ());
 		      printf_filtered ("' only found in ");
-		      puts_filtered (ps->filename);
+		      gdb_puts (ps->filename);
 		      printf_filtered (" psymtab\n");
 		    }
 		}
@@ -1843,15 +1843,15 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 		      || ps->text_high (objfile) > BLOCK_END (b)))
 		{
 		  printf_filtered ("Psymtab ");
-		  puts_filtered (ps->filename);
+		  gdb_puts (ps->filename);
 		  printf_filtered (" covers ");
-		  puts_filtered (paddress (gdbarch, ps->text_low (objfile)));
+		  gdb_puts (paddress (gdbarch, ps->text_low (objfile)));
 		  printf_filtered (" - ");
-		  puts_filtered (paddress (gdbarch, ps->text_high (objfile)));
+		  gdb_puts (paddress (gdbarch, ps->text_high (objfile)));
 		  printf_filtered (" but symtab covers only ");
-		  puts_filtered (paddress (gdbarch, BLOCK_START (b)));
+		  gdb_puts (paddress (gdbarch, BLOCK_START (b)));
 		  printf_filtered (" - ");
-		  puts_filtered (paddress (gdbarch, BLOCK_END (b)));
+		  gdb_puts (paddress (gdbarch, BLOCK_END (b)));
 		  printf_filtered ("\n");
 		}
 	    }
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 5e0c90fb61b..ec00a20ae6d 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -348,12 +348,12 @@ py_print_single_arg (struct ui_out *out,
     {
       string_file stb;
 
-      fputs_filtered (fa->sym->print_name (), &stb);
+      gdb_puts (fa->sym->print_name (), &stb);
       if (fa->entry_kind == print_entry_values_compact)
 	{
 	  stb.puts ("=");
 
-	  fputs_filtered (fa->sym->print_name (), &stb);
+	  gdb_puts (fa->sym->print_name (), &stb);
 	}
       if (fa->entry_kind == print_entry_values_only
 	  || fa->entry_kind == print_entry_values_compact)
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 8d3786844de..16277cc29d2 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -321,7 +321,7 @@ print_string_repr (PyObject *printer, const char *hint,
 		language->printstr (stream, type, (gdb_byte *) output,
 				    length, NULL, 0, options);
 	      else
-		fputs_filtered (output, stream);
+		gdb_puts (output, stream);
 	    }
 	  else
 	    {
@@ -439,10 +439,10 @@ print_children (PyObject *printer, const char *hint,
       if (i == 0)
 	{
 	  if (!is_py_none)
-	    fputs_filtered (" = ", stream);
+	    gdb_puts (" = ", stream);
 	}
       else if (! is_map || i % 2 == 0)
-	fputs_filtered (pretty ? "," : ", ", stream);
+	gdb_puts (pretty ? "," : ", ", stream);
 
       /* Skip printing children if max_depth has been reached.  This check
 	 is performed after print_string_repr and the "=" separator so that
@@ -452,7 +452,7 @@ print_children (PyObject *printer, const char *hint,
 	return;
       else if (i == 0)
 	/* Print initial "{" to bookend children.  */
-	fputs_filtered ("{", stream);
+	gdb_puts ("{", stream);
 
       /* In summary mode, we just want to print "= {...}" if there is
 	 a value.  */
@@ -470,7 +470,7 @@ print_children (PyObject *printer, const char *hint,
 	{
 	  if (pretty)
 	    {
-	      fputs_filtered ("\n", stream);
+	      gdb_puts ("\n", stream);
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 	  else
@@ -478,7 +478,7 @@ print_children (PyObject *printer, const char *hint,
 	}
 
       if (is_map && i % 2 == 0)
-	fputs_filtered ("[", stream);
+	gdb_puts ("[", stream);
       else if (is_array)
 	{
 	  /* We print the index, not whatever the child method
@@ -488,8 +488,8 @@ print_children (PyObject *printer, const char *hint,
 	}
       else if (! is_map)
 	{
-	  fputs_filtered (name, stream);
-	  fputs_filtered (" = ", stream);
+	  gdb_puts (name, stream);
+	  gdb_puts (" = ", stream);
 	}
 
       if (gdbpy_is_lazy_string (py_v))
@@ -514,7 +514,7 @@ print_children (PyObject *printer, const char *hint,
 	  if (!output)
 	    gdbpy_print_stack ();
 	  else
-	    fputs_filtered (output.get (), stream);
+	    gdb_puts (output.get (), stream);
 	}
       else
 	{
@@ -540,7 +540,7 @@ print_children (PyObject *printer, const char *hint,
 	}
 
       if (is_map && i % 2 == 0)
-	fputs_filtered ("] = ", stream);
+	gdb_puts ("] = ", stream);
     }
 
   if (i)
@@ -549,17 +549,17 @@ print_children (PyObject *printer, const char *hint,
 	{
 	  if (pretty)
 	    {
-	      fputs_filtered ("\n", stream);
+	      gdb_puts ("\n", stream);
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
-	  fputs_filtered ("...", stream);
+	  gdb_puts ("...", stream);
 	}
       if (pretty)
 	{
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	  print_spaces_filtered (2 * recurse, stream);
 	}
-      fputs_filtered ("}", stream);
+      gdb_puts ("}", stream);
     }
 }
 
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index a87e86aaeaf..2bf79c0cc95 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -294,7 +294,7 @@ sim_inferior_data::~sim_inferior_data ()
 static void
 dump_mem (const gdb_byte *buf, int len)
 {
-  fputs_unfiltered ("\t", gdb_stdlog);
+  gdb_puts ("\t", gdb_stdlog);
 
   if (len == 8 || len == 4)
     {
@@ -313,7 +313,7 @@ dump_mem (const gdb_byte *buf, int len)
 	fprintf_unfiltered (gdb_stdlog, "0x%02x ", buf[i]);
     }
 
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
 }
 
 /* Initialize gdb_callback.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index bc9a73b2b09..6746aa851bc 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1774,8 +1774,8 @@ show_memory_packet_size (struct memory_packet_config *config)
 	printf_filtered (_("Packets are limited to %ld bytes.\n"),
 			 remote->get_memory_packet_size (config));
       else
-	puts_filtered ("The actual limit will be further reduced "
-		       "dependent on the target.\n");
+	gdb_puts ("The actual limit will be further reduced "
+		  "dependent on the target.\n");
     }
 }
 
@@ -5781,9 +5781,9 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
 
   if (from_tty)
     {
-      puts_filtered ("Remote debugging using ");
-      puts_filtered (name);
-      puts_filtered ("\n");
+      gdb_puts ("Remote debugging using ");
+      gdb_puts (name);
+      gdb_puts ("\n");
     }
 
   /* Switch to using the remote target now.  */
@@ -5959,7 +5959,7 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty)
 
   /* Exit only if this is the only active inferior.  */
   if (from_tty && !rs->extended && number_of_live_inferiors (this) == 1)
-    puts_filtered (_("Ending remote debugging.\n"));
+    gdb_puts (_("Ending remote debugging.\n"));
 
   /* See if any thread of the inferior we are detaching has a pending fork
      status.  In that case, we must detach from the child resulting from
@@ -6092,7 +6092,7 @@ remote_target::disconnect (const char *args, int from_tty)
   remote_unpush_target (this);
 
   if (from_tty)
-    puts_filtered ("Ending remote debugging.\n");
+    gdb_puts ("Ending remote debugging.\n");
 }
 
 /* Attach to the process specified by ARGS.  If FROM_TTY is non-zero,
@@ -11614,18 +11614,18 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks
 
   void sending (gdb::array_view<const char> &buf) override
   {
-    puts_filtered ("sending: ");
+    gdb_puts ("sending: ");
     print_packet (buf);
-    puts_filtered ("\n");
+    gdb_puts ("\n");
   }
 
   /* Called with BUF, the reply from the remote target.  */
 
   void received (gdb::array_view<const char> &buf) override
   {
-    puts_filtered ("received: \"");
+    gdb_puts ("received: \"");
     print_packet (buf);
-    puts_filtered ("\"\n");
+    gdb_puts ("\"\n");
   }
 
 private:
@@ -11647,7 +11647,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks
 	  fprintf_unfiltered (&stb, "\\x%02x", (unsigned char) c);
       }
 
-    puts_filtered (stb.string ().c_str ());
+    gdb_puts (stb.string ().c_str ());
   }
 };
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 886996ce5b7..35287c868fd 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1037,7 +1037,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
   int print_raw_format;
   enum tab_stops { value_column_1 = 15 };
 
-  fputs_filtered (name, file);
+  gdb_puts (name, file);
   print_spaces_filtered (value_column_1 - strlen (name), file);
 
   try
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 316e172969a..110a429a47f 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -349,13 +349,13 @@ rust_language::val_print_struct
 	return;
 
       if (type->name () != NULL)
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
     }
 
   if (is_tuple || is_tuple_struct)
-    fputs_filtered ("(", stream);
+    gdb_puts ("(", stream);
   else
-    fputs_filtered ("{", stream);
+    gdb_puts ("{", stream);
 
   opts = *options;
   opts.deref_ref = 0;
@@ -367,15 +367,15 @@ rust_language::val_print_struct
 	continue;
 
       if (!first_field)
-	fputs_filtered (",", stream);
+	gdb_puts (",", stream);
 
       if (options->prettyformat)
 	{
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	  print_spaces_filtered (2 + 2 * recurse, stream);
 	}
       else if (!first_field)
-	fputs_filtered (" ", stream);
+	gdb_puts (" ", stream);
 
       first_field = 0;
 
@@ -383,7 +383,7 @@ rust_language::val_print_struct
 	{
 	  fputs_styled (type->field (i).name (),
 			variable_name_style.style (), stream);
-	  fputs_filtered (": ", stream);
+	  gdb_puts (": ", stream);
 	}
 
       common_val_print (value_field (val, i), stream, recurse + 1, &opts,
@@ -392,14 +392,14 @@ rust_language::val_print_struct
 
   if (options->prettyformat)
     {
-      fputs_filtered ("\n", stream);
+      gdb_puts ("\n", stream);
       print_spaces_filtered (2 * recurse, stream);
     }
 
   if (is_tuple || is_tuple_struct)
-    fputs_filtered (")", stream);
+    gdb_puts (")", stream);
   else
-    fputs_filtered ("}", stream);
+    gdb_puts ("}", stream);
 }
 
 /* See rust-lang.h.  */
@@ -458,7 +458,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
   for (int j = 0; j < variant_type->num_fields (); j++)
     {
       if (!first_field)
-	fputs_filtered (", ", stream);
+	gdb_puts (", ", stream);
       first_field = false;
 
       if (!is_tuple)
@@ -471,9 +471,9 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
     }
 
   if (is_tuple)
-    fputs_filtered (")", stream);
+    gdb_puts (")", stream);
   else
-    fputs_filtered ("}", stream);
+    gdb_puts ("}", stream);
 }
 
 static const struct generic_val_print_decorations rust_decorations =
@@ -524,11 +524,11 @@ rust_language::value_print_inner
 
 	    if (opts.addressprint)
 	      {
-		fputs_filtered (paddress (arch, addr), stream);
-		fputs_filtered (" ", stream);
+		gdb_puts (paddress (arch, addr), stream);
+		gdb_puts (" ", stream);
 	      }
 
-	    fputs_filtered ("b", stream);
+	    gdb_puts ("b", stream);
 	    val_print_string (TYPE_TARGET_TYPE (elttype), "ASCII", addr,
 			      high_bound - low_bound + 1, stream,
 			      &opts);
@@ -542,7 +542,7 @@ rust_language::value_print_inner
       if (type->is_unsigned () && TYPE_LENGTH (type) == 0
 	  && type->name () != NULL && strcmp (type->name (), "()") == 0)
 	{
-	  fputs_filtered ("()", stream);
+	  gdb_puts ("()", stream);
 	  break;
 	}
       goto generic_print;
@@ -557,7 +557,7 @@ rust_language::value_print_inner
 	/* If we see a plain TYPE_CODE_STRING, then we're printing a
 	   byte string, hence the choice of "ASCII" as the
 	   encoding.  */
-	fputs_filtered ("b", stream);
+	gdb_puts ("b", stream);
 	printstr (stream, TYPE_TARGET_TYPE (type),
 		  value_contents_for_printing (val).data (),
 		  high_bound - low_bound + 1, "ASCII", 0, &opts);
@@ -570,7 +570,7 @@ rust_language::value_print_inner
 
 	if (get_array_bounds (type, &low_bound, &high_bound)
 	    && high_bound - low_bound + 1 == 0)
-	  fputs_filtered ("[]", stream);
+	  gdb_puts ("[]", stream);
 	else
 	  goto generic_print;
       }
@@ -617,7 +617,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
   /* Print a tuple type simply.  */
   if (rust_tuple_type_p (type))
     {
-      fputs_filtered (type->name (), stream);
+      gdb_puts (type->name (), stream);
       return;
     }
 
@@ -648,26 +648,26 @@ rust_print_struct_def (struct type *type, const char *varstring,
       /* This code path is also used by unions and enums.  */
       if (is_enum)
 	{
-	  fputs_filtered ("enum ", stream);
+	  gdb_puts ("enum ", stream);
 	  dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
 	  if (prop != nullptr && prop->kind () == PROP_TYPE)
 	    type = prop->original_type ();
 	}
       else if (type->code () == TYPE_CODE_STRUCT)
-	fputs_filtered ("struct ", stream);
+	gdb_puts ("struct ", stream);
       else
-	fputs_filtered ("union ", stream);
+	gdb_puts ("union ", stream);
 
       if (tagname != NULL)
-	fputs_filtered (tagname, stream);
+	gdb_puts (tagname, stream);
     }
 
   if (type->num_fields () == 0 && !is_tuple)
     return;
   if (for_rust_enum && !flags->print_offsets)
-    fputs_filtered (is_tuple_struct ? "(" : "{", stream);
+    gdb_puts (is_tuple_struct ? "(" : "{", stream);
   else
-    fputs_filtered (is_tuple_struct ? " (\n" : " {\n", stream);
+    gdb_puts (is_tuple_struct ? " (\n" : " {\n", stream);
 
   /* When printing offsets, we rearrange the fields into storage
      order.  This lets us show holes more clearly.  We work using
@@ -720,12 +720,12 @@ rust_print_struct_def (struct type *type, const char *varstring,
 				stream, (is_enum ? show : show - 1),
 				level + 2, flags, is_enum, podata);
       if (!for_rust_enum || flags->print_offsets)
-	fputs_filtered (",\n", stream);
+	gdb_puts (",\n", stream);
       /* Note that this check of "I" is ok because we only sorted the
 	 fields by offset when print_offsets was set, so we won't take
 	 this branch in that case.  */
       else if (i + 1 < type->num_fields ())
-	fputs_filtered (", ", stream);
+	gdb_puts (", ", stream);
     }
 
   if (flags->print_offsets)
@@ -739,7 +739,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
     }
   if (!for_rust_enum || flags->print_offsets)
     print_spaces_filtered (level, stream);
-  fputs_filtered (is_tuple_struct ? ")" : "}", stream);
+  gdb_puts (is_tuple_struct ? ")" : "}", stream);
 }
 
 /* la_print_type implementation for Rust.  */
@@ -757,9 +757,9 @@ rust_internal_print_type (struct type *type, const char *varstring,
       /* Rust calls the unit type "void" in its debuginfo,
 	 but we don't want to print it as that.  */
       if (type->code () == TYPE_CODE_VOID)
-	fputs_filtered ("()", stream);
+	gdb_puts ("()", stream);
       else
-	fputs_filtered (type->name (), stream);
+	gdb_puts (type->name (), stream);
       return;
     }
 
@@ -771,7 +771,7 @@ rust_internal_print_type (struct type *type, const char *varstring,
 	 unqualified name, and there is nothing else to print
 	 here.  */
       if (!for_rust_enum)
-	fputs_filtered ("()", stream);
+	gdb_puts ("()", stream);
       break;
 
     case TYPE_CODE_FUNC:
@@ -779,23 +779,23 @@ rust_internal_print_type (struct type *type, const char *varstring,
       if (type->has_varargs ())
 	goto c_printer;
 
-      fputs_filtered ("fn ", stream);
+      gdb_puts ("fn ", stream);
       if (varstring != NULL)
-	fputs_filtered (varstring, stream);
-      fputs_filtered ("(", stream);
+	gdb_puts (varstring, stream);
+      gdb_puts ("(", stream);
       for (int i = 0; i < type->num_fields (); ++i)
 	{
 	  QUIT;
 	  if (i > 0)
-	    fputs_filtered (", ", stream);
+	    gdb_puts (", ", stream);
 	  rust_internal_print_type (type->field (i).type (), "", stream,
 				    -1, 0, flags, false, podata);
 	}
-      fputs_filtered (")", stream);
+      gdb_puts (")", stream);
       /* If it returns unit, we can omit the return type.  */
       if (TYPE_TARGET_TYPE (type)->code () != TYPE_CODE_VOID)
 	{
-	  fputs_filtered (" -> ", stream);
+	  gdb_puts (" -> ", stream);
 	  rust_internal_print_type (TYPE_TARGET_TYPE (type), "", stream,
 				    -1, 0, flags, false, podata);
 	}
@@ -805,7 +805,7 @@ rust_internal_print_type (struct type *type, const char *varstring,
       {
 	LONGEST low_bound, high_bound;
 
-	fputs_filtered ("[", stream);
+	gdb_puts ("[", stream);
 	rust_internal_print_type (TYPE_TARGET_TYPE (type), NULL,
 				  stream, show - 1, level, flags, false,
 				  podata);
@@ -816,7 +816,7 @@ rust_internal_print_type (struct type *type, const char *varstring,
 	else if (get_array_bounds (type, &low_bound, &high_bound))
 	  fprintf_filtered (stream, "; %s",
 			    plongest (high_bound - low_bound + 1));
-	fputs_filtered ("]", stream);
+	gdb_puts ("]", stream);
       }
       break;
 
@@ -830,14 +830,14 @@ rust_internal_print_type (struct type *type, const char *varstring,
       {
 	int len = 0;
 
-	fputs_filtered ("enum ", stream);
+	gdb_puts ("enum ", stream);
 	if (type->name () != NULL)
 	  {
-	    fputs_filtered (type->name (), stream);
-	    fputs_filtered (" ", stream);
+	    gdb_puts (type->name (), stream);
+	    gdb_puts (" ", stream);
 	    len = strlen (type->name ());
 	  }
-	fputs_filtered ("{\n", stream);
+	gdb_puts ("{\n", stream);
 
 	for (int i = 0; i < type->num_fields (); ++i)
 	  {
@@ -856,19 +856,19 @@ rust_internal_print_type (struct type *type, const char *varstring,
 					     name));
 	  }
 
-	fputs_filtered ("}", stream);
+	gdb_puts ("}", stream);
       }
       break;
 
     case TYPE_CODE_PTR:
       {
 	if (type->name () != nullptr)
-	  fputs_filtered (type->name (), stream);
+	  gdb_puts (type->name (), stream);
 	else
 	  {
 	    /* We currently can't distinguish between pointers and
 	       references.  */
-	    fputs_filtered ("*mut ", stream);
+	    gdb_puts ("*mut ", stream);
 	    type_print (TYPE_TARGET_TYPE (type), "", stream, 0);
 	  }
       }
@@ -1592,13 +1592,13 @@ rust_language::emitchar (int ch, struct type *chtype,
   else if (ch == '\\' || ch == quoter)
     fprintf_filtered (stream, "\\%c", ch);
   else if (ch == '\n')
-    fputs_filtered ("\\n", stream);
+    gdb_puts ("\\n", stream);
   else if (ch == '\r')
-    fputs_filtered ("\\r", stream);
+    gdb_puts ("\\r", stream);
   else if (ch == '\t')
-    fputs_filtered ("\\t", stream);
+    gdb_puts ("\\t", stream);
   else if (ch == '\0')
-    fputs_filtered ("\\0", stream);
+    gdb_puts ("\\0", stream);
   else if (ch >= 32 && ch <= 127 && isprint (ch))
     fputc_filtered (ch, stream);
   else if (ch <= 255)
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 60a1967ff45..97454d8d684 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -178,9 +178,9 @@ class rust_language : public language_defn
   void printchar (int ch, struct type *chtype,
 		  struct ui_file *stream) const override
   {
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
     emitchar (ch, chtype, stream, '\'');
-    fputs_filtered ("'", stream);
+    gdb_puts ("'", stream);
   }
 
   /* See language.h.  */
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 3f9740f0dfe..97f6f4a6f80 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -522,7 +522,7 @@ s12z_print_ccw_info (struct gdbarch *gdbarch,
   struct value *v = value_of_register (reg, frame);
   const char *name = gdbarch_register_name (gdbarch, reg);
   uint32_t ccw = value_as_long (v);
-  fputs_filtered (name, file);
+  gdb_puts (name, file);
   size_t len = strlen (name);
   const int stop_1 = 15;
   const int stop_2 = 17;
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 830ebfea3a1..687cf0f5214 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -306,12 +306,12 @@ ser_base_read_error_fd (struct serial *scb, int close_fd)
 	  while ((newline = strstr (current, "\n")) != NULL)
 	    {
 	      *newline = '\0';
-	      fputs_unfiltered (current, gdb_stderr);
-	      fputs_unfiltered ("\n", gdb_stderr);
+	      gdb_puts (current, gdb_stderr);
+	      gdb_puts ("\n", gdb_stderr);
 	      current = newline + 1;
 	    }
 
-	  fputs_unfiltered (current, gdb_stderr);
+	  gdb_puts (current, gdb_stderr);
        }
     }
 }
diff --git a/gdb/serial.c b/gdb/serial.c
index 41ba753a4b8..347ab2e098f 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -81,10 +81,10 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
       fprintf_unfiltered (stream, "<Error: %s>", safe_strerror (errno));
       return;
     case SERIAL_EOF:
-      fputs_unfiltered ("<Eof>", stream);
+      gdb_puts ("<Eof>", stream);
       return;
     case SERIAL_BREAK:
-      fputs_unfiltered ("<Break>", stream);
+      gdb_puts ("<Break>", stream);
       return;
     default:
       if (serial_logbase == logbase_hex)
@@ -95,25 +95,25 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
 	switch (ch)
 	  {
 	  case '\\':
-	    fputs_unfiltered ("\\\\", stream);
+	    gdb_puts ("\\\\", stream);
 	    break;
 	  case '\b':
-	    fputs_unfiltered ("\\b", stream);
+	    gdb_puts ("\\b", stream);
 	    break;
 	  case '\f':
-	    fputs_unfiltered ("\\f", stream);
+	    gdb_puts ("\\f", stream);
 	    break;
 	  case '\n':
-	    fputs_unfiltered ("\\n", stream);
+	    gdb_puts ("\\n", stream);
 	    break;
 	  case '\r':
-	    fputs_unfiltered ("\\r", stream);
+	    gdb_puts ("\\r", stream);
 	    break;
 	  case '\t':
-	    fputs_unfiltered ("\\t", stream);
+	    gdb_puts ("\\t", stream);
 	    break;
 	  case '\v':
-	    fputs_unfiltered ("\\v", stream);
+	    gdb_puts ("\\v", stream);
 	    break;
 	  default:
 	    fprintf_unfiltered (stream,
@@ -131,8 +131,8 @@ serial_log_command (struct target_ops *self, const char *cmd)
 
   serial_current_type = 'c';
 
-  fputs_unfiltered ("\nc ", serial_logfp);
-  fputs_unfiltered (cmd, serial_logfp);
+  gdb_puts ("\nc ", serial_logfp);
+  gdb_puts (cmd, serial_logfp);
 
   /* Make sure that the log file is as up-to-date as possible,
      in case we are getting ready to dump core or something.  */
@@ -312,7 +312,7 @@ do_serial_close (struct serial *scb, int really_close)
 
   if (serial_logfp)
     {
-      fputs_unfiltered ("\nEnd of log\n", serial_logfp);
+      gdb_puts ("\nEnd of log\n", serial_logfp);
       serial_current_type = 0;
 
       /* XXX - What if serial_logfp == gdb_stdout or gdb_stderr?  */
diff --git a/gdb/source.c b/gdb/source.c
index f749dd64e3b..f8e9a5a2082 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -403,9 +403,9 @@ set_directories_command (const char *args,
 static void
 show_directories_1 (ui_file *file, char *ignore, int from_tty)
 {
-  fputs_filtered ("Source directories searched: ", file);
-  fputs_filtered (source_path.c_str (), file);
-  fputs_filtered ("\n", file);
+  gdb_puts ("Source directories searched: ", file);
+  gdb_puts (source_path.c_str (), file);
+  gdb_puts ("\n", file);
 }
 
 /* Handler for "show directories" command.  */
diff --git a/gdb/stack.c b/gdb/stack.c
index c7269e2ac32..39fb954a1e0 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -428,14 +428,14 @@ print_frame_arg (const frame_print_options &fp_opts,
 
   annotate_arg_emitter arg_emitter;
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
-  fputs_filtered (arg->sym->print_name (), &stb);
+  gdb_puts (arg->sym->print_name (), &stb);
   if (arg->entry_kind == print_entry_values_compact)
     {
       /* It is OK to provide invalid MI-like stream as with
 	 PRINT_ENTRY_VALUE_COMPACT we never use MI.  */
       stb.puts ("=");
 
-      fputs_filtered (arg->sym->print_name (), &stb);
+      gdb_puts (arg->sym->print_name (), &stb);
     }
   if (arg->entry_kind == print_entry_values_only
       || arg->entry_kind == print_entry_values_compact)
@@ -1366,7 +1366,7 @@ print_frame (const frame_print_options &fp_opts,
     annotate_frame_function_name ();
 
     string_file stb;
-    fputs_filtered (funname ? funname.get () : "??", &stb);
+    gdb_puts (funname ? funname.get () : "??", &stb);
     uiout->field_stream ("func", stb, function_name_style.style ());
     uiout->wrap_hint (3);
     annotate_frame_args ();
@@ -1549,11 +1549,11 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
     {
       printf_filtered (_("Stack frame at "));
     }
-  puts_filtered (paddress (gdbarch, get_frame_base (fi)));
+  gdb_puts (paddress (gdbarch, get_frame_base (fi)));
   printf_filtered (":\n");
   printf_filtered (" %s = ", pc_regname);
   if (frame_pc_p)
-    puts_filtered (paddress (gdbarch, get_frame_pc (fi)));
+    gdb_puts (paddress (gdbarch, get_frame_pc (fi)));
   else
     fputs_styled ("<unavailable>", metadata_style.style (), gdb_stdout);
 
@@ -1561,7 +1561,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
   if (funname)
     {
       printf_filtered (" in ");
-      puts_filtered (funname);
+      gdb_puts (funname);
     }
   gdb_stdout->wrap_here (3);
   if (sal.symtab)
@@ -1570,7 +1570,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
        styled_string (file_name_style.style (),
 		      symtab_to_filename_for_display (sal.symtab)),
        sal.line);
-  puts_filtered ("; ");
+  gdb_puts ("; ");
   gdb_stdout->wrap_here (4);
   printf_filtered ("saved %s = ", pc_regname);
 
@@ -1603,7 +1603,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
     }
 
   if (caller_pc_p)
-    puts_filtered (paddress (gdbarch, caller_pc));
+    gdb_puts (paddress (gdbarch, caller_pc));
   printf_filtered ("\n");
 
   if (calling_frame_info == NULL)
@@ -1616,25 +1616,25 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
 			 frame_stop_reason_string (fi));
     }
   else if (get_frame_type (fi) == TAILCALL_FRAME)
-    puts_filtered (" tail call frame");
+    gdb_puts (" tail call frame");
   else if (get_frame_type (fi) == INLINE_FRAME)
     printf_filtered (" inlined into frame %d",
 		     frame_relative_level (get_prev_frame (fi)));
   else
     {
       printf_filtered (" called by frame at ");
-      puts_filtered (paddress (gdbarch, get_frame_base (calling_frame_info)));
+      gdb_puts (paddress (gdbarch, get_frame_base (calling_frame_info)));
     }
   if (get_next_frame (fi) && calling_frame_info)
-    puts_filtered (",");
+    gdb_puts (",");
   gdb_stdout->wrap_here (3);
   if (get_next_frame (fi))
     {
       printf_filtered (" caller of frame at ");
-      puts_filtered (paddress (gdbarch, get_frame_base (get_next_frame (fi))));
+      gdb_puts (paddress (gdbarch, get_frame_base (get_next_frame (fi))));
     }
   if (get_next_frame (fi) || calling_frame_info)
-    puts_filtered ("\n");
+    gdb_puts ("\n");
 
   if (s)
     printf_filtered (" source language %s.\n",
@@ -1651,28 +1651,28 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
     else
       {
 	printf_filtered (" Arglist at ");
-	puts_filtered (paddress (gdbarch, arg_list));
+	gdb_puts (paddress (gdbarch, arg_list));
 	printf_filtered (",");
 
 	if (!gdbarch_frame_num_args_p (gdbarch))
 	  {
 	    numargs = -1;
-	    puts_filtered (" args: ");
+	    gdb_puts (" args: ");
 	  }
 	else
 	  {
 	    numargs = gdbarch_frame_num_args (gdbarch, fi);
 	    gdb_assert (numargs >= 0);
 	    if (numargs == 0)
-	      puts_filtered (" no args.");
+	      gdb_puts (" no args.");
 	    else if (numargs == 1)
-	      puts_filtered (" 1 arg: ");
+	      gdb_puts (" 1 arg: ");
 	    else
 	      printf_filtered (" %d args: ", numargs);
 	  }
 	print_frame_args (user_frame_print_options,
 			  func, fi, numargs, gdb_stdout);
-	puts_filtered ("\n");
+	gdb_puts ("\n");
       }
   }
   {
@@ -1684,7 +1684,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
     else
       {
 	printf_filtered (" Locals at ");
-	puts_filtered (paddress (gdbarch, arg_list));
+	gdb_puts (paddress (gdbarch, arg_list));
 	printf_filtered (",");
       }
   }
@@ -1719,13 +1719,13 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
 		  (value_contents_all (value).data (), sp_size, byte_order);
 
 		printf_filtered (" Previous frame's sp is ");
-		puts_filtered (paddress (gdbarch, sp));
+		gdb_puts (paddress (gdbarch, sp));
 		printf_filtered ("\n");
 	      }
 	    else if (VALUE_LVAL (value) == lval_memory)
 	      {
 		printf_filtered (" Previous frame's sp at ");
-		puts_filtered (paddress (gdbarch, value_address (value)));
+		gdb_puts (paddress (gdbarch, value_address (value)));
 		printf_filtered ("\n");
 	      }
 	    else if (VALUE_LVAL (value) == lval_register)
@@ -1762,18 +1762,18 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
 	  if (!optimized && !unavailable && lval == lval_memory)
 	    {
 	      if (count == 0)
-		puts_filtered (" Saved registers:\n ");
+		gdb_puts (" Saved registers:\n ");
 	      else
-		puts_filtered (",");
+		gdb_puts (",");
 	      gdb_stdout->wrap_here (1);
 	      printf_filtered (" %s at ",
 			       gdbarch_register_name (gdbarch, i));
-	      puts_filtered (paddress (gdbarch, addr));
+	      gdb_puts (paddress (gdbarch, addr));
 	      count++;
 	    }
 	}
     if (count || need_nl)
-      puts_filtered ("\n");
+      gdb_puts ("\n");
   }
 }
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 9bd4f48d0b0..f65e9e1cdf4 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3211,14 +3211,14 @@ list_overlays_command (const char *args, int from_tty)
 	      name = bfd_section_name (osect->the_bfd_section);
 
 	      printf_filtered ("Section %s, loaded at ", name);
-	      puts_filtered (paddress (gdbarch, lma));
-	      puts_filtered (" - ");
-	      puts_filtered (paddress (gdbarch, lma + size));
+	      gdb_puts (paddress (gdbarch, lma));
+	      gdb_puts (" - ");
+	      gdb_puts (paddress (gdbarch, lma + size));
 	      printf_filtered (", mapped at ");
-	      puts_filtered (paddress (gdbarch, vma));
-	      puts_filtered (" - ");
-	      puts_filtered (paddress (gdbarch, vma + size));
-	      puts_filtered ("\n");
+	      gdb_puts (paddress (gdbarch, vma));
+	      gdb_puts (" - ");
+	      gdb_puts (paddress (gdbarch, vma + size));
+	      gdb_puts ("\n");
 
 	      nmapped++;
 	    }
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index cd51f6645c5..29fb80b77f7 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -203,7 +203,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
 	 not try to respect copy relocations.  */
       CORE_ADDR addr = (msymbol->value.address
 			+ objfile->section_offsets[msymbol->section_index ()]);
-      fputs_filtered (paddress (gdbarch, addr), outfile);
+      gdb_puts (paddress (gdbarch, addr), outfile);
       fprintf_filtered (outfile, " %s", msymbol->linkage_name ());
       if (section)
 	{
@@ -220,7 +220,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
 	}
       if (msymbol->filename)
 	fprintf_filtered (outfile, "  %s", msymbol->filename);
-      fputs_filtered ("\n", outfile);
+      gdb_puts ("\n", outfile);
       index++;
     }
   if (objfile->per_bfd->minimal_symbol_count != index)
@@ -267,7 +267,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
       for (i = 0; i < len; i++)
 	{
 	  fprintf_filtered (outfile, " line %d at ", l->item[i].line);
-	  fputs_filtered (paddress (gdbarch, l->item[i].pc), outfile);
+	  gdb_puts (paddress (gdbarch, l->item[i].pc), outfile);
 	  if (l->item[i].is_stmt)
 	    fprintf_filtered (outfile, "\t(stmt)");
 	  fprintf_filtered (outfile, "\n");
@@ -295,9 +295,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 	     wants it.  */
 	  fprintf_filtered (outfile, ", %d syms/buckets in ",
 			    mdict_size (BLOCK_MULTIDICT (b)));
-	  fputs_filtered (paddress (gdbarch, BLOCK_START (b)), outfile);
+	  gdb_puts (paddress (gdbarch, BLOCK_START (b)), outfile);
 	  fprintf_filtered (outfile, "..");
-	  fputs_filtered (paddress (gdbarch, BLOCK_END (b)), outfile);
+	  gdb_puts (paddress (gdbarch, BLOCK_END (b)), outfile);
 	  if (BLOCK_FUNCTION (b))
 	    {
 	      fprintf_filtered (outfile, ", function %s",
@@ -510,8 +510,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
   if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
     {
       fprintf_filtered (outfile, "label %s at ", symbol->print_name ());
-      fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
-		      outfile);
+      gdb_puts (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
+		outfile);
       if (section)
 	fprintf_filtered (outfile, " section %s\n",
 			  bfd_section_name (section->the_bfd_section));
@@ -580,8 +580,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 
 	case LOC_STATIC:
 	  fprintf_filtered (outfile, "static at ");
-	  fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
-			  outfile);
+	  gdb_puts (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
+		    outfile);
 	  if (section)
 	    fprintf_filtered (outfile, " section %s",
 			      bfd_section_name (section->the_bfd_section));
@@ -621,8 +621,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 
 	case LOC_LABEL:
 	  fprintf_filtered (outfile, "label at ");
-	  fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
-			  outfile);
+	  gdb_puts (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
+		    outfile);
 	  if (section)
 	    fprintf_filtered (outfile, " section %s",
 			      bfd_section_name (section->the_bfd_section));
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a32e561ed77..dd0a864f91c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5065,7 +5065,7 @@ print_symbol_info (enum search_domain kind,
       if (SYMBOL_LINE (sym) != 0)
 	printf_filtered ("%d:\t", SYMBOL_LINE (sym));
       else
-	puts_filtered ("\t");
+	gdb_puts ("\t");
     }
 
   std::string str = symbol_to_info_string (sym, block, kind);
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index e7a509858a7..ee494d097e1 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -42,7 +42,7 @@
 /* Helper macro.  */
 
 #define target_debug_do_print(E)			\
-  fputs_unfiltered ((E), gdb_stdlog);
+  gdb_puts ((E), gdb_stdlog);
 
 #define target_debug_print_enum_target_object(X)	\
   target_debug_do_print (plongest (X))
@@ -180,7 +180,7 @@
 static void
 target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
 {
-  fputs_unfiltered (status->to_string ().c_str (), gdb_stdlog);
+  gdb_puts (status->to_string ().c_str (), gdb_stdlog);
 }
 
 \f
@@ -195,13 +195,13 @@ target_debug_print_target_wait_flags (target_wait_flags options)
 {
   std::string str = target_options_to_string (options);
 
-  fputs_unfiltered (str.c_str (), gdb_stdlog);
+  gdb_puts (str.c_str (), gdb_stdlog);
 }
 
 static void
 target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
 {
-  fputs_unfiltered ("{", gdb_stdlog);
+  gdb_puts ("{", gdb_stdlog);
 
   for (size_t i = 0; i < sigs.size (); i++)
     if (sigs[i] != 0)
@@ -209,7 +209,7 @@ target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
 	fprintf_unfiltered (gdb_stdlog, " %s",
 			    gdb_signal_to_name ((enum gdb_signal) i));
       }
-  fputs_unfiltered (" }", gdb_stdlog);
+  gdb_puts (" }", gdb_stdlog);
 }
 
 static void
@@ -221,14 +221,14 @@ target_debug_print_size_t (size_t size)
 static void
 target_debug_print_const_gdb_byte_vector_r (const gdb::byte_vector &vector)
 {
-  fputs_unfiltered ("{", gdb_stdlog);
+  gdb_puts ("{", gdb_stdlog);
 
   for (size_t i = 0; i < vector.size (); i++)
     {
       fprintf_unfiltered (gdb_stdlog, " %s",
 			  phex_nz (vector[i], 1));
     }
-  fputs_unfiltered (" }", gdb_stdlog);
+  gdb_puts (" }", gdb_stdlog);
 }
 
 static void
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 9636e3212bc..ef28d7cde43 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -370,7 +370,7 @@ debug_target::post_attach (int arg0)
   this->beneath ()->post_attach (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->post_attach (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -391,9 +391,9 @@ debug_target::detach (inferior *arg0, int arg1)
   this->beneath ()->detach (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->detach (", this->beneath ()->shortname ());
   target_debug_print_inferior_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -415,9 +415,9 @@ debug_target::disconnect (const char *arg0, int arg1)
   this->beneath ()->disconnect (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->disconnect (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -439,11 +439,11 @@ debug_target::resume (ptid_t arg0, int arg1, enum gdb_signal arg2)
   this->beneath ()->resume (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->resume (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_step (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_gdb_signal (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -463,7 +463,7 @@ debug_target::commit_resumed ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->commit_resumed (...)\n", this->beneath ()->shortname ());
   this->beneath ()->commit_resumed ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->commit_resumed (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 ptid_t
@@ -486,13 +486,13 @@ debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_fla
   result = this->beneath ()->wait (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->wait (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_target_waitstatus_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_target_wait_flags (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_ptid_t (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -514,9 +514,9 @@ debug_target::fetch_registers (struct regcache *arg0, int arg1)
   this->beneath ()->fetch_registers (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->fetch_registers (", this->beneath ()->shortname ());
   target_debug_print_struct_regcache_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -538,9 +538,9 @@ debug_target::store_registers (struct regcache *arg0, int arg1)
   this->beneath ()->store_registers (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->store_registers (", this->beneath ()->shortname ());
   target_debug_print_struct_regcache_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -562,7 +562,7 @@ debug_target::prepare_to_store (struct regcache *arg0)
   this->beneath ()->prepare_to_store (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->prepare_to_store (", this->beneath ()->shortname ());
   target_debug_print_struct_regcache_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -582,7 +582,7 @@ debug_target::files_info ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->files_info (...)\n", this->beneath ()->shortname ());
   this->beneath ()->files_info ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->files_info (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -605,11 +605,11 @@ debug_target::insert_breakpoint (struct gdbarch *arg0, struct bp_target_info *ar
   result = this->beneath ()->insert_breakpoint (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_breakpoint (", this->beneath ()->shortname ());
   target_debug_print_struct_gdbarch_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_bp_target_info_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -633,13 +633,13 @@ debug_target::remove_breakpoint (struct gdbarch *arg0, struct bp_target_info *ar
   result = this->beneath ()->remove_breakpoint (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_breakpoint (", this->beneath ()->shortname ());
   target_debug_print_struct_gdbarch_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_bp_target_info_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_remove_bp_reason (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -662,9 +662,9 @@ debug_target::stopped_by_sw_breakpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->stopped_by_sw_breakpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->stopped_by_sw_breakpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->stopped_by_sw_breakpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -687,9 +687,9 @@ debug_target::supports_stopped_by_sw_breakpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_stopped_by_sw_breakpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_stopped_by_sw_breakpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_stopped_by_sw_breakpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -712,9 +712,9 @@ debug_target::stopped_by_hw_breakpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->stopped_by_hw_breakpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->stopped_by_hw_breakpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->stopped_by_hw_breakpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -737,9 +737,9 @@ debug_target::supports_stopped_by_hw_breakpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_stopped_by_hw_breakpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_stopped_by_hw_breakpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_stopped_by_hw_breakpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -763,13 +763,13 @@ debug_target::can_use_hw_breakpoint (enum bptype arg0, int arg1, int arg2)
   result = this->beneath ()->can_use_hw_breakpoint (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_use_hw_breakpoint (", this->beneath ()->shortname ());
   target_debug_print_enum_bptype (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -792,9 +792,9 @@ debug_target::ranged_break_num_registers ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->ranged_break_num_registers (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->ranged_break_num_registers ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->ranged_break_num_registers (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -818,11 +818,11 @@ debug_target::insert_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info
   result = this->beneath ()->insert_hw_breakpoint (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_hw_breakpoint (", this->beneath ()->shortname ());
   target_debug_print_struct_gdbarch_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_bp_target_info_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -846,11 +846,11 @@ debug_target::remove_hw_breakpoint (struct gdbarch *arg0, struct bp_target_info
   result = this->beneath ()->remove_hw_breakpoint (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_hw_breakpoint (", this->beneath ()->shortname ());
   target_debug_print_struct_gdbarch_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_bp_target_info_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -874,15 +874,15 @@ debug_target::remove_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_typ
   result = this->beneath ()->remove_watchpoint (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_watchpoint (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_target_hw_bp_type (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_expression_p (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -906,15 +906,15 @@ debug_target::insert_watchpoint (CORE_ADDR arg0, int arg1, enum target_hw_bp_typ
   result = this->beneath ()->insert_watchpoint (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_watchpoint (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_target_hw_bp_type (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_expression_p (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -938,13 +938,13 @@ debug_target::insert_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum targe
   result = this->beneath ()->insert_mask_watchpoint (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_mask_watchpoint (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_target_hw_bp_type (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -968,13 +968,13 @@ debug_target::remove_mask_watchpoint (CORE_ADDR arg0, CORE_ADDR arg1, enum targe
   result = this->beneath ()->remove_mask_watchpoint (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_mask_watchpoint (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_target_hw_bp_type (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -997,9 +997,9 @@ debug_target::stopped_by_watchpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->stopped_by_watchpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->stopped_by_watchpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->stopped_by_watchpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1022,9 +1022,9 @@ debug_target::have_steppable_watchpoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->have_steppable_watchpoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->have_steppable_watchpoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->have_steppable_watchpoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1048,9 +1048,9 @@ debug_target::stopped_data_address (CORE_ADDR *arg0)
   result = this->beneath ()->stopped_data_address (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->stopped_data_address (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1074,13 +1074,13 @@ debug_target::watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int
   result = this->beneath ()->watchpoint_addr_within_range (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->watchpoint_addr_within_range (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1104,11 +1104,11 @@ debug_target::region_ok_for_hw_watchpoint (CORE_ADDR arg0, int arg1)
   result = this->beneath ()->region_ok_for_hw_watchpoint (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->region_ok_for_hw_watchpoint (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1132,15 +1132,15 @@ debug_target::can_accel_watchpoint_condition (CORE_ADDR arg0, int arg1, int arg2
   result = this->beneath ()->can_accel_watchpoint_condition (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_accel_watchpoint_condition (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_expression_p (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1164,11 +1164,11 @@ debug_target::masked_watch_num_registers (CORE_ADDR arg0, CORE_ADDR arg1)
   result = this->beneath ()->masked_watch_num_registers (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->masked_watch_num_registers (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1191,9 +1191,9 @@ debug_target::can_do_single_step ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_do_single_step (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_do_single_step ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_do_single_step (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1216,9 +1216,9 @@ debug_target::supports_terminal_ours ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_terminal_ours (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_terminal_ours ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_terminal_ours (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1239,7 +1239,7 @@ debug_target::terminal_init ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_init (...)\n", this->beneath ()->shortname ());
   this->beneath ()->terminal_init ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_init (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1259,7 +1259,7 @@ debug_target::terminal_inferior ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_inferior (...)\n", this->beneath ()->shortname ());
   this->beneath ()->terminal_inferior ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_inferior (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1279,7 +1279,7 @@ debug_target::terminal_save_inferior ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_save_inferior (...)\n", this->beneath ()->shortname ());
   this->beneath ()->terminal_save_inferior ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_save_inferior (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1299,7 +1299,7 @@ debug_target::terminal_ours_for_output ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_ours_for_output (...)\n", this->beneath ()->shortname ());
   this->beneath ()->terminal_ours_for_output ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_ours_for_output (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1319,7 +1319,7 @@ debug_target::terminal_ours ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_ours (...)\n", this->beneath ()->shortname ());
   this->beneath ()->terminal_ours ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_ours (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1341,9 +1341,9 @@ debug_target::terminal_info (const char *arg0, int arg1)
   this->beneath ()->terminal_info (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_info (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1364,7 +1364,7 @@ debug_target::kill ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->kill (...)\n", this->beneath ()->shortname ());
   this->beneath ()->kill ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->kill (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1386,9 +1386,9 @@ debug_target::load (const char *arg0, int arg1)
   this->beneath ()->load (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->load (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -1411,9 +1411,9 @@ debug_target::insert_fork_catchpoint (int arg0)
   result = this->beneath ()->insert_fork_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_fork_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1437,9 +1437,9 @@ debug_target::remove_fork_catchpoint (int arg0)
   result = this->beneath ()->remove_fork_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_fork_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1463,9 +1463,9 @@ debug_target::insert_vfork_catchpoint (int arg0)
   result = this->beneath ()->insert_vfork_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_vfork_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1489,9 +1489,9 @@ debug_target::remove_vfork_catchpoint (int arg0)
   result = this->beneath ()->remove_vfork_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_vfork_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1514,15 +1514,15 @@ debug_target::follow_fork (inferior *arg0, ptid_t arg1, target_waitkind arg2, bo
   this->beneath ()->follow_fork (arg0, arg1, arg2, arg3, arg4);
   fprintf_unfiltered (gdb_stdlog, "<- %s->follow_fork (", this->beneath ()->shortname ());
   target_debug_print_inferior_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ptid_t (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_target_waitkind (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_bool (arg3);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_bool (arg4);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -1545,9 +1545,9 @@ debug_target::insert_exec_catchpoint (int arg0)
   result = this->beneath ()->insert_exec_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insert_exec_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1571,9 +1571,9 @@ debug_target::remove_exec_catchpoint (int arg0)
   result = this->beneath ()->remove_exec_catchpoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->remove_exec_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1595,11 +1595,11 @@ debug_target::follow_exec (inferior *arg0, ptid_t arg1, const char *arg2)
   this->beneath ()->follow_exec (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->follow_exec (", this->beneath ()->shortname ());
   target_debug_print_inferior_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ptid_t (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_char_p (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -1622,15 +1622,15 @@ debug_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_
   result = this->beneath ()->set_syscall_catchpoint (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_syscall_catchpoint (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_bool (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_array_view_const_int (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1652,7 +1652,7 @@ debug_target::mourn_inferior ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->mourn_inferior (...)\n", this->beneath ()->shortname ());
   this->beneath ()->mourn_inferior ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->mourn_inferior (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1673,7 +1673,7 @@ debug_target::pass_signals (gdb::array_view<const unsigned char> arg0)
   this->beneath ()->pass_signals (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->pass_signals (", this->beneath ()->shortname ());
   target_debug_print_signals (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1694,7 +1694,7 @@ debug_target::program_signals (gdb::array_view<const unsigned char> arg0)
   this->beneath ()->program_signals (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->program_signals (", this->beneath ()->shortname ());
   target_debug_print_signals (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -1717,9 +1717,9 @@ debug_target::thread_alive (ptid_t arg0)
   result = this->beneath ()->thread_alive (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_alive (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1740,7 +1740,7 @@ debug_target::update_thread_list ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->update_thread_list (...)\n", this->beneath ()->shortname ());
   this->beneath ()->update_thread_list ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->update_thread_list (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 std::string
@@ -1763,9 +1763,9 @@ debug_target::pid_to_str (ptid_t arg0)
   result = this->beneath ()->pid_to_str (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->pid_to_str (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_std_string (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1789,9 +1789,9 @@ debug_target::extra_thread_info (thread_info *arg0)
   result = this->beneath ()->extra_thread_info (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->extra_thread_info (", this->beneath ()->shortname ());
   target_debug_print_thread_info_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_char_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1815,9 +1815,9 @@ debug_target::thread_name (thread_info *arg0)
   result = this->beneath ()->thread_name (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_name (", this->beneath ()->shortname ());
   target_debug_print_thread_info_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_char_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1841,13 +1841,13 @@ debug_target::thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, infe
   result = this->beneath ()->thread_handle_to_thread_info (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_handle_to_thread_info (", this->beneath ()->shortname ());
   target_debug_print_const_gdb_byte_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_inferior_p (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_thread_info_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1871,9 +1871,9 @@ debug_target::thread_info_to_thread_handle (struct thread_info *arg0)
   result = this->beneath ()->thread_info_to_thread_handle (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_info_to_thread_handle (", this->beneath ()->shortname ());
   target_debug_print_struct_thread_info_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_gdb_byte_vector (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -1895,7 +1895,7 @@ debug_target::stop (ptid_t arg0)
   this->beneath ()->stop (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->stop (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1915,7 +1915,7 @@ debug_target::interrupt ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->interrupt (...)\n", this->beneath ()->shortname ());
   this->beneath ()->interrupt ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->interrupt (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1936,7 +1936,7 @@ debug_target::pass_ctrlc ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->pass_ctrlc (...)\n", this->beneath ()->shortname ());
   this->beneath ()->pass_ctrlc ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->pass_ctrlc (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -1958,9 +1958,9 @@ debug_target::rcmd (const char *arg0, struct ui_file *arg1)
   this->beneath ()->rcmd (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->rcmd (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_ui_file_p (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 char *
@@ -1983,9 +1983,9 @@ debug_target::pid_to_exec_file (int arg0)
   result = this->beneath ()->pid_to_exec_file (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->pid_to_exec_file (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_char_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2007,7 +2007,7 @@ debug_target::log_command (const char *arg0)
   this->beneath ()->log_command (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->log_command (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 const target_section_table *
@@ -2029,9 +2029,9 @@ debug_target::get_section_table ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_section_table (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_section_table ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_section_table (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_target_section_table_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2054,9 +2054,9 @@ debug_target::get_thread_control_capabilities ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_thread_control_capabilities (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_thread_control_capabilities ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_thread_control_capabilities (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_thread_control_capabilities (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2079,9 +2079,9 @@ debug_target::attach_no_wait ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->attach_no_wait (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->attach_no_wait ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->attach_no_wait (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2104,9 +2104,9 @@ debug_target::can_async_p ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_async_p (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_async_p ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_async_p (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2129,9 +2129,9 @@ debug_target::is_async_p ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->is_async_p (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->is_async_p ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->is_async_p (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2154,7 +2154,7 @@ debug_target::async (int arg0)
   this->beneath ()->async (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->async (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -2176,9 +2176,9 @@ debug_target::async_wait_fd ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->async_wait_fd (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->async_wait_fd ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->async_wait_fd (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2201,9 +2201,9 @@ debug_target::has_pending_events ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->has_pending_events (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->has_pending_events ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->has_pending_events (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2225,7 +2225,7 @@ debug_target::thread_events (int arg0)
   this->beneath ()->thread_events (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_events (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -2247,9 +2247,9 @@ debug_target::supports_non_stop ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_non_stop (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_non_stop ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_non_stop (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2272,9 +2272,9 @@ debug_target::always_non_stop_p ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->always_non_stop_p (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->always_non_stop_p ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->always_non_stop_p (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2298,11 +2298,11 @@ debug_target::find_memory_regions (find_memory_region_ftype arg0, void *arg1)
   result = this->beneath ()->find_memory_regions (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->find_memory_regions (", this->beneath ()->shortname ());
   target_debug_print_find_memory_region_ftype (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_void_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2326,11 +2326,11 @@ debug_target::make_corefile_notes (bfd *arg0, int *arg1)
   result = this->beneath ()->make_corefile_notes (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->make_corefile_notes (", this->beneath ()->shortname ());
   target_debug_print_bfd_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_gdb_unique_xmalloc_ptr_char (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2354,11 +2354,11 @@ debug_target::get_bookmark (const char *arg0, int arg1)
   result = this->beneath ()->get_bookmark (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_bookmark (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_gdb_byte_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2381,9 +2381,9 @@ debug_target::goto_bookmark (const gdb_byte *arg0, int arg1)
   this->beneath ()->goto_bookmark (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->goto_bookmark (", this->beneath ()->shortname ());
   target_debug_print_const_gdb_byte_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 CORE_ADDR
@@ -2406,13 +2406,13 @@ debug_target::get_thread_local_address (ptid_t arg0, CORE_ADDR arg1, CORE_ADDR a
   result = this->beneath ()->get_thread_local_address (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_thread_local_address (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_CORE_ADDR (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2436,21 +2436,21 @@ debug_target::xfer_partial (enum target_object arg0, const char *arg1, gdb_byte
   result = this->beneath ()->xfer_partial (arg0, arg1, arg2, arg3, arg4, arg5, arg6);
   fprintf_unfiltered (gdb_stdlog, "<- %s->xfer_partial (", this->beneath ()->shortname ());
   target_debug_print_enum_target_object (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_char_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_byte_p (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_gdb_byte_p (arg3);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg4);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg5);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST_p (arg6);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_enum_target_xfer_status (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2473,9 +2473,9 @@ debug_target::get_memory_xfer_limit ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_memory_xfer_limit (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_memory_xfer_limit ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_memory_xfer_limit (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_ULONGEST (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2498,9 +2498,9 @@ debug_target::memory_map ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->memory_map (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->memory_map ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->memory_map (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_std_vector_mem_region (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2523,9 +2523,9 @@ debug_target::flash_erase (ULONGEST arg0, LONGEST arg1)
   this->beneath ()->flash_erase (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->flash_erase (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_LONGEST (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -2546,7 +2546,7 @@ debug_target::flash_done ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->flash_done (...)\n", this->beneath ()->shortname ());
   this->beneath ()->flash_done ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->flash_done (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 const struct target_desc *
@@ -2568,9 +2568,9 @@ debug_target::read_description ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->read_description (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->read_description ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->read_description (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_struct_target_desc_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2594,11 +2594,11 @@ debug_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
   result = this->beneath ()->get_ada_task_ptid (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_ada_task_ptid (", this->beneath ()->shortname ());
   target_debug_print_long (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_ptid_t (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2622,15 +2622,15 @@ debug_target::auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE
   result = this->beneath ()->auxv_parse (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->auxv_parse (", this->beneath ()->shortname ());
   target_debug_print_gdb_byte_pp (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_byte_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR_p (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR_p (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2654,17 +2654,17 @@ debug_target::search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2
   result = this->beneath ()->search_memory (arg0, arg1, arg2, arg3, arg4);
   fprintf_unfiltered (gdb_stdlog, "<- %s->search_memory (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_gdb_byte_p (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg3);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR_p (arg4);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2687,9 +2687,9 @@ debug_target::can_execute_reverse ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_execute_reverse (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_execute_reverse ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_execute_reverse (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2712,9 +2712,9 @@ debug_target::execution_direction ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->execution_direction (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->execution_direction ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->execution_direction (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_enum_exec_direction_kind (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2737,9 +2737,9 @@ debug_target::supports_multi_process ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_multi_process (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_multi_process ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_multi_process (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2762,9 +2762,9 @@ debug_target::supports_enable_disable_tracepoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_enable_disable_tracepoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_enable_disable_tracepoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_enable_disable_tracepoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2787,9 +2787,9 @@ debug_target::supports_disable_randomization ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_disable_randomization (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_disable_randomization ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_disable_randomization (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2812,9 +2812,9 @@ debug_target::supports_string_tracing ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_string_tracing (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_string_tracing ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_string_tracing (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2837,9 +2837,9 @@ debug_target::supports_evaluation_of_breakpoint_conditions ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_evaluation_of_breakpoint_conditions (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_evaluation_of_breakpoint_conditions ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_evaluation_of_breakpoint_conditions (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2862,9 +2862,9 @@ debug_target::supports_dumpcore ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_dumpcore (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_dumpcore ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_dumpcore (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2886,7 +2886,7 @@ debug_target::dumpcore (const char *arg0)
   this->beneath ()->dumpcore (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->dumpcore (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -2908,9 +2908,9 @@ debug_target::can_run_breakpoint_commands ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_run_breakpoint_commands (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_run_breakpoint_commands ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_run_breakpoint_commands (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2934,9 +2934,9 @@ debug_target::thread_architecture (ptid_t arg0)
   result = this->beneath ()->thread_architecture (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_architecture (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_struct_gdbarch_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2960,9 +2960,9 @@ debug_target::thread_address_space (ptid_t arg0)
   result = this->beneath ()->thread_address_space (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->thread_address_space (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_struct_address_space_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -2985,9 +2985,9 @@ debug_target::filesystem_is_local ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->filesystem_is_local (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->filesystem_is_local ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->filesystem_is_local (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3009,7 +3009,7 @@ debug_target::trace_init ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->trace_init (...)\n", this->beneath ()->shortname ());
   this->beneath ()->trace_init ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->trace_init (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3031,7 +3031,7 @@ debug_target::download_tracepoint (struct bp_location *arg0)
   this->beneath ()->download_tracepoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->download_tracepoint (", this->beneath ()->shortname ());
   target_debug_print_struct_bp_location_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -3053,9 +3053,9 @@ debug_target::can_download_tracepoint ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_download_tracepoint (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_download_tracepoint ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_download_tracepoint (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3078,7 +3078,7 @@ debug_target::download_trace_state_variable (const trace_state_variable &arg0)
   this->beneath ()->download_trace_state_variable (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->download_trace_state_variable (", this->beneath ()->shortname ());
   target_debug_print_const_trace_state_variable_r (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3100,7 +3100,7 @@ debug_target::enable_tracepoint (struct bp_location *arg0)
   this->beneath ()->enable_tracepoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->enable_tracepoint (", this->beneath ()->shortname ());
   target_debug_print_struct_bp_location_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3122,7 +3122,7 @@ debug_target::disable_tracepoint (struct bp_location *arg0)
   this->beneath ()->disable_tracepoint (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->disable_tracepoint (", this->beneath ()->shortname ());
   target_debug_print_struct_bp_location_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3143,7 +3143,7 @@ debug_target::trace_set_readonly_regions ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->trace_set_readonly_regions (...)\n", this->beneath ()->shortname ());
   this->beneath ()->trace_set_readonly_regions ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->trace_set_readonly_regions (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3164,7 +3164,7 @@ debug_target::trace_start ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->trace_start (...)\n", this->beneath ()->shortname ());
   this->beneath ()->trace_start ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->trace_start (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -3187,9 +3187,9 @@ debug_target::get_trace_status (struct trace_status *arg0)
   result = this->beneath ()->get_trace_status (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_trace_status (", this->beneath ()->shortname ());
   target_debug_print_struct_trace_status_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3212,9 +3212,9 @@ debug_target::get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp
   this->beneath ()->get_tracepoint_status (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_tracepoint_status (", this->beneath ()->shortname ());
   target_debug_print_struct_breakpoint_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_uploaded_tp_p (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3235,7 +3235,7 @@ debug_target::trace_stop ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->trace_stop (...)\n", this->beneath ()->shortname ());
   this->beneath ()->trace_stop ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->trace_stop (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 int
@@ -3258,17 +3258,17 @@ debug_target::trace_find (enum trace_find_type arg0, int arg1, CORE_ADDR arg2, C
   result = this->beneath ()->trace_find (arg0, arg1, arg2, arg3, arg4);
   fprintf_unfiltered (gdb_stdlog, "<- %s->trace_find (", this->beneath ()->shortname ());
   target_debug_print_enum_trace_find_type (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg3);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int_p (arg4);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3292,11 +3292,11 @@ debug_target::get_trace_state_variable_value (int arg0, LONGEST *arg1)
   result = this->beneath ()->get_trace_state_variable_value (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_trace_state_variable_value (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_LONGEST_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3320,9 +3320,9 @@ debug_target::save_trace_data (const char *arg0)
   result = this->beneath ()->save_trace_data (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->save_trace_data (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3346,9 +3346,9 @@ debug_target::upload_tracepoints (struct uploaded_tp **arg0)
   result = this->beneath ()->upload_tracepoints (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->upload_tracepoints (", this->beneath ()->shortname ());
   target_debug_print_struct_uploaded_tp_pp (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3372,9 +3372,9 @@ debug_target::upload_trace_state_variables (struct uploaded_tsv **arg0)
   result = this->beneath ()->upload_trace_state_variables (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->upload_trace_state_variables (", this->beneath ()->shortname ());
   target_debug_print_struct_uploaded_tsv_pp (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3398,13 +3398,13 @@ debug_target::get_raw_trace_data (gdb_byte *arg0, ULONGEST arg1, LONGEST arg2)
   result = this->beneath ()->get_raw_trace_data (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_raw_trace_data (", this->beneath ()->shortname ());
   target_debug_print_gdb_byte_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_LONGEST (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_LONGEST (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3427,9 +3427,9 @@ debug_target::get_min_fast_tracepoint_insn_len ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_min_fast_tracepoint_insn_len (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_min_fast_tracepoint_insn_len ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_min_fast_tracepoint_insn_len (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3451,7 +3451,7 @@ debug_target::set_disconnected_tracing (int arg0)
   this->beneath ()->set_disconnected_tracing (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_disconnected_tracing (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3472,7 +3472,7 @@ debug_target::set_circular_trace_buffer (int arg0)
   this->beneath ()->set_circular_trace_buffer (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_circular_trace_buffer (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3493,7 +3493,7 @@ debug_target::set_trace_buffer_size (LONGEST arg0)
   this->beneath ()->set_trace_buffer_size (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_trace_buffer_size (", this->beneath ()->shortname ());
   target_debug_print_LONGEST (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -3516,13 +3516,13 @@ debug_target::set_trace_notes (const char *arg0, const char *arg1, const char *a
   result = this->beneath ()->set_trace_notes (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_trace_notes (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_char_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_char_p (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3546,9 +3546,9 @@ debug_target::core_of_thread (ptid_t arg0)
   result = this->beneath ()->core_of_thread (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->core_of_thread (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3572,13 +3572,13 @@ debug_target::verify_memory (const gdb_byte *arg0, CORE_ADDR arg1, ULONGEST arg2
   result = this->beneath ()->verify_memory (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->verify_memory (", this->beneath ()->shortname ());
   target_debug_print_const_gdb_byte_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_int (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3602,11 +3602,11 @@ debug_target::get_tib_address (ptid_t arg0, CORE_ADDR *arg1)
   result = this->beneath ()->get_tib_address (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_tib_address (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_CORE_ADDR_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3627,7 +3627,7 @@ debug_target::set_permissions ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->set_permissions (...)\n", this->beneath ()->shortname ());
   this->beneath ()->set_permissions ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->set_permissions (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -3650,11 +3650,11 @@ debug_target::static_tracepoint_marker_at (CORE_ADDR arg0, static_tracepoint_mar
   result = this->beneath ()->static_tracepoint_marker_at (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->static_tracepoint_marker_at (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_static_tracepoint_marker_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3678,9 +3678,9 @@ debug_target::static_tracepoint_markers_by_strid (const char *arg0)
   result = this->beneath ()->static_tracepoint_markers_by_strid (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->static_tracepoint_markers_by_strid (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_std_vector_static_tracepoint_marker (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3703,9 +3703,9 @@ debug_target::traceframe_info ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->traceframe_info (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->traceframe_info ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->traceframe_info (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_traceframe_info_up (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3729,9 +3729,9 @@ debug_target::use_agent (bool arg0)
   result = this->beneath ()->use_agent (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->use_agent (", this->beneath ()->shortname ());
   target_debug_print_bool (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3754,9 +3754,9 @@ debug_target::can_use_agent ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->can_use_agent (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->can_use_agent ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->can_use_agent (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3780,11 +3780,11 @@ debug_target::enable_btrace (ptid_t arg0, const struct btrace_config *arg1)
   result = this->beneath ()->enable_btrace (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->enable_btrace (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_struct_btrace_config_p (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_struct_btrace_target_info_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3807,7 +3807,7 @@ debug_target::disable_btrace (struct btrace_target_info *arg0)
   this->beneath ()->disable_btrace (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->disable_btrace (", this->beneath ()->shortname ());
   target_debug_print_struct_btrace_target_info_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3829,7 +3829,7 @@ debug_target::teardown_btrace (struct btrace_target_info *arg0)
   this->beneath ()->teardown_btrace (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->teardown_btrace (", this->beneath ()->shortname ());
   target_debug_print_struct_btrace_target_info_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 enum btrace_error
@@ -3852,13 +3852,13 @@ debug_target::read_btrace (struct btrace_data *arg0, struct btrace_target_info *
   result = this->beneath ()->read_btrace (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->read_btrace (", this->beneath ()->shortname ());
   target_debug_print_struct_btrace_data_p (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_struct_btrace_target_info_p (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_enum_btrace_read_type (arg2);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_enum_btrace_error (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3882,9 +3882,9 @@ debug_target::btrace_conf (const struct btrace_target_info *arg0)
   result = this->beneath ()->btrace_conf (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->btrace_conf (", this->beneath ()->shortname ());
   target_debug_print_const_struct_btrace_target_info_p (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_struct_btrace_config_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3908,9 +3908,9 @@ debug_target::record_method (ptid_t arg0)
   result = this->beneath ()->record_method (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->record_method (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_enum_record_method (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -3931,7 +3931,7 @@ debug_target::stop_recording ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->stop_recording (...)\n", this->beneath ()->shortname ());
   this->beneath ()->stop_recording ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->stop_recording (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3951,7 +3951,7 @@ debug_target::info_record ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->info_record (...)\n", this->beneath ()->shortname ());
   this->beneath ()->info_record ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->info_record (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -3973,7 +3973,7 @@ debug_target::save_record (const char *arg0)
   this->beneath ()->save_record (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->save_record (", this->beneath ()->shortname ());
   target_debug_print_const_char_p (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -3995,9 +3995,9 @@ debug_target::supports_delete_record ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_delete_record (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_delete_record ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_delete_record (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4019,7 +4019,7 @@ debug_target::delete_record ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->delete_record (...)\n", this->beneath ()->shortname ());
   this->beneath ()->delete_record ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->delete_record (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -4042,9 +4042,9 @@ debug_target::record_is_replaying (ptid_t arg0)
   result = this->beneath ()->record_is_replaying (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->record_is_replaying (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4068,11 +4068,11 @@ debug_target::record_will_replay (ptid_t arg0, int arg1)
   result = this->beneath ()->record_will_replay (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->record_will_replay (", this->beneath ()->shortname ());
   target_debug_print_ptid_t (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4093,7 +4093,7 @@ debug_target::record_stop_replaying ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->record_stop_replaying (...)\n", this->beneath ()->shortname ());
   this->beneath ()->record_stop_replaying ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->record_stop_replaying (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4114,7 +4114,7 @@ debug_target::goto_record_begin ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->goto_record_begin (...)\n", this->beneath ()->shortname ());
   this->beneath ()->goto_record_begin ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->goto_record_begin (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4135,7 +4135,7 @@ debug_target::goto_record_end ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->goto_record_end (...)\n", this->beneath ()->shortname ());
   this->beneath ()->goto_record_end ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->goto_record_end (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4157,7 +4157,7 @@ debug_target::goto_record (ULONGEST arg0)
   this->beneath ()->goto_record (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->goto_record (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4179,9 +4179,9 @@ debug_target::insn_history (int arg0, gdb_disassembly_flags arg1)
   this->beneath ()->insn_history (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insn_history (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_disassembly_flags (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4203,11 +4203,11 @@ debug_target::insn_history_from (ULONGEST arg0, int arg1, gdb_disassembly_flags
   this->beneath ()->insn_history_from (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insn_history_from (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_disassembly_flags (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4229,11 +4229,11 @@ debug_target::insn_history_range (ULONGEST arg0, ULONGEST arg1, gdb_disassembly_
   this->beneath ()->insn_history_range (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->insn_history_range (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_disassembly_flags (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4255,9 +4255,9 @@ debug_target::call_history (int arg0, record_print_flags arg1)
   this->beneath ()->call_history (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->call_history (", this->beneath ()->shortname ());
   target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_record_print_flags (arg1);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4279,11 +4279,11 @@ debug_target::call_history_from (ULONGEST arg0, int arg1, record_print_flags arg
   this->beneath ()->call_history_from (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->call_history_from (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_record_print_flags (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4305,11 +4305,11 @@ debug_target::call_history_range (ULONGEST arg0, ULONGEST arg1, record_print_fla
   this->beneath ()->call_history_range (arg0, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->call_history_range (", this->beneath ()->shortname ());
   target_debug_print_ULONGEST (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_record_print_flags (arg2);
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -4331,9 +4331,9 @@ debug_target::augmented_libraries_svr4_read ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->augmented_libraries_svr4_read (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->augmented_libraries_svr4_read ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->augmented_libraries_svr4_read (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4356,9 +4356,9 @@ debug_target::get_unwinder ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_unwinder (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_unwinder ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_unwinder (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_struct_frame_unwind_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4381,9 +4381,9 @@ debug_target::get_tailcall_unwinder ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->get_tailcall_unwinder (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->get_tailcall_unwinder ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->get_tailcall_unwinder (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_const_struct_frame_unwind_p (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4404,7 +4404,7 @@ debug_target::prepare_to_generate_core ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->prepare_to_generate_core (...)\n", this->beneath ()->shortname ());
   this->beneath ()->prepare_to_generate_core ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->prepare_to_generate_core (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 void
@@ -4424,7 +4424,7 @@ debug_target::done_generating_core ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->done_generating_core (...)\n", this->beneath ()->shortname ());
   this->beneath ()->done_generating_core ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->done_generating_core (", this->beneath ()->shortname ());
-  fputs_unfiltered (")\n", gdb_stdlog);
+  gdb_puts (")\n", gdb_stdlog);
 }
 
 bool
@@ -4446,9 +4446,9 @@ debug_target::supports_memory_tagging ()
   fprintf_unfiltered (gdb_stdlog, "-> %s->supports_memory_tagging (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->supports_memory_tagging ();
   fprintf_unfiltered (gdb_stdlog, "<- %s->supports_memory_tagging (", this->beneath ()->shortname ());
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4472,15 +4472,15 @@ debug_target::fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2
   result = this->beneath ()->fetch_memtags (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->fetch_memtags (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_size_t (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_gdb_byte_vector_r (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
@@ -4504,15 +4504,15 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector
   result = this->beneath ()->store_memtags (arg0, arg1, arg2, arg3);
   fprintf_unfiltered (gdb_stdlog, "<- %s->store_memtags (", this->beneath ()->shortname ());
   target_debug_print_CORE_ADDR (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_size_t (arg1);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_const_gdb_byte_vector_r (arg2);
-  fputs_unfiltered (", ", gdb_stdlog);
+  gdb_puts (", ", gdb_stdlog);
   target_debug_print_int (arg3);
-  fputs_unfiltered (") = ", gdb_stdlog);
+  gdb_puts (") = ", gdb_stdlog);
   target_debug_print_bool (result);
-  fputs_unfiltered ("\n", gdb_stdlog);
+  gdb_puts ("\n", gdb_stdlog);
   return result;
 }
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 4c187754c65..d5e07fcfad1 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1858,7 +1858,7 @@ maint_print_xml_tdesc_cmd (const char *args, int from_tty)
   std::string buf;
   print_xml_feature v (&buf);
   tdesc->accept (v);
-  puts_filtered (buf.c_str ());
+  gdb_puts (buf.c_str ());
 }
 
 namespace selftests {
diff --git a/gdb/target.c b/gdb/target.c
index 4a40ce3a720..b53e5b6098e 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1768,7 +1768,7 @@ target_xfer_partial (struct target_ops *ops,
 	{
 	  int i;
 
-	  fputs_unfiltered (", bytes =", gdb_stdlog);
+	  gdb_puts (", bytes =", gdb_stdlog);
 	  for (i = 0; i < *xfered_len; i++)
 	    {
 	      if ((((intptr_t) &(myaddr[i])) & 0xf) == 0)
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index cef9190c3e1..eb98e0f5683 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -471,7 +471,7 @@ tui_layout_window::replace_window (const char *name, const char *new_window)
 void
 tui_layout_window::specification (ui_file *output, int depth)
 {
-  fputs_unfiltered (get_name (), output);
+  gdb_puts (get_name (), output);
 }
 
 /* See tui-layout.h.  */
@@ -806,23 +806,23 @@ void
 tui_layout_split::specification (ui_file *output, int depth)
 {
   if (depth > 0)
-    fputs_unfiltered ("{", output);
+    gdb_puts ("{", output);
 
   if (!m_vertical)
-    fputs_unfiltered ("-horizontal ", output);
+    gdb_puts ("-horizontal ", output);
 
   bool first = true;
   for (auto &item : m_splits)
     {
       if (!first)
-	fputs_unfiltered (" ", output);
+	gdb_puts (" ", output);
       first = false;
       item.layout->specification (output, depth + 1);
       fprintf_unfiltered (output, " %d", item.weight);
     }
 
   if (depth > 0)
-    fputs_unfiltered ("}", output);
+    gdb_puts ("}", output);
 }
 
 /* Destroy the layout associated with SELF.  */
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 158e6d91b3f..edb06b133b3 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -107,14 +107,14 @@ print_offset_data::maybe_print_hole (struct ui_file *stream,
 	{
 	  fprintf_styled (stream, highlight_style.style (),
 			  "/* XXX %2u-bit %-7s    */", hole_bit, for_what);
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	}
 
       if (hole_byte > 0)
 	{
 	  fprintf_styled (stream, highlight_style.style (),
 			  "/* XXX %2u-byte %-7s   */", hole_byte, for_what);
-	  fputs_filtered ("\n", stream);
+	  gdb_puts ("\n", stream);
 	}
     }
 }
@@ -187,7 +187,7 @@ print_offset_data::finish (struct type *type, int level,
   unsigned int bitpos = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
   maybe_print_hole (stream, bitpos, "padding");
 
-  fputs_filtered ("\n", stream);
+  gdb_puts ("\n", stream);
   print_spaces_filtered (level + 4 + print_offset_data::indentation, stream);
   fprintf_filtered (stream, "/* total size (bytes): %4s */\n",
 		    pulongest (TYPE_LENGTH (type)));
@@ -633,7 +633,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 	}
       if (i < len)
 	{
-	  fputs_filtered (type->field (i).name (), stream);
+	  gdb_puts (type->field (i).name (), stream);
 	}
       else
 	{
diff --git a/gdb/utils.c b/gdb/utils.c
index 4a3d5397bc7..b07852bcc74 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -150,7 +150,7 @@ vwarning (const char *string, va_list args)
 	gdb_stdout->wrap_here (0);	/* Force out any buffered output.  */
       gdb_flush (gdb_stdout);
       if (warning_pre_print)
-	fputs_unfiltered (warning_pre_print, gdb_stderr);
+	gdb_puts (warning_pre_print, gdb_stderr);
       gdb_vprintf (gdb_stderr, string, args);
       fprintf_unfiltered (gdb_stderr, "\n");
     }
@@ -180,7 +180,7 @@ abort_with_message (const char *msg)
   if (current_ui == NULL)
     fputs (msg, stderr);
   else
-    fputs_unfiltered (msg, gdb_stderr);
+    gdb_puts (msg, gdb_stderr);
 
   abort ();		/* ARI: abort */
 }
@@ -404,11 +404,11 @@ internal_vproblem (struct internal_problem *problem,
   else
     internal_error (__FILE__, __LINE__, _("bad switch"));
 
-  fputs_unfiltered (_("\nThis is a bug, please report it."), gdb_stderr);
+  gdb_puts (_("\nThis is a bug, please report it."), gdb_stderr);
   if (REPORT_BUGS_TO[0])
     fprintf_unfiltered (gdb_stderr, _("  For instructions, see:\n%s."),
 			REPORT_BUGS_TO);
-  fputs_unfiltered ("\n\n", gdb_stderr);
+  gdb_puts ("\n\n", gdb_stderr);
 
   if (problem->should_dump_core == internal_problem_ask)
     {
@@ -1156,7 +1156,7 @@ static bool pagination_disabled_for_command;
 
 /* Buffer and start column of buffered text, for doing smarter word-
    wrapping.  When someone calls wrap_here(), we start buffering output
-   that comes through fputs_filtered().  If we see a newline, we just
+   that comes through gdb_puts().  If we see a newline, we just
    spit it out and forget about the wrap_here().  If we see another
    wrap_here(), we spit it out and remember the newer one.  If we see
    the end of the line, we spit out a newline, the indent, and then
@@ -1521,13 +1521,13 @@ puts_filtered_tabular (char *string, int width, int right)
   gdb_assert (chars_per_line > 0);
   if (chars_per_line == UINT_MAX)
     {
-      puts_filtered (string);
-      puts_filtered ("\n");
+      gdb_puts (string);
+      gdb_puts ("\n");
       return;
     }
 
   if (((chars_printed - 1) / width + 2) * width >= chars_per_line)
-    puts_filtered ("\n");
+    gdb_puts ("\n");
 
   if (width >= chars_per_line)
     width = chars_per_line - 1;
@@ -1544,8 +1544,8 @@ puts_filtered_tabular (char *string, int width, int right)
   while (spaces--)
     spacebuf[spaces] = ' ';
 
-  puts_filtered (spacebuf);
-  puts_filtered (string);
+  gdb_puts (spacebuf);
+  gdb_puts (string);
 }
 
 
@@ -1559,7 +1559,7 @@ begin_line (void)
 {
   if (chars_printed > 0)
     {
-      puts_filtered ("\n");
+      gdb_puts ("\n");
     }
 }
 
@@ -1748,13 +1748,7 @@ pager_file::write (const char *buf, long length_buf)
 }
 
 void
-fputs_unfiltered (const char *linebuffer, struct ui_file *stream)
-{
-  stream->puts_unfiltered (linebuffer);
-}
-
-void
-fputs_filtered (const char *linebuffer, struct ui_file *stream)
+gdb_puts (const char *linebuffer, struct ui_file *stream)
 {
   stream->puts (linebuffer);
 }
@@ -1766,7 +1760,7 @@ fputs_styled (const char *linebuffer, const ui_file_style &style,
 	      struct ui_file *stream)
 {
   stream->emit_style_escape (style);
-  fputs_filtered (linebuffer, stream);
+  gdb_puts (linebuffer, stream);
   stream->emit_style_escape (ui_file_style ());
 }
 
@@ -1803,7 +1797,7 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
 
   /* Output the trailing part of STR not matching HIGHLIGHT.  */
   if (*str)
-    fputs_filtered (str, stream);
+    gdb_puts (str, stream);
 }
 
 /* Write character C to gdb_stdout using GDB's paging mechanism and return C.
@@ -1822,7 +1816,7 @@ fputc_unfiltered (int c, struct ui_file *stream)
 
   buf[0] = c;
   buf[1] = 0;
-  fputs_unfiltered (buf, stream);
+  gdb_puts (buf, stream);
   return c;
 }
 
@@ -1833,7 +1827,7 @@ fputc_filtered (int c, struct ui_file *stream)
 
   buf[0] = c;
   buf[1] = 0;
-  fputs_filtered (buf, stream);
+  gdb_puts (buf, stream);
   return c;
 }
 
@@ -1924,9 +1918,9 @@ printf_unfiltered (const char *format, ...)
    This one doesn't, and had better not!  */
 
 void
-puts_filtered (const char *string)
+gdb_puts (const char *string)
 {
-  fputs_filtered (string, gdb_stdout);
+  gdb_stdout->puts (string);
 }
 
 /* Return a pointer to N spaces and a null.  The pointer is good
@@ -1955,7 +1949,7 @@ n_spaces (int n)
 void
 print_spaces_filtered (int n, struct ui_file *stream)
 {
-  fputs_filtered (n_spaces (n), stream);
+  gdb_puts (n_spaces (n), stream);
 }
 \f
 /* C++/ObjC demangler stuff.  */
@@ -1974,13 +1968,13 @@ fprintf_symbol_filtered (struct ui_file *stream, const char *name,
       /* If user wants to see raw output, no problem.  */
       if (!demangle)
 	{
-	  fputs_filtered (name, stream);
+	  gdb_puts (name, stream);
 	}
       else
 	{
 	  gdb::unique_xmalloc_ptr<char> demangled
 	    = language_demangle (language_def (lang), name, arg_mode);
-	  fputs_filtered (demangled ? demangled.get () : name, stream);
+	  gdb_puts (demangled ? demangled.get () : name, stream);
 	}
     }
 }
diff --git a/gdb/utils.h b/gdb/utils.h
index 268886d716a..ec595e993c0 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -230,9 +230,7 @@ extern void set_screen_width_and_height (int width, int height);
    here are the styling formatters: '%p[', '%p]' and '%ps'.  See
    ui_out::message for details.  */
 
-extern void fputs_filtered (const char *, struct ui_file *);
-
-extern void fputs_unfiltered (const char *, struct ui_file *);
+extern void gdb_puts (const char *, struct ui_file *);
 
 extern int fputc_filtered (int c, struct ui_file *);
 
@@ -240,7 +238,7 @@ extern int fputc_unfiltered (int c, struct ui_file *);
 
 extern int putchar_filtered (int c);
 
-extern void puts_filtered (const char *);
+extern void gdb_puts (const char *);
 
 extern void puts_filtered_tabular (char *string, int width, int right);
 
@@ -281,7 +279,7 @@ extern void vfprintf_styled (struct ui_file *stream,
 			     va_list args)
   ATTRIBUTE_PRINTF (3, 0);
 
-/* Like fputs_filtered, but styles the output according to STYLE, when
+/* Like gdb_puts, but styles the output according to STYLE, when
    appropriate.  */
 
 extern void fputs_styled (const char *linebuffer,
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 82abcb41734..ff215fbc9df 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -435,7 +435,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
   if (options->symbol_print)
     print_address_demangle (options, gdbarch, address, stream, demangle);
   else if (options->addressprint)
-    fputs_filtered (paddress (gdbarch, address), stream);
+    gdb_puts (paddress (gdbarch, address), stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_ARRAY.  */
@@ -458,9 +458,9 @@ generic_val_print_array (struct value *val,
       if (!get_array_bounds (type, &low_bound, &high_bound))
 	error (_("Could not determine the array high bound"));
 
-      fputs_filtered (decorations->array_start, stream);
+      gdb_puts (decorations->array_start, stream);
       value_print_array_elements (val, stream, recurse, options, 0);
-      fputs_filtered (decorations->array_end, stream);
+      gdb_puts (decorations->array_end, stream);
     }
   else
     {
@@ -506,7 +506,7 @@ print_ref_address (struct type *type, const gdb_byte *address_buffer,
 	= extract_typed_address (address_buffer + embedded_offset, type);
 
       fprintf_filtered (stream, "@");
-      fputs_filtered (paddress (gdbarch, address), stream);
+      gdb_puts (paddress (gdbarch, address), stream);
     }
   /* Else: we have a non-addressable value, such as a DW_AT_const_value.  */
 }
@@ -581,7 +581,7 @@ generic_val_print_ref (struct type *type,
       print_ref_address (type, address, embedded_offset, stream);
 
       if (options->deref_ref)
-	fputs_filtered (": ", stream);
+	gdb_puts (": ", stream);
     }
 
   if (options->deref_ref)
@@ -590,7 +590,7 @@ generic_val_print_ref (struct type *type,
 	common_val_print (deref_val, stream, recurse, options,
 			  current_language);
       else
-	fputs_filtered ("???", stream);
+	gdb_puts ("???", stream);
     }
 }
 
@@ -639,11 +639,11 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
 	    {
 	      if (first)
 		{
-		  fputs_filtered ("(", stream);
+		  gdb_puts ("(", stream);
 		  first = 0;
 		}
 	      else
-		fputs_filtered (" | ", stream);
+		gdb_puts (" | ", stream);
 
 	      val &= ~type->field (i).loc_enumval ();
 	      fputs_styled (type->field (i).name (),
@@ -655,24 +655,24 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
 	{
 	  /* There are leftover bits, print them.  */
 	  if (first)
-	    fputs_filtered ("(", stream);
+	    gdb_puts ("(", stream);
 	  else
-	    fputs_filtered (" | ", stream);
+	    gdb_puts (" | ", stream);
 
-	  fputs_filtered ("unknown: 0x", stream);
+	  gdb_puts ("unknown: 0x", stream);
 	  print_longest (stream, 'x', 0, val);
-	  fputs_filtered (")", stream);
+	  gdb_puts (")", stream);
 	}
       else if (first)
 	{
 	  /* Nothing has been printed and the value is 0, the enum value must
 	     have been 0.  */
-	  fputs_filtered ("0", stream);
+	  gdb_puts ("0", stream);
 	}
       else
 	{
 	  /* Something has been printed, close the parenthesis.  */
-	  fputs_filtered (")", stream);
+	  gdb_puts (")", stream);
 	}
     }
   else
@@ -744,9 +744,9 @@ generic_value_print_bool
       struct type *type = check_typedef (value_type (value));
       LONGEST val = unpack_long (type, valaddr);
       if (val == 0)
-	fputs_filtered (decorations->false_name, stream);
+	gdb_puts (decorations->false_name, stream);
       else if (val == 1)
-	fputs_filtered (decorations->true_name, stream);
+	gdb_puts (decorations->true_name, stream);
       else
 	print_longest (stream, 'd', 0, val);
     }
@@ -790,7 +790,7 @@ generic_value_print_char (struct value *value, struct ui_file *stream,
 	fprintf_filtered (stream, "%u", (unsigned int) val);
       else
 	fprintf_filtered (stream, "%d", (int) val);
-      fputs_filtered (" ", stream);
+      gdb_puts (" ", stream);
       LA_PRINT_CHAR (val, unresolved_type, stream);
     }
 }
@@ -958,7 +958,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_VOID:
-      fputs_filtered (decorations->void_name, stream);
+      gdb_puts (decorations->void_name, stream);
       break;
 
     case TYPE_CODE_ERROR:
@@ -1064,7 +1064,7 @@ val_print_check_max_depth (struct ui_file *stream, int recurse,
   if (options->max_depth > -1 && recurse >= options->max_depth)
     {
       gdb_assert (language->struct_too_deep_ellipsis () != NULL);
-      fputs_filtered (language->struct_too_deep_ellipsis (), stream);
+      gdb_puts (language->struct_too_deep_ellipsis (), stream);
       return true;
     }
 
@@ -1200,7 +1200,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
   struct gdbarch *gdbarch = type->arch ();
   struct type *bool_type = builtin_type (gdbarch)->builtin_bool;
 
-  fputs_filtered ("[", stream);
+  gdb_puts ("[", stream);
   for (field = 0; field < nfields; field++)
     {
       if (type->field (field).name ()[0] != '\0')
@@ -1237,7 +1237,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
 	    }
 	}
     }
-  fputs_filtered (" ]", stream);
+  gdb_puts (" ]", stream);
 }
 
 /* See valprint.h.  */
@@ -1328,7 +1328,7 @@ print_longest (struct ui_file *stream, int format, int use_c_format,
       internal_error (__FILE__, __LINE__,
 		      _("failed internal consistency check"));
     } 
-  fputs_filtered (val, stream);
+  gdb_puts (val, stream);
 }
 
 /* This used to be a macro, but I don't think it is called often enough
@@ -1362,7 +1362,7 @@ print_floating (const gdb_byte *valaddr, struct type *type,
 		struct ui_file *stream)
 {
   std::string str = target_float_to_string (valaddr, type);
-  fputs_filtered (str.c_str (), stream);
+  gdb_puts (str.c_str (), stream);
 }
 
 void
@@ -1491,7 +1491,7 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
   cycle = (len * HOST_CHAR_BIT) % BITS_IN_OCTAL;
   carry = 0;
 
-  fputs_filtered ("0", stream);
+  gdb_puts ("0", stream);
   bool seen_a_one = false;
   if (byte_order == BFD_ENDIAN_BIG)
     {
@@ -1668,7 +1668,7 @@ print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr,
   if (is_signed
       && maybe_negate_by_bytes (valaddr, len, byte_order, &negated_bytes))
     {
-      fputs_filtered ("-", stream);
+      gdb_puts ("-", stream);
       valaddr = negated_bytes.data ();
     }
 
@@ -1788,7 +1788,7 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
 {
   const gdb_byte *p;
 
-  fputs_filtered ("0x", stream);
+  gdb_puts ("0x", stream);
   if (byte_order == BFD_ENDIAN_BIG)
     {
       p = valaddr;
@@ -1857,9 +1857,9 @@ print_function_pointer_address (const struct value_print_options *options,
      the address of the description.  */
   if (options->addressprint && func_addr != address)
     {
-      fputs_filtered ("@", stream);
-      fputs_filtered (paddress (gdbarch, address), stream);
-      fputs_filtered (": ", stream);
+      gdb_puts ("@", stream);
+      gdb_puts (paddress (gdbarch, address), stream);
+      gdb_puts (": ", stream);
     }
   print_address_demangle (options, gdbarch, func_addr, stream, demangle);
 }
@@ -2360,7 +2360,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
 			     sizeof (gdb_wchar_t), &output, translit_char);
   obstack_1grow (&output, '\0');
 
-  fputs_filtered ((const char *) obstack_base (&output), stream);
+  gdb_puts ((const char *) obstack_base (&output), stream);
 }
 
 /* Return the repeat count of the next character/byte in ITER,
@@ -2646,7 +2646,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
 
   if (length == 0)
     {
-      fputs_filtered ("\"\"", stream);
+      gdb_puts ("\"\"", stream);
       return;
     }
 
@@ -2703,7 +2703,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
 			     sizeof (gdb_wchar_t), &output, translit_char);
   obstack_1grow (&output, '\0');
 
-  fputs_filtered ((const char *) obstack_base (&output), stream);
+  gdb_puts ((const char *) obstack_base (&output), stream);
 }
 
 /* Print a string from the inferior, starting at ADDR and printing up to LEN
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index c933034346f..78b27908e11 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -944,7 +944,7 @@ display_selector (HANDLE thread, DWORD sel)
       printf_filtered ("0x%03x: ", (unsigned) sel);
       if (!info.HighWord.Bits.Pres)
 	{
-	  puts_filtered ("Segment not present\n");
+	  gdb_puts ("Segment not present\n");
 	  return 0;
 	}
       base = (info.HighWord.Bits.BaseHi << 24) +
@@ -955,50 +955,50 @@ display_selector (HANDLE thread, DWORD sel)
 	limit = (limit << 12) | 0xfff;
       printf_filtered ("base=0x%08x limit=0x%08x", base, limit);
       if (info.HighWord.Bits.Default_Big)
-	puts_filtered(" 32-bit ");
+	gdb_puts(" 32-bit ");
       else
-	puts_filtered(" 16-bit ");
+	gdb_puts(" 16-bit ");
       switch ((info.HighWord.Bits.Type & 0xf) >> 1)
 	{
 	case 0:
-	  puts_filtered ("Data (Read-Only, Exp-up");
+	  gdb_puts ("Data (Read-Only, Exp-up");
 	  break;
 	case 1:
-	  puts_filtered ("Data (Read/Write, Exp-up");
+	  gdb_puts ("Data (Read/Write, Exp-up");
 	  break;
 	case 2:
-	  puts_filtered ("Unused segment (");
+	  gdb_puts ("Unused segment (");
 	  break;
 	case 3:
-	  puts_filtered ("Data (Read/Write, Exp-down");
+	  gdb_puts ("Data (Read/Write, Exp-down");
 	  break;
 	case 4:
-	  puts_filtered ("Code (Exec-Only, N.Conf");
+	  gdb_puts ("Code (Exec-Only, N.Conf");
 	  break;
 	case 5:
-	  puts_filtered ("Code (Exec/Read, N.Conf");
+	  gdb_puts ("Code (Exec/Read, N.Conf");
 	  break;
 	case 6:
-	  puts_filtered ("Code (Exec-Only, Conf");
+	  gdb_puts ("Code (Exec-Only, Conf");
 	  break;
 	case 7:
-	  puts_filtered ("Code (Exec/Read, Conf");
+	  gdb_puts ("Code (Exec/Read, Conf");
 	  break;
 	default:
 	  printf_filtered ("Unknown type 0x%lx",
 			   (unsigned long) info.HighWord.Bits.Type);
 	}
       if ((info.HighWord.Bits.Type & 0x1) == 0)
-	puts_filtered(", N.Acc");
-      puts_filtered (")\n");
+	gdb_puts(", N.Acc");
+      gdb_puts (")\n");
       if ((info.HighWord.Bits.Type & 0x10) == 0)
-	puts_filtered("System selector ");
+	gdb_puts("System selector ");
       printf_filtered ("Priviledge level = %ld. ",
 		       (unsigned long) info.HighWord.Bits.Dpl);
       if (info.HighWord.Bits.Granularity)
-	puts_filtered ("Page granular.\n");
+	gdb_puts ("Page granular.\n");
       else
-	puts_filtered ("Byte granular.\n");
+	gdb_puts ("Byte granular.\n");
       return 1;
     }
   else
@@ -1017,7 +1017,7 @@ display_selectors (const char * args, int from_tty)
 {
   if (inferior_ptid == null_ptid)
     {
-      puts_filtered ("Impossible to display selectors now.\n");
+      gdb_puts ("Impossible to display selectors now.\n");
       return;
     }
 
@@ -1029,44 +1029,44 @@ display_selectors (const char * args, int from_tty)
 #ifdef __x86_64__
       if (wow64_process)
 	{
-	  puts_filtered ("Selector $cs\n");
+	  gdb_puts ("Selector $cs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegCs);
-	  puts_filtered ("Selector $ds\n");
+	  gdb_puts ("Selector $ds\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegDs);
-	  puts_filtered ("Selector $es\n");
+	  gdb_puts ("Selector $es\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegEs);
-	  puts_filtered ("Selector $ss\n");
+	  gdb_puts ("Selector $ss\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegSs);
-	  puts_filtered ("Selector $fs\n");
+	  gdb_puts ("Selector $fs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegFs);
-	  puts_filtered ("Selector $gs\n");
+	  gdb_puts ("Selector $gs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->wow64_context.SegGs);
 	}
       else
 #endif
 	{
-	  puts_filtered ("Selector $cs\n");
+	  gdb_puts ("Selector $cs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegCs);
-	  puts_filtered ("Selector $ds\n");
+	  gdb_puts ("Selector $ds\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegDs);
-	  puts_filtered ("Selector $es\n");
+	  gdb_puts ("Selector $es\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegEs);
-	  puts_filtered ("Selector $ss\n");
+	  gdb_puts ("Selector $ss\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegSs);
-	  puts_filtered ("Selector $fs\n");
+	  gdb_puts ("Selector $fs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegFs);
-	  puts_filtered ("Selector $gs\n");
+	  gdb_puts ("Selector $gs\n");
 	  display_selector (current_windows_thread->h,
 			    current_windows_thread->context.SegGs);
 	}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 11/19] Unify gdb putc functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (9 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 10/19] Unify gdb puts functions Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 13/19] Rename print_spaces_filtered Tom Tromey
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that filtered and unfiltered output can be treated identically, we
can unify the putc family of functions.  This is done under the name
"gdb_putc".  Most of this patch was written by script.
---
 gdb/arm-tdep.c                    |  2 +-
 gdb/break-catch-sig.c             |  2 +-
 gdb/breakpoint.c                  |  2 +-
 gdb/c-lang.c                      | 10 +++++-----
 gdb/cli-out.c                     |  4 ++--
 gdb/compile/compile-cplus-types.c |  4 ++--
 gdb/dwarf2/loc.c                  |  8 ++++----
 gdb/f-valprint.c                  |  4 ++--
 gdb/guile/scm-ports.c             |  2 +-
 gdb/guile/scm-pretty-print.c      |  2 +-
 gdb/hppa-tdep.c                   |  2 +-
 gdb/linux-fork.c                  |  2 +-
 gdb/mep-tdep.c                    |  2 +-
 gdb/mi/mi-console.c               |  8 ++++----
 gdb/mi/mi-out.c                   | 10 +++++-----
 gdb/mips-tdep.c                   |  8 ++++----
 gdb/p-typeprint.c                 |  2 +-
 gdb/remote.c                      |  4 ++--
 gdb/rust-lang.c                   |  2 +-
 gdb/s12z-tdep.c                   | 12 ++++++------
 gdb/serial.c                      |  2 +-
 gdb/target.c                      |  2 +-
 gdb/ui-file.c                     |  4 +++-
 gdb/utils.c                       | 28 ++++++----------------------
 gdb/utils.h                       |  6 ++----
 gdb/valprint.c                    |  6 +++---
 26 files changed, 62 insertions(+), 78 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index fc83ff8b9b7..33b65bdf421 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4024,7 +4024,7 @@ print_fpu_flags (struct ui_file *file, int flags)
     gdb_puts ("UFL ", file);
   if (flags & (1 << 4))
     gdb_puts ("INX ", file);
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 }
 
 /* Print interesting information about the floating point processor
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index e268a102891..b41a9083ccd 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -296,7 +296,7 @@ signal_catchpoint_print_recreate (struct breakpoint *b, struct ui_file *fp)
     }
   else if (c->catch_all)
     fprintf_unfiltered (fp, " all");
-  fputc_unfiltered ('\n', fp);
+  gdb_putc ('\n', fp);
 }
 
 /* Implement the "explains_signal" breakpoint_ops method for signal
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9567c737cab..0cdb848cea7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11052,7 +11052,7 @@ clear_command (const char *arg, int from_tty)
       delete_breakpoint (iter);
     }
   if (from_tty)
-    putchar_filtered ('\n');
+    gdb_putc ('\n');
 }
 \f
 /* Delete breakpoint in BS if they are `delete' breakpoints and
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index fa1b73c718f..d5dd7fd2400 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -167,19 +167,19 @@ language_defn::printchar (int c, struct type *type,
     case C_CHAR:
       break;
     case C_WIDE_CHAR:
-      fputc_filtered ('L', stream);
+      gdb_putc ('L', stream);
       break;
     case C_CHAR_16:
-      fputc_filtered ('u', stream);
+      gdb_putc ('u', stream);
       break;
     case C_CHAR_32:
-      fputc_filtered ('U', stream);
+      gdb_putc ('U', stream);
       break;
     }
 
-  fputc_filtered ('\'', stream);
+  gdb_putc ('\'', stream);
   emitchar (c, type, stream, '\'');
-  fputc_filtered ('\'', stream);
+  gdb_putc ('\'', stream);
 }
 
 /* Print the character string STRING, printing at most LENGTH
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 0c87a820568..47b256bd97e 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -381,9 +381,9 @@ void
 cli_ui_out::field_separator ()
 {
   if (test_flags (unfiltered_output))
-    fputc_unfiltered (' ', m_streams.back ());
+    gdb_putc (' ', m_streams.back ());
   else
-    fputc_filtered (' ', m_streams.back ());
+    gdb_putc (' ', m_streams.back ());
 }
 
 /* Constructor for cli_ui_out.  */
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index a76abea977a..9b24857dfa9 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -1267,7 +1267,7 @@ static void
 compile_cplus_debug_output (T arg, Targs... Args)
 {
   compile_cplus_debug_output_1 (arg);
-  fputc_unfiltered (' ', gdb_stdlog);
+  gdb_putc (' ', gdb_stdlog);
   compile_cplus_debug_output (Args...);
 }
 
@@ -1277,7 +1277,7 @@ compile_cplus_debug_output (T arg, Targs... Args)
     {						  \
       gdb_puts (": ", gdb_stdlog);		  \
       compile_cplus_debug_output (R);		  \
-      fputc_unfiltered ('\n', gdb_stdlog);	  \
+      gdb_putc ('\n', gdb_stdlog);		  \
     }						  \
 
 #define GCC_METHOD0(R, N)			  \
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index a9aa0d5b7a0..73f37ad9c0b 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -862,7 +862,7 @@ chain_candidate (struct gdbarch *gdbarch,
 	  fprintf_unfiltered (gdb_stdlog, "tailcall: initial:");
 	  for (idx = 0; idx < length; idx++)
 	    tailcall_dump (gdbarch, result->call_site[idx]);
-	  fputc_unfiltered ('\n', gdb_stdlog);
+	  gdb_putc ('\n', gdb_stdlog);
 	}
 
       return;
@@ -873,7 +873,7 @@ chain_candidate (struct gdbarch *gdbarch,
       fprintf_unfiltered (gdb_stdlog, "tailcall: compare:");
       for (idx = 0; idx < length; idx++)
 	tailcall_dump (gdbarch, chain->at (idx));
-      fputc_unfiltered ('\n', gdb_stdlog);
+      gdb_putc ('\n', gdb_stdlog);
     }
 
   /* Intersect callers.  */
@@ -907,7 +907,7 @@ chain_candidate (struct gdbarch *gdbarch,
 	tailcall_dump (gdbarch,
 		       (*resultp)->call_site[(*resultp)->length
 					     - (*resultp)->callees + idx]);
-      fputc_unfiltered ('\n', gdb_stdlog);
+      gdb_putc ('\n', gdb_stdlog);
     }
 
   if ((*resultp)->callers == 0 && (*resultp)->callees == 0)
@@ -3621,7 +3621,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  data = safe_read_uleb128 (data, end, &ul);
-	  fputc_filtered ('\n', stream);
+	  gdb_putc ('\n', stream);
 	  disassemble_dwarf_expression (stream, arch, addr_size, offset_size,
 					start, data, data + ul, indent + 2,
 					all, per_cu, per_objfile);
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index fa036355c1c..ad1fae29efc 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -607,7 +607,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
 	  continue;
 
 	if (*any_printed)
-	  putchar_filtered ('\n');
+	  gdb_putc ('\n');
 	else
 	  *any_printed = 1;
 	if (sym->print_name ())
@@ -636,7 +636,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
 				except.what ());
 	      }
 
-	    putchar_filtered ('\n');
+	    gdb_putc ('\n');
 	  }
       }
 }
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index c61ca1dafc4..946859aa1f3 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -204,7 +204,7 @@ fputsn_filtered (const char *s, size_t size, struct ui_file *stream)
       if (s[i] == '\0')
 	gdb_puts ("\\000", stream);
       else
-	fputc_filtered (s[i], stream);
+	gdb_putc (s[i], stream);
     }
 }
 
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 8a5c02d0adb..707ef4be4e4 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -689,7 +689,7 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
 	      if (string.get ()[i] == '\0')
 		gdb_puts ("\\000", stream);
 	      else
-		fputc_filtered (string.get ()[i], stream);
+		gdb_putc (string.get ()[i], stream);
 	    }
 	}
       result = STRING_REPR_OK;
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 32c54357045..682028d6fe8 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -2609,7 +2609,7 @@ unwind_command (const char *exp, int from_tty)
   pif (Large_frame);
   pif (alloca_frame);
 
-  putchar_filtered ('\n');
+  gdb_putc ('\n');
 
 #define pin(FLD) printf_filtered ("\t"#FLD" = 0x%x\n", u->FLD);
 
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index e7e25b5eae6..8cea33d793f 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -597,7 +597,7 @@ info_checkpoints_command (const char *arg, int from_tty)
 	    printf_filtered (", <%s>", msym.minsym->linkage_name ());
 	}
 
-      putchar_filtered ('\n');
+      gdb_putc ('\n');
     }
   if (printed == NULL)
     {
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 11d79a0e9e7..696d9c63bce 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -2369,7 +2369,7 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	  const char *file_endianness
 	    = bfd_big_endian (info.abfd) ? "big" : "little";
 	  
-	  fputc_unfiltered ('\n', gdb_stderr);
+	  gdb_putc ('\n', gdb_stderr);
 	  if (module_name)
 	    warning (_("the MeP module '%s' is %s-endian, but the executable\n"
 		       "%s is %s-endian."),
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index 5043e9b475d..5cdb486be5e 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -79,15 +79,15 @@ mi_console_file::flush ()
       gdb_puts (m_prefix, m_raw);
       if (m_quote)
 	{
-	  fputc_unfiltered (m_quote, m_raw);
+	  gdb_putc (m_quote, m_raw);
 	  m_raw->putstrn (buf, length_buf, m_quote);
-	  fputc_unfiltered (m_quote, m_raw);
-	  fputc_unfiltered ('\n', m_raw);
+	  gdb_putc (m_quote, m_raw);
+	  gdb_putc ('\n', m_raw);
 	}
       else
 	{
 	  m_raw->putstrn (buf, length_buf, 0);
-	  fputc_unfiltered ('\n', m_raw);
+	  gdb_putc ('\n', m_raw);
 	}
       gdb_flush (m_raw);
     }
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index ff93cb3ba10..c84cc55e4c1 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -199,7 +199,7 @@ mi_ui_out::field_separator ()
   if (m_suppress_field_separator)
     m_suppress_field_separator = false;
   else
-    fputc_unfiltered (',', m_streams.back ());
+    gdb_putc (',', m_streams.back ());
 }
 
 void
@@ -216,11 +216,11 @@ mi_ui_out::open (const char *name, ui_out_type type)
   switch (type)
     {
     case ui_out_type_tuple:
-      fputc_unfiltered ('{', stream);
+      gdb_putc ('{', stream);
       break;
 
     case ui_out_type_list:
-      fputc_unfiltered ('[', stream);
+      gdb_putc ('[', stream);
       break;
 
     default:
@@ -236,11 +236,11 @@ mi_ui_out::close (ui_out_type type)
   switch (type)
     {
     case ui_out_type_tuple:
-      fputc_unfiltered ('}', stream);
+      gdb_putc ('}', stream);
       break;
 
     case ui_out_type_list:
-      fputc_unfiltered (']', stream);
+      gdb_putc (']', stream);
       break;
 
     default:
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 299e8a0cc52..d784f9ea3d3 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6423,7 +6423,7 @@ print_fpu_flags (struct ui_file *file, int flags)
     gdb_puts (" inval", file);
   if (flags & (1 << 5))
     gdb_puts (" unimp", file);
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 }
 
 /* Print interesting information about the floating point processor
@@ -6458,7 +6458,7 @@ mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
   for (i = 1; i <= 7; i++)
     if (fcs & (1 << (24 + i)))
       fprintf_filtered (file, " %d", i);
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 
   gdb_puts ("cause   :", file);
   print_fpu_flags (file, (fcs >> 12) & 0x3f);
@@ -6485,11 +6485,11 @@ mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
     gdb_puts (" zero", file);
   if ((fcs & (0xb << 21)) == 0)
     gdb_puts (" no", file);
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 
   fprintf_filtered (file, "nan2008 : %s\n", fcs & (1 << 18) ? "yes" : "no");
   fprintf_filtered (file, "abs2008 : %s\n", fcs & (1 << 19) ? "yes" : "no");
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 
   default_print_float_info (gdbarch, file, frame, args);
 }
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 98bbee97988..f8bdf72cf4a 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -152,7 +152,7 @@ pascal_language::type_print_method_args (const char *physname,
 	  physname += len;
 
 	  for (j = 0; j < i; ++j)
-	    fputc_filtered (physname[j], stream);
+	    gdb_putc (physname[j], stream);
 
 	  physname += i;
 	  if (physname[0] != 0)
diff --git a/gdb/remote.c b/gdb/remote.c
index 6746aa851bc..be5b759b0c2 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11585,7 +11585,7 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
 	{
 	  char c = (fromhex (p[0]) << 4) + fromhex (p[1]);
 
-	  fputc_unfiltered (c, outbuf);
+	  gdb_putc (c, outbuf);
 	}
       break;
     }
@@ -11642,7 +11642,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks
       {
 	gdb_byte c = buf[i];
 	if (isprint (c))
-	  fputc_unfiltered (c, &stb);
+	  gdb_putc (c, &stb);
 	else
 	  fprintf_unfiltered (&stb, "\\x%02x", (unsigned char) c);
       }
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 110a429a47f..d37b04b824c 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1600,7 +1600,7 @@ rust_language::emitchar (int ch, struct type *chtype,
   else if (ch == '\0')
     gdb_puts ("\\0", stream);
   else if (ch >= 32 && ch <= 127 && isprint (ch))
-    fputc_filtered (ch, stream);
+    gdb_putc (ch, stream);
   else if (ch <= 255)
     fprintf_filtered (stream, "\\x%02x", ch);
   else
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 97f6f4a6f80..40cd3d1da1b 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -527,23 +527,23 @@ s12z_print_ccw_info (struct gdbarch *gdbarch,
   const int stop_1 = 15;
   const int stop_2 = 17;
   for (int i = 0; i < stop_1 - len; ++i)
-    fputc_filtered (' ', file);
+    gdb_putc (' ', file);
   fprintf_filtered (file, "0x%04x", ccw);
   for (int i = 0; i < stop_2 - len; ++i)
-    fputc_filtered (' ', file);
+    gdb_putc (' ', file);
   for (int b = 15; b >= 0; --b)
     {
       if (ccw & (0x1u << b))
 	{
 	  if (ccw_bits[b] == 0)
-	    fputc_filtered ('1', file);
+	    gdb_putc ('1', file);
 	  else
-	    fputc_filtered (ccw_bits[b], file);
+	    gdb_putc (ccw_bits[b], file);
 	}
       else
-	fputc_filtered (tolower (ccw_bits[b]), file);
+	gdb_putc (tolower (ccw_bits[b]), file);
     }
-  fputc_filtered ('\n', file);
+  gdb_putc ('\n', file);
 }
 
 static void
diff --git a/gdb/serial.c b/gdb/serial.c
index 347ab2e098f..1508c5de2c3 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -70,7 +70,7 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
     }
 
   if (serial_logbase != logbase_ascii)
-    fputc_unfiltered (' ', stream);
+    gdb_putc (' ', stream);
 
   switch (ch)
     {
diff --git a/gdb/target.c b/gdb/target.c
index b53e5b6098e..97e8e125b5d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1785,7 +1785,7 @@ target_xfer_partial (struct target_ops *ops,
 	    }
 	}
 
-      fputc_unfiltered ('\n', gdb_stdlog);
+      gdb_putc ('\n', gdb_stdlog);
     }
 
   /* Check implementations of to_xfer_partial update *XFERED_LEN
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index ec441a73a8c..afb12b408f5 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -63,7 +63,9 @@ ui_file::putstrn (const char *str, int n, int quoter, bool async_safe)
 int
 ui_file::putc (int c)
 {
-  return fputc_unfiltered (c, this);
+  char copy = (char) c;
+  write (&copy, 1);
+  return c;
 }
 
 void
diff --git a/gdb/utils.c b/gdb/utils.c
index b07852bcc74..04f2f38bd7b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1779,7 +1779,7 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
       /* Output the part before pmatch with current style.  */
       while (pmatch.rm_so > 0)
 	{
-	  fputc_filtered (*str, stream);
+	  gdb_putc (*str, stream);
 	  pmatch.rm_so--;
 	  str++;
 	}
@@ -1788,7 +1788,7 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
       stream->emit_style_escape (highlight_style.style ());
       while (n_highlight > 0)
 	{
-	  fputc_filtered (*str, stream);
+	  gdb_putc (*str, stream);
 	  n_highlight--;
 	  str++;
 	}
@@ -1804,31 +1804,15 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
    May return nonlocally.  */
 
 int
-putchar_filtered (int c)
+gdb_putc (int c)
 {
-  return fputc_filtered (c, gdb_stdout);
+  return gdb_stdout->putc (c);
 }
 
 int
-fputc_unfiltered (int c, struct ui_file *stream)
+gdb_putc (int c, struct ui_file *stream)
 {
-  char buf[2];
-
-  buf[0] = c;
-  buf[1] = 0;
-  gdb_puts (buf, stream);
-  return c;
-}
-
-int
-fputc_filtered (int c, struct ui_file *stream)
-{
-  char buf[2];
-
-  buf[0] = c;
-  buf[1] = 0;
-  gdb_puts (buf, stream);
-  return c;
+  return stream->putc (c);
 }
 
 void
diff --git a/gdb/utils.h b/gdb/utils.h
index ec595e993c0..0c629ae2908 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -232,11 +232,9 @@ extern void set_screen_width_and_height (int width, int height);
 
 extern void gdb_puts (const char *, struct ui_file *);
 
-extern int fputc_filtered (int c, struct ui_file *);
+extern int gdb_putc (int c, struct ui_file *);
 
-extern int fputc_unfiltered (int c, struct ui_file *);
-
-extern int putchar_filtered (int c);
+extern int gdb_putc (int c);
 
 extern void gdb_puts (const char *);
 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index ff215fbc9df..9a8de15e5eb 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1396,7 +1396,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 		b = '0';
 
 	      if (zero_pad || seen_a_one || b == '1')
-		fputc_filtered (b, stream);
+		gdb_putc (b, stream);
 	      if (b == '1')
 		seen_a_one = true;
 	    }
@@ -1416,7 +1416,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 		b = '0';
 
 	      if (zero_pad || seen_a_one || b == '1')
-		fputc_filtered (b, stream);
+		gdb_putc (b, stream);
 	      if (b == '1')
 		seen_a_one = true;
 	    }
@@ -1426,7 +1426,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
   /* When not zero-padding, ensure that something is printed when the
      input is 0.  */
   if (!zero_pad && !seen_a_one)
-    fputc_filtered ('0', stream);
+    gdb_putc ('0', stream);
 }
 
 /* A helper for print_octal_chars that emits a single octal digit,
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 13/19] Rename print_spaces_filtered
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (10 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 11/19] Unify gdb putc functions Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 14/19] Rename puts_filtered_tabular Tom Tromey
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

print_spaces_filtered is now misnamed, because whether filtering
happens is up to the stream.  So, rename it.
---
 gdb/ada-valprint.c           | 10 +++++-----
 gdb/c-typeprint.c            | 14 +++++++-------
 gdb/c-valprint.c             |  2 +-
 gdb/cli-out.c                |  2 +-
 gdb/cp-valprint.c            |  8 ++++----
 gdb/guile/scm-pretty-print.c |  6 +++---
 gdb/m2-typeprint.c           |  2 +-
 gdb/p-typeprint.c            |  4 ++--
 gdb/p-valprint.c             | 10 +++++-----
 gdb/python/py-prettyprint.c  |  6 +++---
 gdb/riscv-tdep.c             |  2 +-
 gdb/rust-lang.c              | 12 ++++++------
 gdb/symmisc.c                |  2 +-
 gdb/typeprint.c              |  4 ++--
 gdb/utils.c                  |  2 +-
 gdb/utils.h                  |  2 +-
 gdb/valprint.c               |  6 +++---
 17 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 3dac4dc85b7..6aac5c36f1e 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -166,7 +166,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	  if (options->prettyformat_arrays)
 	    {
 	      gdb_printf (stream, ",\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    {
@@ -176,7 +176,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
       else if (options->prettyformat_arrays)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 + 2 * recurse, stream);
+	  print_spaces (2 + 2 * recurse, stream);
 	}
       stream->wrap_here (2 + 2 * recurse);
       maybe_print_array_index (index_type, i + low, stream, options);
@@ -229,7 +229,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		  if (options->prettyformat_arrays)
 		    {
 		      gdb_printf (stream, ",\n");
-		      print_spaces_filtered (2 + 2 * recurse, stream);
+		      print_spaces (2 + 2 * recurse, stream);
 		    }
 		  else
 		    {
@@ -610,7 +610,7 @@ print_field_values (struct value *value, struct value *outer_value,
       if (options->prettyformat)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 + 2 * recurse, stream);
+	  print_spaces (2 + 2 * recurse, stream);
 	}
       else
 	{
@@ -876,7 +876,7 @@ ada_val_print_struct_union (struct value *value,
       && options->prettyformat)
     {
       gdb_printf (stream, "\n");
-      print_spaces_filtered (2 * recurse, stream);
+      print_spaces (2 * recurse, stream);
     }
 
   gdb_printf (stream, ")");
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 3612244c3d5..6d369886e37 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -906,7 +906,7 @@ c_type_print_template_args (const struct type_print_options *flags,
     gdb_puts (_("] "), stream);
 }
 
-/* Use 'print_spaces_filtered', but take into consideration the
+/* Use 'print_spaces', but take into consideration the
    type_print_options FLAGS in order to determine how many whitespaces
    will be printed.  */
 
@@ -915,9 +915,9 @@ print_spaces_filtered_with_print_options
   (int level, struct ui_file *stream, const struct type_print_options *flags)
 {
   if (!flags->print_offsets)
-    print_spaces_filtered (level, stream);
+    print_spaces (level, stream);
   else
-    print_spaces_filtered (level + print_offset_data::indentation, stream);
+    print_spaces (level + print_offset_data::indentation, stream);
 }
 
 /* Output an access specifier to STREAM, if needed.  LAST_ACCESS is the
@@ -1175,7 +1175,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 	  if (flags->print_offsets)
 	    podata->update (type, i, stream);
 
-	  print_spaces_filtered (level + 4, stream);
+	  print_spaces (level + 4, stream);
 	  if (is_static)
 	    gdb_printf (stream, "static ");
 
@@ -1426,9 +1426,9 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 	  if (show > 0)
 	    podata->finish (type, level, stream);
 
-	  print_spaces_filtered (print_offset_data::indentation, stream);
+	  print_spaces (print_offset_data::indentation, stream);
 	  if (level == 0)
-	    print_spaces_filtered (2, stream);
+	    print_spaces (2, stream);
 	}
 
       gdb_printf (stream, "%*s}", level, "");
@@ -1639,7 +1639,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 	    for (i = 0; i < len; i++)
 	      {
 		QUIT;
-		print_spaces_filtered (level + 4, stream);
+		print_spaces (level + 4, stream);
 		/* We pass "show" here and not "show - 1" to get enum types
 		   printed.  There's no other way to see them.  */
 		c_print_type_1 (type->field (i).type (),
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 2ab0772cbd3..4063445d404 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -222,7 +222,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	  if (options->prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	}
     }
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index f396aef12e3..39279d96397 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -211,7 +211,7 @@ cli_ui_out::do_spaces (int numspaces)
   if (test_flags (unfiltered_output))
     gdb_printf (m_streams.back (), "%*s", numspaces, "");
   else
-    print_spaces_filtered (numspaces, m_streams.back ());
+    print_spaces (numspaces, m_streams.back ());
 }
 
 void
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 92b5f440e76..fc5600c100c 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -207,7 +207,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      if (options->prettyformat)
 		{
 		  gdb_printf (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
+		  print_spaces (2 + 2 * recurse, stream);
 		  gdb_puts ("members of ", stream);
 		  gdb_puts (type->name (), stream);
 		  gdb_puts (":", stream);
@@ -218,7 +218,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  if (options->prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    {
@@ -374,7 +374,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
       if (options->prettyformat)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
     }				/* if there are data fields */
 
@@ -479,7 +479,7 @@ cp_print_value (struct value *val, struct ui_file *stream,
       if (options->prettyformat)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
       gdb_puts ("<", stream);
       /* Not sure what the best notation is in the case where there is
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index a99ab13c1d8..2bb63e849d1 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -858,7 +858,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	  if (pretty)
 	    {
 	      gdb_puts ("\n", stream);
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    stream->wrap_here (2 + 2 *recurse);
@@ -930,14 +930,14 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	  if (pretty)
 	    {
 	      gdb_puts ("\n", stream);
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  gdb_puts ("...", stream);
 	}
       if (pretty)
 	{
 	  gdb_puts ("\n", stream);
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
       gdb_puts ("}", stream);
     }
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index fd8a96c9dd1..601d1fc26c3 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -562,7 +562,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
 	{
 	  QUIT;
 
-	  print_spaces_filtered (level + 4, stream);
+	  print_spaces (level + 4, stream);
 	  fputs_styled (type->field (i).name (),
 			variable_name_style.style (), stream);
 	  gdb_puts (" : ", stream);
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 0ef8c922606..f222f01b429 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -561,7 +561,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 		    }
 		}
 
-	      print_spaces_filtered (level + 4, stream);
+	      print_spaces (level + 4, stream);
 	      if (field_is_static (&type->field (i)))
 		gdb_printf (stream, "static ");
 	      print_type (type->field (i).type (),
@@ -633,7 +633,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 			}
 		    }
 
-		  print_spaces_filtered (level + 4, stream);
+		  print_spaces (level + 4, stream);
 		  if (TYPE_FN_FIELD_STATIC_P (f, j))
 		    gdb_printf (stream, "static ");
 		  if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 68b5042ac52..eeb24454bd7 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -267,7 +267,7 @@ pascal_language::value_print_inner (struct value *val,
 	      if (options->prettyformat)
 		{
 		  gdb_printf (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
+		  print_spaces (2 + 2 * recurse, stream);
 		}
 	    }
 	}
@@ -559,7 +559,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	      if (options->prettyformat)
 		{
 		  gdb_printf (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
+		  print_spaces (2 + 2 * recurse, stream);
 		  gdb_puts ("members of ", stream);
 		  gdb_puts (type->name (), stream);
 		  gdb_puts (": ", stream);
@@ -570,7 +570,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	  if (options->prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    {
@@ -671,7 +671,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
       if (options->prettyformat)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
     }
   gdb_printf (stream, "}");
@@ -762,7 +762,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream,
       if (options->prettyformat)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
       gdb_puts ("<", stream);
       /* Not sure what the best notation is in the case where there is no
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index a88a9f5b9b6..c9bbd726412 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -471,7 +471,7 @@ print_children (PyObject *printer, const char *hint,
 	  if (pretty)
 	    {
 	      gdb_puts ("\n", stream);
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    stream->wrap_here (2 + 2 *recurse);
@@ -550,14 +550,14 @@ print_children (PyObject *printer, const char *hint,
 	  if (pretty)
 	    {
 	      gdb_puts ("\n", stream);
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  gdb_puts ("...", stream);
 	}
       if (pretty)
 	{
 	  gdb_puts ("\n", stream);
-	  print_spaces_filtered (2 * recurse, stream);
+	  print_spaces (2 * recurse, stream);
 	}
       gdb_puts ("}", stream);
     }
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 8d1ecf0cdd7..e569f9369b8 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1038,7 +1038,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
   enum tab_stops { value_column_1 = 15 };
 
   gdb_puts (name, file);
-  print_spaces_filtered (value_column_1 - strlen (name), file);
+  print_spaces (value_column_1 - strlen (name), file);
 
   try
     {
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 9ac29b85e8f..c78289c3244 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -372,7 +372,7 @@ rust_language::val_print_struct
       if (options->prettyformat)
 	{
 	  gdb_puts ("\n", stream);
-	  print_spaces_filtered (2 + 2 * recurse, stream);
+	  print_spaces (2 + 2 * recurse, stream);
 	}
       else if (!first_field)
 	gdb_puts (" ", stream);
@@ -393,7 +393,7 @@ rust_language::val_print_struct
   if (options->prettyformat)
     {
       gdb_puts ("\n", stream);
-      print_spaces_filtered (2 * recurse, stream);
+      print_spaces (2 * recurse, stream);
     }
 
   if (is_tuple || is_tuple_struct)
@@ -707,7 +707,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
       /* For a tuple struct we print the type but nothing
 	 else.  */
       if (!for_rust_enum || flags->print_offsets)
-	print_spaces_filtered (level + 2, stream);
+	print_spaces (level + 2, stream);
       if (is_enum)
 	fputs_styled (type->field (i).name (), variable_name_style.style (),
 		      stream);
@@ -733,12 +733,12 @@ rust_print_struct_def (struct type *type, const char *varstring,
       /* Undo the temporary level increase we did above.  */
       level -= 2;
       podata->finish (type, level, stream);
-      print_spaces_filtered (print_offset_data::indentation, stream);
+      print_spaces (print_offset_data::indentation, stream);
       if (level == 0)
-	print_spaces_filtered (2, stream);
+	print_spaces (2, stream);
     }
   if (!for_rust_enum || flags->print_offsets)
-    print_spaces_filtered (level, stream);
+    print_spaces (level, stream);
   gdb_puts (is_tuple_struct ? ")" : "}", stream);
 }
 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 55f79856643..1d3555ea2cd 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -506,7 +506,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
   else
     section = NULL;
 
-  print_spaces_filtered (depth, outfile);
+  print_spaces (depth, outfile);
   if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
     {
       gdb_printf (outfile, "label %s at ", symbol->print_name ());
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 27f4846f934..c52af125516 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -127,7 +127,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
 {
   if (field_is_static (&type->field (field_idx)))
     {
-      print_spaces_filtered (indentation, stream);
+      print_spaces (indentation, stream);
       return;
     }
 
@@ -188,7 +188,7 @@ print_offset_data::finish (struct type *type, int level,
   maybe_print_hole (stream, bitpos, "padding");
 
   gdb_puts ("\n", stream);
-  print_spaces_filtered (level + 4 + print_offset_data::indentation, stream);
+  print_spaces (level + 4 + print_offset_data::indentation, stream);
   gdb_printf (stream, "/* total size (bytes): %4s */\n",
 	      pulongest (TYPE_LENGTH (type)));
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index 31205b046a0..46b061ea6cf 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1921,7 +1921,7 @@ n_spaces (int n)
 
 /* Print N spaces.  */
 void
-print_spaces_filtered (int n, struct ui_file *stream)
+print_spaces (int n, struct ui_file *stream)
 {
   gdb_puts (n_spaces (n), stream);
 }
diff --git a/gdb/utils.h b/gdb/utils.h
index 621ac76ded5..e43ce3bcbd0 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -252,7 +252,7 @@ extern void gdb_printf (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
 
 extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
 
-extern void print_spaces_filtered (int, struct ui_file *);
+extern void print_spaces (int, struct ui_file *);
 
 extern const char *n_spaces (int);
 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 42930f66896..0580a87c303 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1936,7 +1936,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
 	  if (options->prettyformat_arrays)
 	    {
 	      gdb_printf (stream, ",\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
+	      print_spaces (2 + 2 * recurse, stream);
 	    }
 	  else
 	    gdb_printf (stream, ", ");
@@ -1944,7 +1944,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
       else if (options->prettyformat_arrays)
 	{
 	  gdb_printf (stream, "\n");
-	  print_spaces_filtered (2 + 2 * recurse, stream);
+	  print_spaces (2 + 2 * recurse, stream);
 	}
       stream->wrap_here (2 + 2 * recurse);
       maybe_print_array_index (index_type, i + low_bound,
@@ -1992,7 +1992,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
   if (options->prettyformat_arrays)
     {
       gdb_printf (stream, "\n");
-      print_spaces_filtered (2 * recurse, stream);
+      print_spaces (2 * recurse, stream);
     }
 }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 14/19] Rename puts_filtered_tabular
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (11 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 13/19] Rename print_spaces_filtered Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 15/19] Rename fprintf_symbol_filtered Tom Tromey
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

puts_filtered_tabular is now misnamed, because whether filtering
happens is now up to the stream.  So, rename it.  (This function is
pretty weird, and should probably be rewritten to avoid using the
chars_printed global, and moved into objc-lang.c.  However, I haven't
done so.)
---
 gdb/objc-lang.c |  4 ++--
 gdb/utils.c     | 13 ++++++-------
 gdb/utils.h     |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 0ef1973a6f9..9a834ff504a 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -666,7 +666,7 @@ info_selectors_command (const char *regexp, int from_tty)
 	    *p++ = *name++;
 	  *p++ = '\0';
 	  /* Print in columns.  */
-	  puts_filtered_tabular(asel, maxlen + 1, 0);
+	  puts_tabular(asel, maxlen + 1, 0);
 	}
       begin_line();
     }
@@ -800,7 +800,7 @@ info_classes_command (const char *regexp, int from_tty)
 	    *p++ = *name++;
 	  *p++ = '\0';
 	  /* Print in columns.  */
-	  puts_filtered_tabular(aclass, maxlen + 1, 0);
+	  puts_tabular(aclass, maxlen + 1, 0);
 	}
       begin_line();
     }
diff --git a/gdb/utils.c b/gdb/utils.c
index 46b061ea6cf..d00f72ba0a5 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1504,15 +1504,14 @@ pager_file::wrap_here (int indent)
     }
 }
 
-/* Print input string to gdb_stdout, filtered, with wrap, 
-   arranging strings in columns of n chars.  String can be
-   right or left justified in the column.  Never prints 
-   trailing spaces.  String should never be longer than
-   width.  FIXME: this could be useful for the EXAMINE 
-   command, which currently doesn't tabulate very well.  */
+/* Print input string to gdb_stdout arranging strings in columns of n
+   chars.  String can be right or left justified in the column.  Never
+   prints trailing spaces.  String should never be longer than width.
+   FIXME: this could be useful for the EXAMINE command, which
+   currently doesn't tabulate very well.  */
 
 void
-puts_filtered_tabular (char *string, int width, int right)
+puts_tabular (char *string, int width, int right)
 {
   int spaces = 0;
   int stringlen;
diff --git a/gdb/utils.h b/gdb/utils.h
index e43ce3bcbd0..e899e899238 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -238,7 +238,7 @@ extern int gdb_putc (int c);
 
 extern void gdb_puts (const char *);
 
-extern void puts_filtered_tabular (char *string, int width, int right);
+extern void puts_tabular (char *string, int width, int right);
 
 extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 15/19] Rename fprintf_symbol_filtered
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (12 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 14/19] Rename puts_filtered_tabular Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 16/19] Remove ui_out_flag::unfiltered_output Tom Tromey
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

fprintf_symbol_filtered is misnamed, because whether filtering happens
is now up to the stream.  This renames it to fprintf_symbol, which
isn't a great name (the first "f" doesn't mean much and the second one
is truly meaningless here), but "print_symbol" was already taken.
---
 gdb/c-typeprint.c | 8 ++++----
 gdb/cp-valprint.c | 8 ++++----
 gdb/p-valprint.c  | 8 ++++----
 gdb/printcmd.c    | 8 ++++----
 gdb/utils.c       | 6 +++---
 gdb/utils.h       | 4 ++--
 6 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 6d369886e37..357f61d6c3e 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -283,10 +283,10 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
   int varargs = mtype->has_varargs ();
   int i;
 
-  fprintf_symbol_filtered (stream, prefix,
-			   language_cplus, DMGL_ANSI);
-  fprintf_symbol_filtered (stream, varstring,
-			   language_cplus, DMGL_ANSI);
+  fprintf_symbol (stream, prefix,
+		  language_cplus, DMGL_ANSI);
+  fprintf_symbol (stream, varstring,
+		  language_cplus, DMGL_ANSI);
   gdb_puts ("(", stream);
 
   /* Skip the class variable.  We keep this here to accommodate older
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index fc5600c100c..43a52698b71 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -230,10 +230,10 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  if (field_is_static (&type->field (i)))
 	    {
 	      gdb_puts ("static ", stream);
-	      fprintf_symbol_filtered (stream,
-				       type->field (i).name (),
-				       current_language->la_language,
-				       DMGL_PARAMS | DMGL_ANSI);
+	      fprintf_symbol (stream,
+			      type->field (i).name (),
+			      current_language->la_language,
+			      DMGL_PARAMS | DMGL_ANSI);
 	    }
 	  else
 	    fputs_styled (type->field (i).name (),
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index eeb24454bd7..950aa61d5db 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -582,10 +582,10 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	  if (field_is_static (&type->field (i)))
 	    {
 	      gdb_puts ("static ", stream);
-	      fprintf_symbol_filtered (stream,
-				       type->field (i).name (),
-				       current_language->la_language,
-				       DMGL_PARAMS | DMGL_ANSI);
+	      fprintf_symbol (stream,
+			      type->field (i).name (),
+			      current_language->la_language,
+			      DMGL_PARAMS | DMGL_ANSI);
 	    }
 	  else
 	    fputs_styled (type->field (i).name (),
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index f51a99fa9fc..2263a4c90ea 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1638,8 +1638,8 @@ info_address_command (const char *exp, int from_tty)
       if (is_a_field_of_this.type != NULL)
 	{
 	  gdb_printf ("Symbol \"");
-	  fprintf_symbol_filtered (gdb_stdout, exp,
-				   current_language->la_language, DMGL_ANSI);
+	  fprintf_symbol (gdb_stdout, exp,
+			  current_language->la_language, DMGL_ANSI);
 	  gdb_printf ("\" is a field of the local class variable ");
 	  if (current_language->la_language == language_objc)
 	    gdb_printf ("`self'\n");	/* ObjC equivalent of "this" */
@@ -1658,8 +1658,8 @@ info_address_command (const char *exp, int from_tty)
 	  load_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
 
 	  gdb_printf ("Symbol \"");
-	  fprintf_symbol_filtered (gdb_stdout, exp,
-				   current_language->la_language, DMGL_ANSI);
+	  fprintf_symbol (gdb_stdout, exp,
+			  current_language->la_language, DMGL_ANSI);
 	  gdb_printf ("\" is at ");
 	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
 			gdb_stdout);
diff --git a/gdb/utils.c b/gdb/utils.c
index d00f72ba0a5..4ecf2bbda50 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1927,14 +1927,14 @@ print_spaces (int n, struct ui_file *stream)
 \f
 /* C++/ObjC demangler stuff.  */
 
-/* fprintf_symbol_filtered attempts to demangle NAME, a symbol in language
+/* fprintf_symbol attempts to demangle NAME, a symbol in language
    LANG, using demangling args ARG_MODE, and print it filtered to STREAM.
    If the name is not mangled, or the language for the name is unknown, or
    demangling is off, the name is printed in its "raw" form.  */
 
 void
-fprintf_symbol_filtered (struct ui_file *stream, const char *name,
-			 enum language lang, int arg_mode)
+fprintf_symbol (struct ui_file *stream, const char *name,
+		enum language lang, int arg_mode)
 {
   if (name != NULL)
     {
diff --git a/gdb/utils.h b/gdb/utils.h
index e899e899238..b7f39929846 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -302,8 +302,8 @@ extern const char *print_core_address (struct gdbarch *gdbarch,
 
 extern CORE_ADDR string_to_core_addr (const char *my_string);
 
-extern void fprintf_symbol_filtered (struct ui_file *, const char *,
-				     enum language, int);
+extern void fprintf_symbol (struct ui_file *, const char *,
+			    enum language, int);
 
 extern void throw_perror_with_name (enum errors errcode, const char *string)
   ATTRIBUTE_NORETURN;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 16/19] Remove ui_out_flag::unfiltered_output
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (13 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 15/19] Rename fprintf_symbol_filtered Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:37 ` [PATCH 17/19] Remove vfprintf_styled Tom Tromey
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

There is no longer any need for ui_out_flag::unfiltered_output --
nothing ever sets this flag.  This used to be needed to make the
_unfiltered output work, but now only printf_unfiltered can be used,
and it uses the puts_unfiltered method.  This patch removes the flag
and the dead code.
---
 gdb/cli-out.c | 25 +++++--------------------
 gdb/ui-out.h  |  5 +----
 2 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 39279d96397..e0802df352b 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -173,10 +173,7 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align,
     {
       ui_file *stream = m_streams.back ();
       stream->emit_style_escape (style);
-      if (test_flags (unfiltered_output))
-	stream->puts_unfiltered (string);
-      else
-	stream->puts (string);
+      stream->puts (string);
       stream->emit_style_escape (ui_file_style ());
     }
 
@@ -208,10 +205,7 @@ cli_ui_out::do_spaces (int numspaces)
   if (m_suppress_output)
     return;
 
-  if (test_flags (unfiltered_output))
-    gdb_printf (m_streams.back (), "%*s", numspaces, "");
-  else
-    print_spaces (numspaces, m_streams.back ());
+  print_spaces (numspaces, m_streams.back ());
 }
 
 void
@@ -220,10 +214,7 @@ cli_ui_out::do_text (const char *string)
   if (m_suppress_output)
     return;
 
-  if (test_flags (unfiltered_output))
-    gdb_puts (string, m_streams.back ());
-  else
-    gdb_puts (string, m_streams.back ());
+  gdb_puts (string, m_streams.back ());
 }
 
 void
@@ -238,10 +229,7 @@ cli_ui_out::do_message (const ui_file_style &style,
     {
       ui_file *stream = m_streams.back ();
       stream->emit_style_escape (style);
-      if (test_flags (unfiltered_output))
-	stream->puts_unfiltered (str.c_str ());
-      else
-	stream->puts (str.c_str ());
+      stream->puts (str.c_str ());
       stream->emit_style_escape (ui_file_style ());
     }
 }
@@ -380,10 +368,7 @@ cli_ui_out::do_progress_end ()
 void
 cli_ui_out::field_separator ()
 {
-  if (test_flags (unfiltered_output))
-    gdb_putc (' ', m_streams.back ());
-  else
-    gdb_putc (' ', m_streams.back ());
+  gdb_putc (' ', m_streams.back ());
 }
 
 /* Constructor for cli_ui_out.  */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 60dd6fc2d37..b9a59c916ad 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -53,12 +53,9 @@ enum ui_out_flag
 {
   ui_source_list = (1 << 0),
   fix_multi_location_breakpoint_output = (1 << 1),
-  /* For CLI output, this flag is set if unfiltered output is desired.
-     This should only be used by low-level formatting functions.  */
-  unfiltered_output = (1 << 2),
   /* This indicates that %pF should be disallowed in a printf format
      string.  */
-  disallow_ui_out_field = (1 << 3)
+  disallow_ui_out_field = (1 << 2)
 };
 
 DEF_ENUM_FLAGS_TYPE (ui_out_flag, ui_out_flags);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 17/19] Remove vfprintf_styled
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (14 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 16/19] Remove ui_out_flag::unfiltered_output Tom Tromey
@ 2022-01-22  1:37 ` Tom Tromey
  2022-01-22  1:38 ` [PATCH 18/19] Minor comment updates in utils.h Tom Tromey
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Nothing calls vfprintf_styled any more, so remove it.
---
 gdb/utils.c | 11 -----------
 gdb/utils.h |  6 ------
 2 files changed, 17 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index 4ecf2bbda50..0b23e54f185 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1851,17 +1851,6 @@ fprintf_styled (struct ui_file *stream, const ui_file_style &style,
   stream->emit_style_escape (ui_file_style ());
 }
 
-/* See utils.h.  */
-
-void
-vfprintf_styled (struct ui_file *stream, const ui_file_style &style,
-		 const char *format, va_list args)
-{
-  stream->emit_style_escape (style);
-  gdb_vprintf (stream, format, args);
-  stream->emit_style_escape (ui_file_style ());
-}
-
 void
 gdb_printf (const char *format, ...)
 {
diff --git a/gdb/utils.h b/gdb/utils.h
index b7f39929846..011597b4925 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -268,12 +268,6 @@ extern void fprintf_styled (struct ui_file *stream,
 			    ...)
   ATTRIBUTE_PRINTF (3, 4);
 
-extern void vfprintf_styled (struct ui_file *stream,
-			     const ui_file_style &style,
-			     const char *fmt,
-			     va_list args)
-  ATTRIBUTE_PRINTF (3, 0);
-
 /* Like gdb_puts, but styles the output according to STYLE, when
    appropriate.  */
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 18/19] Minor comment updates in utils.h
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (15 preceding siblings ...)
  2022-01-22  1:37 ` [PATCH 17/19] Remove vfprintf_styled Tom Tromey
@ 2022-01-22  1:38 ` Tom Tromey
  2022-03-24 18:05   ` Pedro Alves
  2022-01-22  1:38 ` [PATCH 19/19] Remove unnecessary calls to wrap_here and gdb_flush Tom Tromey
                   ` (3 subsequent siblings)
  20 siblings, 1 reply; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch updates some comments in utils.h to more closely reflect
the new reality.
---
 gdb/utils.h | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/gdb/utils.h b/gdb/utils.h
index 011597b4925..b9baaadbb6f 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -190,11 +190,8 @@ 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);
 
-/* Flush STREAM.  This is a wrapper for ui_file_flush that also
-   flushes any output pending from uses of the *_filtered output
-   functions; that output is kept in a special buffer so that
-   pagination and styling are handled properly.  */
-extern void gdb_flush (struct ui_file *);
+/* Flush STREAM.  */
+extern void gdb_flush (struct ui_file *stream);
 
 /* The current top level's ui_file streams.  */
 
@@ -202,20 +199,16 @@ extern void gdb_flush (struct ui_file *);
 #define gdb_stdout (*current_ui_gdb_stdout_ptr ())
 /* Input stream */
 #define gdb_stdin (*current_ui_gdb_stdin_ptr ())
-/* Serious error notifications */
+/* Serious error notifications.  This bypasses the pager, if one is in
+   use.  */
 #define gdb_stderr (*current_ui_gdb_stderr_ptr ())
-/* Log/debug/trace messages that should bypass normal stdout/stderr
-   filtering.  For moment, always call this stream using
-   *_unfiltered.  In the very near future that restriction shall be
-   removed - either call shall be unfiltered.  (cagney 1999-06-13).  */
+/* Log/debug/trace messages that bypasses the pager, if one is in
+   use.  */
 #define gdb_stdlog (*current_ui_gdb_stdlog_ptr ())
 
 /* Truly global ui_file streams.  These are all defined in main.c.  */
 
-/* Target output that should bypass normal stdout/stderr filtering.
-   For moment, always call this stream using *_unfiltered.  In the
-   very near future that restriction shall be removed - either call
-   shall be unfiltered.  (cagney 1999-07-02).  */
+/* 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;
@@ -224,12 +217,6 @@ extern struct ui_file *gdb_stdtargin;
 
 extern void set_screen_width_and_height (int width, int height);
 
-/* More generic printf like operations.  Filtered versions may return
-   non-locally on error.  As an extension over plain printf, these
-   support some GDB-specific format specifiers.  Particularly useful
-   here are the styling formatters: '%p[', '%p]' and '%ps'.  See
-   ui_out::message for details.  */
-
 extern void gdb_puts (const char *, struct ui_file *);
 
 extern int gdb_putc (int c, struct ui_file *);
@@ -245,6 +232,11 @@ extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
 extern void gdb_vprintf (struct ui_file *, const char *, va_list)
   ATTRIBUTE_PRINTF (2, 0);
 
+/* More generic printf like operations.  As an extension over plain
+   printf, these support some GDB-specific format specifiers.
+   Particularly useful here are the styling formatters: '%p[', '%p]'
+   and '%ps'.  See ui_out::message for details.  */
+
 extern void gdb_printf (struct ui_file *, const char *, ...)
   ATTRIBUTE_PRINTF (2, 3);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 19/19] Remove unnecessary calls to wrap_here and gdb_flush
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (16 preceding siblings ...)
  2022-01-22  1:38 ` [PATCH 18/19] Minor comment updates in utils.h Tom Tromey
@ 2022-01-22  1:38 ` Tom Tromey
  2022-01-22 17:40 ` [PATCH 00/19] Simplify GDB output functions John Baldwin
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-01-22  1:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Various spots in gdb currently know about the wrap buffer, and so are
careful to call wrap_here to be certain that all output has been
flushed.

Now that the pager is just an ordinary stream, this isn't needed, and
a simple call to gdb_flush is enough.

Similarly, there are places where gdb prints to gdb_stderr, but first
flushes gdb_stdout.  stderr_file already flushes gdb_stdout, so these
aren't needed.
---
 gdb/cli/cli-cmds.c |  1 -
 gdb/exceptions.c   | 10 +++-------
 gdb/main.c         |  4 ----
 gdb/printcmd.c     |  1 -
 gdb/psymtab.c      |  1 -
 gdb/top.c          |  1 -
 gdb/utils.c        |  6 ------
 7 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 12b078244b9..2deef7fc053 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -841,7 +841,6 @@ echo_command (const char *text, int from_tty)
   gdb_stdout->reset_style ();
 
   /* Force this output to appear now.  */
-  gdb_stdout->wrap_here (0);
   gdb_flush (gdb_stdout);
 }
 
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 64a36273a61..fdb65b3dc4b 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -46,19 +46,15 @@ print_flush (void)
     }
 
   /* We want all output to appear now, before we print the error.  We
-     have 3 levels of buffering we have to flush (it's possible that
+     have 2 levels of buffering we have to flush (it's possible that
      some of these should be changed to flush the lower-level ones
      too):  */
 
-  /* 1.  The _filtered buffer.  */
-  if (filtered_printing_initialized ())
-    gdb_stdout->wrap_here (0);
-
-  /* 2.  The stdio buffer.  */
+  /* 1.  The stdio buffer.  */
   gdb_flush (gdb_stdout);
   gdb_flush (gdb_stderr);
 
-  /* 3.  The system-level buffer.  */
+  /* 2.  The system-level buffer.  */
   gdb_stdout_serial = serial_fdopen (fileno (ui->outstream));
   if (gdb_stdout_serial)
     {
diff --git a/gdb/main.c b/gdb/main.c
index 84d11b7bbc9..418d3a5bc02 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1121,7 +1121,6 @@ captured_main_1 (struct captured_main_args *context)
   if (print_version)
     {
       print_gdb_version (gdb_stdout, false);
-      gdb_stdout->wrap_here (0);
       gdb_printf ("\n");
       exit (0);
     }
@@ -1135,7 +1134,6 @@ captured_main_1 (struct captured_main_args *context)
   if (print_configuration)
     {
       print_gdb_configuration (gdb_stdout);
-      gdb_stdout->wrap_here (0);
       gdb_printf ("\n");
       exit (0);
     }
@@ -1151,7 +1149,6 @@ captured_main_1 (struct captured_main_args *context)
       print_gdb_version (gdb_stdout, true);
       if (symarg)
 	gdb_printf ("..");
-      gdb_stdout->wrap_here (0);
       gdb_printf ("\n");
       gdb_flush (gdb_stdout);	/* Force to screen during slow
 				   operations.  */
@@ -1172,7 +1169,6 @@ captured_main_1 (struct captured_main_args *context)
       print_gdb_version (gdb_stdout, true);
       if (symarg)
 	gdb_printf ("..");
-      gdb_stdout->wrap_here (0);
       gdb_printf ("\n");
       gdb_flush (gdb_stdout);	/* Force to screen during slow
 				   operations.  */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2263a4c90ea..02a91ff80e2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1498,7 +1498,6 @@ output_command (const char *exp, int from_tty)
 
   annotate_value_end ();
 
-  gdb_stdout->wrap_here (0);
   gdb_flush (gdb_stdout);
 }
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 39307d92296..5293f6f750f 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1426,7 +1426,6 @@ partial_symtab::expand_dependencies (struct objfile *objfile)
 	      gdb_puts ("and ");
 	      gdb_stdout->wrap_here (0);
 	      gdb_printf ("%s...", dependencies[i]->filename);
-	      gdb_stdout->wrap_here (0);	/* Flush output */
 	      gdb_flush (gdb_stdout);
 	    }
 	  dependencies[i]->expand_psymtab (objfile);
diff --git a/gdb/top.c b/gdb/top.c
index b8c1618f65d..031f919302a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1365,7 +1365,6 @@ command_line_input (const char *prompt_arg, const char *annotation_suffix)
       /* Make sure that all output has been output.  Some machines may
 	 let you get away with leaving out some of the gdb_flush, but
 	 not all.  */
-      gdb_stdout->wrap_here (0);
       gdb_flush (gdb_stdout);
       gdb_flush (gdb_stderr);
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 0b23e54f185..3d190e08260 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -146,9 +146,6 @@ vwarning (const char *string, va_list args)
 	  term_state.emplace ();
 	  target_terminal::ours_for_output ();
 	}
-      if (filtered_printing_initialized ())
-	gdb_stdout->wrap_here (0);	/* Force out any buffered output.  */
-      gdb_flush (gdb_stdout);
       if (warning_pre_print)
 	gdb_puts (warning_pre_print, gdb_stderr);
       gdb_vprintf (gdb_stderr, string, args);
@@ -650,9 +647,6 @@ void
 print_sys_errmsg (const char *string, int errcode)
 {
   const char *err = safe_strerror (errcode);
-  /* We want anything which was printed on stdout to come out first, before
-     this message.  */
-  gdb_flush (gdb_stdout);
   gdb_printf (gdb_stderr, "%s: %s.\n", string, err);
 }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/19] Simplify GDB output functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (17 preceding siblings ...)
  2022-01-22  1:38 ` [PATCH 19/19] Remove unnecessary calls to wrap_here and gdb_flush Tom Tromey
@ 2022-01-22 17:40 ` John Baldwin
  2022-03-24 16:25 ` Tom Tromey
  2022-03-24 18:08 ` Pedro Alves
  20 siblings, 0 replies; 25+ messages in thread
From: John Baldwin @ 2022-01-22 17:40 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 1/21/22 5:37 PM, Tom Tromey wrote:
> This series tries to untangle and simplify the GDB output functions.
> 
> By the end of this series, whether a particular bit of output goes
> through the filter will largely depend on the particular stream that
> is being written to.  This means that new code can be much simpler --
> there's no need to decide between using a _filtered or _unfiltered
> form of a function, and in fact, that distinction will no longer
> exist.  (Some unfiltered output is still needed, but only to
> gdb_stdout, and only via a single API.  New such cases should be
> rare.)
> 
> A few cleanups are still possible after this series goes in.  For
> example, ui-file.c could be broken up a bit, and the pager
> implementation should be moved out of utils.c.  I also have a couple
> of pager bug fixes that I will apply afterward.
> 
> This series is based on a couple of still-pending output series that
> I've already sent.  I'll probably check those in reasonably soon.
> 
> Regression tested on x86-64 Fedora 34.

I only skimmed the patches, but I like the idea in general.  I wasn't
previously really aware of when to use filtered vs unfiltered and
just depended on matching existing code in other targets, etc.  To
that end I appreciate making the "default" API clearer.  I do think
having to use 'gdb_*' for functions that would alias stdio is slightly
unfortunate, but I understand the reason and I don't have a
better naming suggestion (gdb_* is consistent with other things like
our local versions of STL types, etc. so is the best choice I think)

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/19] Simplify GDB output functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (18 preceding siblings ...)
  2022-01-22 17:40 ` [PATCH 00/19] Simplify GDB output functions John Baldwin
@ 2022-03-24 16:25 ` Tom Tromey
  2022-03-24 18:08 ` Pedro Alves
  20 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-03-24 16:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This series tries to untangle and simplify the GDB output functions.
Tom> By the end of this series, whether a particular bit of output goes
Tom> through the filter will largely depend on the particular stream that
Tom> is being written to.  This means that new code can be much simpler --
Tom> there's no need to decide between using a _filtered or _unfiltered
Tom> form of a function, and in fact, that distinction will no longer
Tom> exist.

I'm planning to push this soon, but I wanted to warn everyone that this
renames the output functions.  For example, fprintf_filtered no longer
exists, it will be an overload of "gdb_printf".  So, this may interfere
with rebasing.  I do have some scripts that will do this renaming for
you (including reindenting the code), but personally I've found just
doing the post-rebase touchups by hand to be easy enough.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 18/19] Minor comment updates in utils.h
  2022-01-22  1:38 ` [PATCH 18/19] Minor comment updates in utils.h Tom Tromey
@ 2022-03-24 18:05   ` Pedro Alves
  2022-03-28 20:29     ` Tom Tromey
  0 siblings, 1 reply; 25+ messages in thread
From: Pedro Alves @ 2022-03-24 18:05 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Just some nits.

On 2022-01-22 01:38, Tom Tromey wrote:

>  /* Truly global ui_file streams.  These are all defined in main.c.  */
>  
> -/* Target output that should bypass normal stdout/stderr filtering.
> -   For moment, always call this stream using *_unfiltered.  In the
> -   very near future that restriction shall be removed - either call
> -   shall be unfiltered.  (cagney 1999-07-02).  */
> +/* 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;
> @@ -224,12 +217,6 @@ extern struct ui_file *gdb_stdtargin;
>  
>  extern void set_screen_width_and_height (int width, int height);
>  
> -/* More generic printf like operations.  Filtered versions may return
> -   non-locally on error.  As an extension over plain printf, these
> -   support some GDB-specific format specifiers.  Particularly useful
> -   here are the styling formatters: '%p[', '%p]' and '%ps'.  See
> -   ui_out::message for details.  */
> -

This comment might have been originally put here and not close to gdb_printf
(old printf_filtered) because it was alluding to the whole family of
stdio.h functions, puts, putc, etc.

Maybe leave such a comment here, like:

/* Generic stdio-like operations.  */


>  extern void gdb_puts (const char *, struct ui_file *);
>  
>  extern int gdb_putc (int c, struct ui_file *);
> @@ -245,6 +232,11 @@ extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
>  extern void gdb_vprintf (struct ui_file *, const char *, va_list)
>    ATTRIBUTE_PRINTF (2, 0);

Since GDB-specific format specifiers apply to gdb_vprintf as well at least,
then it seems to me from the diff context that the comment should be above it,
not below.

You may want to hyphenate "printf like" as printf-like instead to make it a bit clearer.
Maybe remove the "More" as well, I'm not sure why it is there, is there some
preceding comment talking about generic printf like operations, such that here we'd
have more of the same?

>  
> +/* More generic printf like operations.  As an extension over plain
> +   printf, these support some GDB-specific format specifiers.
> +   Particularly useful here are the styling formatters: '%p[', '%p]'
> +   and '%ps'.  See ui_out::message for details.  */
> +
>  extern void gdb_printf (struct ui_file *, const char *, ...)
>    ATTRIBUTE_PRINTF (2, 3);
>  


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/19] Simplify GDB output functions
  2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
                   ` (19 preceding siblings ...)
  2022-03-24 16:25 ` Tom Tromey
@ 2022-03-24 18:08 ` Pedro Alves
  2022-03-29 19:38   ` Tom Tromey
  20 siblings, 1 reply; 25+ messages in thread
From: Pedro Alves @ 2022-03-24 18:08 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2022-01-22 01:37, Tom Tromey wrote:
> This series tries to untangle and simplify the GDB output functions.
> 
> By the end of this series, whether a particular bit of output goes
> through the filter will largely depend on the particular stream that
> is being written to.  This means that new code can be much simpler --
> there's no need to decide between using a _filtered or _unfiltered
> form of a function, and in fact, that distinction will no longer
> exist.  (Some unfiltered output is still needed, but only to
> gdb_stdout, and only via a single API.  New such cases should be
> rare.)
> 
> A few cleanups are still possible after this series goes in.  For
> example, ui-file.c could be broken up a bit, and the pager
> implementation should be moved out of utils.c.  I also have a couple
> of pager bug fixes that I will apply afterward.
> 
> This series is based on a couple of still-pending output series that
> I've already sent.  I'll probably check those in reasonably soon.
> 
> Regression tested on x86-64 Fedora 34.

I hadn't seen this yet, but now that I did, I excitingly skimmed it.
I sent nit picking comments to patch #18, but otherwise it all looks
great.

Thanks a lot for doing this.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 18/19] Minor comment updates in utils.h
  2022-03-24 18:05   ` Pedro Alves
@ 2022-03-28 20:29     ` Tom Tromey
  0 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-03-28 20:29 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> This comment might have been originally put here and not close to gdb_printf
Pedro> (old printf_filtered) because it was alluding to the whole family of
Pedro> stdio.h functions, puts, putc, etc.

Pedro> Maybe leave such a comment here, like:

Pedro> /* Generic stdio-like operations.  */

I made this change.

Pedro> Since GDB-specific format specifiers apply to gdb_vprintf as well at least,
Pedro> then it seems to me from the diff context that the comment should be above it,
Pedro> not below.

Agreed, I moved it there.

Pedro> You may want to hyphenate "printf like" as printf-like instead to make it a bit clearer.

Done.

Pedro> Maybe remove the "More" as well, I'm not sure why it is there, is there some
Pedro> preceding comment talking about generic printf like operations, such that here we'd
Pedro> have more of the same?

I don't see one, so I made this change as well.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/19] Simplify GDB output functions
  2022-03-24 18:08 ` Pedro Alves
@ 2022-03-29 19:38   ` Tom Tromey
  0 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2022-03-29 19:38 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

Pedro> I hadn't seen this yet, but now that I did, I excitingly skimmed it.
Pedro> I sent nit picking comments to patch #18, but otherwise it all looks
Pedro> great.

Pedro> Thanks a lot for doing this.

Thanks.  I have rebased this and re-tested it, and I'm going to check it
in soon.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-03-29 19:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22  1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
2022-01-22  1:37 ` [PATCH 01/19] Use unfiltered output in annotate.c Tom Tromey
2022-01-22  1:37 ` [PATCH 02/19] Remove some uses of printf_unfiltered Tom Tromey
2022-01-22  1:37 ` [PATCH 03/19] Only have one API for unfiltered output Tom Tromey
2022-01-22  1:37 ` [PATCH 04/19] Add puts_unfiltered method to ui_file Tom Tromey
2022-01-22  1:37 ` [PATCH 05/19] Add style-escape methods " Tom Tromey
2022-01-22  1:37 ` [PATCH 06/19] Remove vfprintf_styled_no_gdbfmt Tom Tromey
2022-01-22  1:37 ` [PATCH 07/19] Change the pager to a ui_file Tom Tromey
2022-01-22  1:37 ` [PATCH 08/19] Remove fputs_styled_unfiltered Tom Tromey
2022-01-22  1:37 ` [PATCH 09/19] Unify vprintf functions Tom Tromey
2022-01-22  1:37 ` [PATCH 10/19] Unify gdb puts functions Tom Tromey
2022-01-22  1:37 ` [PATCH 11/19] Unify gdb putc functions Tom Tromey
2022-01-22  1:37 ` [PATCH 13/19] Rename print_spaces_filtered Tom Tromey
2022-01-22  1:37 ` [PATCH 14/19] Rename puts_filtered_tabular Tom Tromey
2022-01-22  1:37 ` [PATCH 15/19] Rename fprintf_symbol_filtered Tom Tromey
2022-01-22  1:37 ` [PATCH 16/19] Remove ui_out_flag::unfiltered_output Tom Tromey
2022-01-22  1:37 ` [PATCH 17/19] Remove vfprintf_styled Tom Tromey
2022-01-22  1:38 ` [PATCH 18/19] Minor comment updates in utils.h Tom Tromey
2022-03-24 18:05   ` Pedro Alves
2022-03-28 20:29     ` Tom Tromey
2022-01-22  1:38 ` [PATCH 19/19] Remove unnecessary calls to wrap_here and gdb_flush Tom Tromey
2022-01-22 17:40 ` [PATCH 00/19] Simplify GDB output functions John Baldwin
2022-03-24 16:25 ` Tom Tromey
2022-03-24 18:08 ` Pedro Alves
2022-03-29 19:38   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).