Use filtered output in ordinary commands

Many otherwise ordinary commands choose to use unfiltered output
rather than filtered.  I don't think there's any reason for this, so
this changes many such commands to use filtered output instead.

Note that complete_command is not touched due to a comment there
explaining why unfiltered output is believed to be used.
This commit is contained in:
Tom Tromey 2021-12-24 22:31:53 -07:00
parent b68178b9cb
commit b58f47ab4c
18 changed files with 89 additions and 89 deletions

View file

@ -11535,19 +11535,19 @@ clear_command (const char *arg, int from_tty)
if (from_tty) if (from_tty)
{ {
if (found.size () == 1) if (found.size () == 1)
printf_unfiltered (_("Deleted breakpoint ")); printf_filtered (_("Deleted breakpoint "));
else else
printf_unfiltered (_("Deleted breakpoints ")); printf_filtered (_("Deleted breakpoints "));
} }
for (breakpoint *iter : found) for (breakpoint *iter : found)
{ {
if (from_tty) if (from_tty)
printf_unfiltered ("%d ", iter->number); printf_filtered ("%d ", iter->number);
delete_breakpoint (iter); delete_breakpoint (iter);
} }
if (from_tty) if (from_tty)
putchar_unfiltered ('\n'); putchar_filtered ('\n');
} }
/* Delete breakpoint in BS if they are `delete' breakpoints and /* Delete breakpoint in BS if they are `delete' breakpoints and
@ -14010,7 +14010,7 @@ map_breakpoint_number_range (std::pair<int, int> bp_num_range,
break; break;
} }
if (!match) if (!match)
printf_unfiltered (_("No breakpoint number %d.\n"), i); printf_filtered (_("No breakpoint number %d.\n"), i);
} }
} }
} }
@ -14948,7 +14948,7 @@ get_tracepoint_by_number (const char **arg,
if (t->number == tpnum) if (t->number == tpnum)
return (struct tracepoint *) t; return (struct tracepoint *) t;
printf_unfiltered ("No tracepoint number %d.\n", tpnum); printf_filtered ("No tracepoint number %d.\n", tpnum);
return NULL; return NULL;
} }

View file

@ -501,12 +501,12 @@ pwd_command (const char *args, int from_tty)
safe_strerror (errno)); safe_strerror (errno));
if (strcmp (cwd.get (), current_directory) != 0) if (strcmp (cwd.get (), current_directory) != 0)
printf_unfiltered (_("Working directory %ps\n (canonically %ps).\n"), printf_filtered (_("Working directory %ps\n (canonically %ps).\n"),
styled_string (file_name_style.style (), styled_string (file_name_style.style (),
current_directory), current_directory),
styled_string (file_name_style.style (), cwd.get ())); styled_string (file_name_style.style (), cwd.get ()));
else else
printf_unfiltered (_("Working directory %ps.\n"), printf_filtered (_("Working directory %ps.\n"),
styled_string (file_name_style.style (), styled_string (file_name_style.style (),
current_directory)); current_directory));
} }

View file

@ -115,7 +115,7 @@ handle_redirections (int from_tty)
{ {
if (!saved_filename.empty ()) if (!saved_filename.empty ())
{ {
fprintf_unfiltered (gdb_stdout, "Already logging to %s.\n", printf_filtered ("Already logging to %s.\n",
saved_filename.c_str ()); saved_filename.c_str ());
return; return;
} }
@ -128,17 +128,17 @@ handle_redirections (int from_tty)
if (from_tty) if (from_tty)
{ {
if (!logging_redirect) if (!logging_redirect)
fprintf_unfiltered (gdb_stdout, "Copying output to %s.\n", printf_filtered ("Copying output to %s.\n",
logging_filename.c_str ()); logging_filename.c_str ());
else else
fprintf_unfiltered (gdb_stdout, "Redirecting output to %s.\n", printf_filtered ("Redirecting output to %s.\n",
logging_filename.c_str ()); logging_filename.c_str ());
if (!debug_redirect) if (!debug_redirect)
fprintf_unfiltered (gdb_stdout, "Copying debug output to %s.\n", printf_filtered ("Copying debug output to %s.\n",
logging_filename.c_str ()); logging_filename.c_str ());
else else
fprintf_unfiltered (gdb_stdout, "Redirecting debug output to %s.\n", printf_filtered ("Redirecting debug output to %s.\n",
logging_filename.c_str ()); logging_filename.c_str ());
} }
@ -177,7 +177,7 @@ set_logging_off (const char *args, int from_tty)
pop_output_files (); pop_output_files ();
if (from_tty) if (from_tty)
fprintf_unfiltered (gdb_stdout, "Done logging to %s.\n", printf_filtered ("Done logging to %s.\n",
saved_filename.c_str ()); saved_filename.c_str ());
saved_filename.clear (); saved_filename.clear ();
} }

View file

@ -1058,7 +1058,7 @@ cp_lookup_transparent_type_loop (const char *name,
static void static void
maintenance_cplus_namespace (const char *args, int from_tty) maintenance_cplus_namespace (const char *args, int from_tty)
{ {
printf_unfiltered (_("The `maint namespace' command was removed.\n")); printf_filtered (_("The `maint namespace' command was removed.\n"));
} }
void _initialize_cp_namespace (); void _initialize_cp_namespace ();

View file

@ -2185,7 +2185,7 @@ first_component_command (const char *arg, int from_tty)
memcpy (prefix, arg, len); memcpy (prefix, arg, len);
prefix[len] = '\0'; prefix[len] = '\0';
printf_unfiltered ("%s\n", prefix); printf_filtered ("%s\n", prefix);
} }
/* Implement "info vtbl". */ /* Implement "info vtbl". */

