Remove some uses of printf_unfiltered
authorTom Tromey <tom@tromey.com>
Sat, 8 Jan 2022 23:31:44 +0000 (16:31 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 29 Mar 2022 18:46:24 +0000 (12:46 -0600)
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.

16 files changed:
gdb/fbsd-nat.c
gdb/infcmd.c
gdb/inferior.c
gdb/infrun.c
gdb/linux-nat.c
gdb/linux-thread-db.c
gdb/mdebugread.c
gdb/netbsd-nat.c
gdb/procfs.c
gdb/remote.c
gdb/sol-thread.c
gdb/solib-svr4.c
gdb/solib.c
gdb/target.c
gdb/thread.c
gdb/windows-nat.c

index 934fdbad6efb640fdfdeeb6adc2a5c0bbd9bd260..ee128a9e707f91e93100a41c4109155ef6b7d40b 100644 (file)
@@ -1296,8 +1296,8 @@ fbsd_nat_target::wait_1 (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 ());
                  low_delete_thread (thr);
                  delete_thread (thr);
                }
index ea06ceb992cf0d185869d3495f404bf747bdd621..5be234f75861a337c01231851c7655cf1ae36cf2 100644 (file)
@@ -1179,11 +1179,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;
            }
        }
index 48d5c8bfd1545759fe94a54fc82c6e94583ad55d..8aa93a00acf1891e9ad83207beb4381646291825 100644 (file)
@@ -164,11 +164,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;
@@ -264,9 +264,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
index 737710f5bae7c7c7dd7f03fac540a6dc455c43cb..580075fa16e4d3dceadf15d79ccb49f3afc55588 100644 (file)
@@ -1130,9 +1130,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.  */
@@ -4159,7 +4159,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.  */
@@ -8851,7 +8851,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:
index d97a770bf83bccea9bb11cf0175ff0d706dbc6f9..e782f6f4b345340c40c5a95afd8ac0d705c8a989 100644 (file)
@@ -894,8 +894,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);
     }
index 530ece08db1ba5eb28c13ae40bb1489388e14ef1..487a2afa8f8c5189d0d983db8ca5972949cf546e 100644 (file)
@@ -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
index 8ede3d6aa269bb4bd45933137b8432d420a0d6c9..e377fdb96208a2fa966044e5cbaf57da4a085592 100644 (file)
@@ -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
 }
index 9e9014283cde0dc0a4c96f7d784737421d81120c..b8389ca14b602d7753f4d8bca7e70111c1b53ab6 100644 (file)
@@ -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);
        }
 
index 840201d18975d367327d0635c6bb2ee41325b245..47516450b53e7847b99956427e6b705aa38fbaac 100644 (file)
@@ -2122,8 +2122,8 @@ wait_again:
                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 @@ wait_again:
                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;
index 219e7203a9474585938fed9f1dfb2285ae78931d..67fd71332d832c4b42a120307971dbf105f43873 100644 (file)
@@ -6005,8 +6005,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
     {
@@ -9961,7 +9961,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)
@@ -12312,8 +12312,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)
        {
index 44e990b6e5f064c1a858f1638112bc83175e7286..0bfdbdf5037855b1922c3dee8215b9bee716e603 100644 (file)
@@ -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);
index 69f2991f5e641c0e3fd79fe84b7a4d739c1ac100..37fc898d2aae93a61c6a72d75040c90d703a2815 100644 (file)
@@ -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;
index 27fdf24c0b12919c26ca1a0983a11bbcca6ef2ca..935341dcb4b66526bb6326c93f0982713d8bf474 100644 (file)
@@ -1022,11 +1022,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++;
@@ -1071,8 +1071,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;
@@ -1083,7 +1083,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)
@@ -1359,7 +1359,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 ())
     {
index e3df9275c9a0b5512c99861fa9d12c7950442962..8d0d04b85c6dd04e601c6389552f0a1172da3273 100644 (file)
@@ -3646,11 +3646,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  */
@@ -3664,11 +3664,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!  */
index 9d0693bd0b8ba54aebb05d26429b8ed9199949f1..84c4cf4b87aa34e444a5db19a5eebfba95d5120f 100644 (file)
@@ -293,7 +293,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;
index 81e26fe4759fc40fcc826a2804a2db809b1fb7f3..c933034346f881de5d0201806f8a126ee654501b 100644 (file)
@@ -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;
     }