public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 02/19] Remove some uses of printf_unfiltered
Date: Fri, 21 Jan 2022 18:37:44 -0700	[thread overview]
Message-ID: <20220122013801.666659-3-tom@tromey.com> (raw)
In-Reply-To: <20220122013801.666659-1-tom@tromey.com>

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


  parent reply	other threads:[~2022-01-22  1:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20220122013801.666659-3-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

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

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