View file

@ -257,8 +257,8 @@ show_index_cache_command (const char *arg, int from_tty)
/* Call all "show index-cache" subcommands. */ /* Call all "show index-cache" subcommands. */
cmd_show_list (show_index_cache_prefix_list, from_tty); cmd_show_list (show_index_cache_prefix_list, from_tty);
printf_unfiltered ("\n"); printf_filtered ("\n");
printf_unfiltered printf_filtered
(_("The index cache is currently %s.\n"), (_("The index cache is currently %s.\n"),
global_index_cache.enabled () ? _("enabled") : _("disabled")); global_index_cache.enabled () ? _("enabled") : _("disabled"));
} }
@ -316,12 +316,12 @@ show_index_cache_stats_command (const char *arg, int from_tty)
if (in_show_index_cache_command) if (in_show_index_cache_command)
{ {
indent = " "; indent = " ";
printf_unfiltered ("\n"); printf_filtered ("\n");
} }
printf_unfiltered (_("%s Cache hits (this session): %u\n"), printf_filtered (_("%s Cache hits (this session): %u\n"),
indent, global_index_cache.n_hits ()); indent, global_index_cache.n_hits ());
printf_unfiltered (_("%sCache misses (this session): %u\n"), printf_filtered (_("%sCache misses (this session): %u\n"),
indent, global_index_cache.n_misses ()); indent, global_index_cache.n_misses ());
} }

View file

@ -378,7 +378,7 @@ exec_file_attach (const char *filename, int from_tty)
if (!filename) if (!filename)
{ {
if (from_tty) if (from_tty)
printf_unfiltered (_("No executable file now.\n")); printf_filtered (_("No executable file now.\n"));
set_gdbarch_from_file (NULL); set_gdbarch_from_file (NULL);
} }

View file

