From 830df12588cfa80be673e710bee22761752ead11 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 8 Jan 2022 16:31:44 -0700 Subject: Remove some uses of printf_unfiltered 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 934fdba..ee128a9 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -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); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index ea06ceb..5be234f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -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; } } diff --git a/gdb/inferior.c b/gdb/inferior.c index 48d5c8b..8aa93a0 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -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 diff --git a/gdb/infrun.c b/gdb/infrun.c index 737710f..580075f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -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: diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index d97a770..e782f6f 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -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); } diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 530ece0..487a2af 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 8ede3d6..e377fdb 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 9e90142..b8389ca 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 840201d..4751645 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -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; diff --git a/gdb/remote.c b/gdb/remote.c index 219e720..67fd713 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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) { diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 44e990b..0bfdbdf 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 69f2991..37fc898 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 27fdf24..935341d 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -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 ()) { diff --git a/gdb/target.c b/gdb/target.c index e3df927..8d0d04b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -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! */ diff --git a/gdb/thread.c b/gdb/thread.c index 9d0693b..84c4cf4 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -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; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 81e26fe..c933034 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; } -- cgit v1.1