@ -116,7 +116,7 @@ static void
maintenance_time_display (const char *args, int from_tty) maintenance_time_display (const char *args, int from_tty)
{ {
if (args == NULL || *args == '\0') if (args == NULL || *args == '\0')
printf_unfiltered (_("\"maintenance time\" takes a numeric argument.\n")); printf_filtered (_("\"maintenance time\" takes a numeric argument.\n"));
else else
set_per_command_time (strtol (args, NULL, 10)); set_per_command_time (strtol (args, NULL, 10));
} }
@ -125,7 +125,7 @@ static void
maintenance_space_display (const char *args, int from_tty) maintenance_space_display (const char *args, int from_tty)
{ {
if (args == NULL || *args == '\0') if (args == NULL || *args == '\0')
printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n"); printf_filtered ("\"maintenance space\" takes a numeric argument.\n");
else else
set_per_command_space (strtol (args, NULL, 10)); set_per_command_space (strtol (args, NULL, 10));
} }
@ -632,7 +632,7 @@ maintenance_deprecate (const char *args, int from_tty)
{ {
if (args == NULL || *args == '\0') if (args == NULL || *args == '\0')
{ {
printf_unfiltered (_("\"maintenance deprecate\" takes an argument,\n\ printf_filtered (_("\"maintenance deprecate\" takes an argument,\n\
the command you want to deprecate, and optionally the replacement command\n\ the command you want to deprecate, and optionally the replacement command\n\
enclosed in quotes.\n")); enclosed in quotes.\n"));
} }
@ -646,7 +646,7 @@ maintenance_undeprecate (const char *args, int from_tty)
{ {
if (args == NULL || *args == '\0') if (args == NULL || *args == '\0')
{ {
printf_unfiltered (_("\"maintenance undeprecate\" takes an argument, \n\ printf_filtered (_("\"maintenance undeprecate\" takes an argument, \n\
the command you want to undeprecate.\n")); the command you want to undeprecate.\n"));
} }

View file

@ -121,7 +121,7 @@ create_user_mem_region (CORE_ADDR lo, CORE_ADDR hi,
/* lo == hi is a useless empty region. */ /* lo == hi is a useless empty region. */
if (lo >= hi && hi != 0) if (lo >= hi && hi != 0)
{ {
printf_unfiltered (_("invalid memory region: low >= high\n")); printf_filtered (_("invalid memory region: low >= high\n"));
return; return;
} }
@ -148,7 +148,7 @@ create_user_mem_region (CORE_ADDR lo, CORE_ADDR hi,
|| (hi > n.lo && (hi <= n.hi || n.hi == 0)) || (hi > n.lo && (hi <= n.hi || n.hi == 0))
|| (lo <= n.lo && ((hi >= n.hi && n.hi != 0) || hi == 0))) || (lo <= n.lo && ((hi >= n.hi && n.hi != 0) || hi == 0)))
{ {
printf_unfiltered (_("overlapping memory region\n")); printf_filtered (_("overlapping memory region\n"));
return; return;
} }
} }
@ -347,7 +347,7 @@ info_mem_command (const char *args, int from_tty)
if (mem_region_list->empty ()) if (mem_region_list->empty ())
{ {
printf_unfiltered (_("There are no memory regions defined.\n")); printf_filtered (_("There are no memory regions defined.\n"));
return; return;
} }
@ -474,7 +474,7 @@ mem_enable (int num)
m.enabled_p = 1; m.enabled_p = 1;
return; return;
} }
printf_unfiltered (_("No memory region number %d.\n"), num); printf_filtered (_("No memory region number %d.\n"), num);
} }
static void static void
@ -512,7 +512,7 @@ mem_disable (int num)
m.enabled_p = 0; m.enabled_p = 0;
return; return;
} }
printf_unfiltered (_("No memory region number %d.\n"), num); printf_filtered (_("No memory region number %d.\n"), num);
} }
static void static void
@ -545,7 +545,7 @@ mem_delete (int num)
{ {
if (!mem_region_list) if (!mem_region_list)
{ {
printf_unfiltered (_("No memory region number %d.\n"), num); printf_filtered (_("No memory region number %d.\n"), num);
return; return;
} }
@ -558,7 +558,7 @@ mem_delete (int num)
if (it != mem_region_list->end ()) if (it != mem_region_list->end ())
mem_region_list->erase (it); mem_region_list->erase (it);
else else
printf_unfiltered (_("No memory region number %d.\n"), num); printf_filtered (_("No memory region number %d.\n"), num);
} }
static void static void

View file

@ -2058,7 +2058,7 @@ map_display_numbers (const char *args,
return item->number == num; return item->number == num;
}); });
if (iter == all_displays.end ()) if (iter == all_displays.end ())
printf_unfiltered (_("No display number %d.\n"), num); printf_filtered (_("No display number %d.\n"), num);
else else
function (iter->get ()); function (iter->get ());
} }
@ -2253,7 +2253,7 @@ disable_display (int num)
d->enabled_p = false; d->enabled_p = false;
return; return;
} }
printf_unfiltered (_("No display number %d.\n"), num); printf_filtered (_("No display number %d.\n"), num);
} }
void void
@ -2274,7 +2274,7 @@ static void
info_display_command (const char *ignore, int from_tty) info_display_command (const char *ignore, int from_tty)
{ {
if (all_displays.empty ()) if (all_displays.empty ())
printf_unfiltered (_("There are no auto-display expressions now.\n")); printf_filtered (_("There are no auto-display expressions now.\n"));
else else
printf_filtered (_("Auto-display expressions now in effect:\n\ printf_filtered (_("Auto-display expressions now in effect:\n\
Num Enb Expression\n")); Num Enb Expression\n"));

View file

@ -279,13 +279,13 @@ cmd_record_delete (const char *args, int from_tty)
if (!target_record_is_replaying (inferior_ptid)) if (!target_record_is_replaying (inferior_ptid))
{ {
printf_unfiltered (_("Already at end of record list.\n")); printf_filtered (_("Already at end of record list.\n"));
return; return;
} }
if (!target_supports_delete_record ()) if (!target_supports_delete_record ())
{ {
printf_unfiltered (_("The current record target does not support " printf_filtered (_("The current record target does not support "
"this operation.\n")); "this operation.\n"));
return; return;
} }
@ -308,7 +308,7 @@ cmd_record_stop (const char *args, int from_tty)
record_stop (t); record_stop (t);
record_unpush (t); record_unpush (t);
printf_unfiltered (_("Process record is stopped and all execution " printf_filtered (_("Process record is stopped and all execution "
"logs are deleted.\n")); "logs are deleted.\n"));
gdb::observers::record_changed.notify (current_inferior (), 0, NULL, NULL); gdb::observers::record_changed.notify (current_inferior (), 0, NULL, NULL);

View file

@ -1290,7 +1290,7 @@ show_system_call_allowed (const char *args, int from_tty)
if (args) if (args)
error (_("Garbage after \"show remote " error (_("Garbage after \"show remote "
"system-call-allowed\" command: `%s'"), args); "system-call-allowed\" command: `%s'"), args);
printf_unfiltered ("Calling host system(3) call from target is %sallowed\n", printf_filtered ("Calling host system(3) call from target is %sallowed\n",
remote_fio_system_call_allowed ? "" : "not "); remote_fio_system_call_allowed ? "" : "not ");
} }

View file

@ -2276,7 +2276,7 @@ add_symbol_file_command (const char *args, int from_tty)
statements because hex_string returns a local static statements because hex_string returns a local static
string. */ string. */
printf_unfiltered (_("add symbol table from file \"%s\""), printf_filtered (_("add symbol table from file \"%s\""),
filename.get ()); filename.get ());
section_addr_info section_addrs; section_addr_info section_addrs;
std::vector<sect_opt>::const_iterator it = sect_opts.begin (); std::vector<sect_opt>::const_iterator it = sect_opts.begin ();
@ -2289,7 +2289,7 @@ add_symbol_file_command (const char *args, int from_tty)
const char *sec = it->name; const char *sec = it->name;
if (section_addrs.empty ()) if (section_addrs.empty ())
printf_unfiltered (_(" at\n")); printf_filtered (_(" at\n"));
addr = parse_and_eval_address (val); addr = parse_and_eval_address (val);
/* Here we store the section offsets in the order they were /* Here we store the section offsets in the order they were
@ -2309,13 +2309,13 @@ add_symbol_file_command (const char *args, int from_tty)
so we can't determine what section names are valid. */ so we can't determine what section names are valid. */
} }
if (seen_offset) if (seen_offset)
printf_unfiltered (_("%s offset by %s\n"), printf_filtered (_("%s offset by %s\n"),
(section_addrs.empty () (section_addrs.empty ()
? _(" with all sections") ? _(" with all sections")
: _("with other sections")), : _("with other sections")),
paddress (gdbarch, offset)); paddress (gdbarch, offset));
else if (section_addrs.empty ()) else if (section_addrs.empty ())
printf_unfiltered ("\n"); printf_filtered ("\n");
if (from_tty && (!query ("%s", ""))) if (from_tty && (!query ("%s", "")))
error (_("Not confirmed.")); error (_("Not confirmed."));
@ -3262,7 +3262,7 @@ map_overlay_command (const char *args, int from_tty)
sec2)) sec2))
{ {
if (info_verbose) if (info_verbose)
printf_unfiltered (_("Note: section %s unmapped by overlap\n"), printf_filtered (_("Note: section %s unmapped by overlap\n"),
bfd_section_name (sec2->the_bfd_section)); bfd_section_name (sec2->the_bfd_section));
sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */ sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
} }
@ -3311,7 +3311,7 @@ overlay_auto_command (const char *args, int from_tty)
overlay_debugging = ovly_auto; overlay_debugging = ovly_auto;
enable_overlay_breakpoints (); enable_overlay_breakpoints ();
if (info_verbose) if (info_verbose)
printf_unfiltered (_("Automatic overlay debugging enabled.")); printf_filtered (_("Automatic overlay debugging enabled."));
} }
/* Function: overlay_manual_command /* Function: overlay_manual_command
@ -3324,7 +3324,7 @@ overlay_manual_command (const char *args, int from_tty)
overlay_debugging = ovly_on; overlay_debugging = ovly_on;
disable_overlay_breakpoints (); disable_overlay_breakpoints ();
if (info_verbose) if (info_verbose)
printf_unfiltered (_("Overlay debugging enabled.")); printf_filtered (_("Overlay debugging enabled."));
} }
/* Function: overlay_off_command /* Function: overlay_off_command
@ -3337,7 +3337,7 @@ overlay_off_command (const char *args, int from_tty)
overlay_debugging = ovly_off; overlay_debugging = ovly_off;
disable_overlay_breakpoints (); disable_overlay_breakpoints ();
if (info_verbose) if (info_verbose)
printf_unfiltered (_("Overlay debugging disabled.")); printf_filtered (_("Overlay debugging disabled."));
} }
static void static void

View file

@ -385,7 +385,7 @@ new_ui_command (const char *args, int from_tty)
ui.release (); ui.release ();
} }
printf_unfiltered ("New UI allocated\n"); printf_filtered ("New UI allocated\n");
} }
/* Handler for SIGHUP. */ /* Handler for SIGHUP. */
@ -652,7 +652,7 @@ execute_command (const char *p, int from_tty)
std::string prefixname = c->prefixname (); std::string prefixname = c->prefixname ();
std::string prefixname_no_space std::string prefixname_no_space
= prefixname.substr (0, prefixname.length () - 1); = prefixname.substr (0, prefixname.length () - 1);
printf_unfiltered printf_filtered
("\"%s\" must be followed by the name of a subcommand.\n", ("\"%s\" must be followed by the name of a subcommand.\n",
prefixname_no_space.c_str ()); prefixname_no_space.c_str ());
help_list (*c->subcommands, prefixname.c_str (), all_commands, help_list (*c->subcommands, prefixname.c_str (), all_commands,

View file

@ -2195,7 +2195,7 @@ tfind_1 (enum trace_find_type type, int num,
} }
else else
{ {
printf_unfiltered (_("Found trace frame %d, tracepoint %d\n"), printf_filtered (_("Found trace frame %d, tracepoint %d\n"),
traceframe_number, tracepoint_number); traceframe_number, tracepoint_number);
} }
} }
@ -2204,9 +2204,9 @@ tfind_1 (enum trace_find_type type, int num,
if (uiout->is_mi_like_p ()) if (uiout->is_mi_like_p ())
uiout->field_string ("found", "0"); uiout->field_string ("found", "0");
else if (type == tfind_number && num == -1) else if (type == tfind_number && num == -1)
printf_unfiltered (_("No longer looking at any trace frame\n")); printf_filtered (_("No longer looking at any trace frame\n"));
else /* This case may never occur, check. */ else /* This case may never occur, check. */
printf_unfiltered (_("No trace frame found\n")); printf_filtered (_("No trace frame found\n"));
} }
/* If we're in nonstop mode and getting out of looking at trace /* If we're in nonstop mode and getting out of looking at trace

View file

@ -606,7 +606,7 @@ tui_reg_command (const char *args, int from_tty)
struct reggroup *group; struct reggroup *group;
int first; int first;
printf_unfiltered (_("\"tui reg\" must be followed by the name of " printf_filtered (_("\"tui reg\" must be followed by the name of "
"either a register group,\nor one of 'next' " "either a register group,\nor one of 'next' "
"or 'prev'. Known register groups are:\n")); "or 'prev'. Known register groups are:\n"));
@ -615,11 +615,11 @@ tui_reg_command (const char *args, int from_tty)
first = 0, group = reggroup_next (gdbarch, group)) first = 0, group = reggroup_next (gdbarch, group))
{ {
if (!first) if (!first)
printf_unfiltered (", "); printf_filtered (", ");
printf_unfiltered ("%s", reggroup_name (group)); printf_filtered ("%s", reggroup_name (group));
} }
printf_unfiltered ("\n"); printf_filtered ("\n");
} }
} }

View file

@ -223,9 +223,9 @@ maintenance_print_user_registers (const char *args, int from_tty)
regs = (struct gdb_user_regs *) gdbarch_data (gdbarch, user_regs_data); regs = (struct gdb_user_regs *) gdbarch_data (gdbarch, user_regs_data);
regnum = gdbarch_num_cooked_regs (gdbarch); regnum = gdbarch_num_cooked_regs (gdbarch);
fprintf_unfiltered (gdb_stdout, " %-11s %3s\n", "Name", "Nr"); printf_filtered (" %-11s %3s\n", "Name", "Nr");
for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum) for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
fprintf_unfiltered (gdb_stdout, " %-11s %3d\n", reg->name, regnum); printf_filtered (" %-11s %3d\n", reg->name, regnum);
} }
void _initialize_user_regs (); void _initialize_user_regs ();

View file

@ -2649,7 +2649,7 @@ show_convenience (const char *ignore, int from_tty)
The user can't create them except via Python, and if Python support The user can't create them except via Python, and if Python support
is installed this message will never be printed ($_streq will is installed this message will never be printed ($_streq will
exist). */ exist). */
printf_unfiltered (_("No debugger convenience variables now defined.\n" printf_filtered (_("No debugger convenience variables now defined.\n"
"Convenience variables have " "Convenience variables have "
"names starting with \"$\";\n" "names starting with \"$\";\n"
"use \"set\" as in \"set " "use \"set\" as in \"set "