Unify gdb printf functions

Now that filtered and unfiltered output can be treated identically, we
can unify the printf family of functions.  This is done under the name
"gdb_printf".  Most of this patch was written by script.
This commit is contained in:
Tom Tromey 2022-01-02 11:46:15 -07:00
parent a11ac3b3e8
commit 6cb06a8cda
249 changed files with 8449 additions and 8463 deletions

View file

@ -460,7 +460,7 @@ static void
show_version (const char *args, int from_tty)
{
print_gdb_version (gdb_stdout, true);
printf_filtered ("\n");
gdb_printf ("\n");
}
static void
@ -506,14 +506,14 @@ pwd_command (const char *args, int from_tty)
safe_strerror (errno));
if (strcmp (cwd.get (), current_directory) != 0)
printf_filtered (_("Working directory %ps\n (canonically %ps).\n"),
styled_string (file_name_style.style (),
current_directory),
styled_string (file_name_style.style (), cwd.get ()));
gdb_printf (_("Working directory %ps\n (canonically %ps).\n"),
styled_string (file_name_style.style (),
current_directory),
styled_string (file_name_style.style (), cwd.get ()));
else
printf_filtered (_("Working directory %ps.\n"),
styled_string (file_name_style.style (),
current_directory));
gdb_printf (_("Working directory %ps.\n"),
styled_string (file_name_style.style (),
current_directory));
}
void
@ -626,9 +626,9 @@ static void
show_script_ext_mode (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file,
_("Script filename extension recognition is \"%s\".\n"),
value);
gdb_printf (file,
_("Script filename extension recognition is \"%s\".\n"),
value);
}
/* Try to open SCRIPT_FILE.
@ -837,10 +837,10 @@ echo_command (const char *text, int from_tty)
c = parse_escape (get_current_arch (), &p);
if (c >= 0)
printf_filtered ("%c", c);
gdb_printf ("%c", c);
}
else
printf_filtered ("%c", c);
gdb_printf ("%c", c);
}
gdb_stdout->reset_style ();
@ -894,10 +894,10 @@ shell_escape (const char *arg, int from_tty)
arg = "inferior shell";
if (rc == -1)
fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", arg,
safe_strerror (errno));
gdb_printf (gdb_stderr, "Cannot execute %s: %s\n", arg,
safe_strerror (errno));
else if (rc)
fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
gdb_printf (gdb_stderr, "%s exited with status %d\n", arg, rc);
#ifdef GLOBAL_CURDIR
/* Make sure to return to the directory GDB thinks it is, in case
the shell command we just ran changed it. */
@ -921,8 +921,8 @@ shell_escape (const char *arg, int from_tty)
else
execl (user_shell, p, "-c", arg, (char *) 0);
fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
safe_strerror (errno));
gdb_printf (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
safe_strerror (errno));
_exit (0177);
}
@ -1011,16 +1011,16 @@ edit_command (const char *arg, int from_tty)
gdbarch = sal.symtab->objfile ()->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
sym->print_name (),
symtab_to_filename_for_display (sal.symtab),
sal.line);
gdb_printf ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
sym->print_name (),
symtab_to_filename_for_display (sal.symtab),
sal.line);
else
printf_filtered ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
symtab_to_filename_for_display (sal.symtab),
sal.line);
gdb_printf ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
symtab_to_filename_for_display (sal.symtab),
sal.line);
}
/* If what was given does not imply a symtab, it must be an
@ -1350,14 +1350,14 @@ list_command (const char *arg, int from_tty)
gdbarch = sal.symtab->objfile ()->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
sym->print_name (),
symtab_to_filename_for_display (sal.symtab), sal.line);
gdb_printf ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
sym->print_name (),
symtab_to_filename_for_display (sal.symtab), sal.line);
else
printf_filtered ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
symtab_to_filename_for_display (sal.symtab), sal.line);
gdb_printf ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
symtab_to_filename_for_display (sal.symtab), sal.line);
}
/* If line was not specified by just a line number, and it does not
@ -1425,18 +1425,18 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
else
#endif
{
printf_filtered (_("Dump of assembler code "));
gdb_printf (_("Dump of assembler code "));
if (name != NULL)
printf_filtered (_("for function %ps:\n"),
styled_string (function_name_style.style (), name));
gdb_printf (_("for function %ps:\n"),
styled_string (function_name_style.style (), name));
if (block == nullptr || BLOCK_CONTIGUOUS_P (block))
{
if (name == NULL)
printf_filtered (_("from %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, low)),
styled_string (address_style.style (),
paddress (gdbarch, high)));
gdb_printf (_("from %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, low)),
styled_string (address_style.style (),
paddress (gdbarch, high)));
/* Dump the specified range. */
gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high);
@ -1447,16 +1447,16 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
{
CORE_ADDR range_low = BLOCK_RANGE_START (block, i);
CORE_ADDR range_high = BLOCK_RANGE_END (block, i);
printf_filtered (_("Address range %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, range_low)),
styled_string (address_style.style (),
paddress (gdbarch, range_high)));
gdb_printf (_("Address range %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, range_low)),
styled_string (address_style.style (),
paddress (gdbarch, range_high)));
gdb_disassembly (gdbarch, current_uiout, flags, -1,
range_low, range_high);
}
}
printf_filtered (_("End of assembler dump.\n"));
gdb_printf (_("End of assembler dump.\n"));
}
}
@ -2020,9 +2020,9 @@ print_sal_location (const symtab_and_line &sal)
const char *sym_name = NULL;
if (sal.symbol != NULL)
sym_name = sal.symbol->print_name ();
printf_filtered (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"),
symtab_to_filename_for_display (sal.symtab),
sal.line, sym_name != NULL ? sym_name : "???");
gdb_printf (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"),
symtab_to_filename_for_display (sal.symtab),
sal.line, sym_name != NULL ? sym_name : "???");
}
/* Print a list of files and line numbers which a user may choose from
@ -2117,28 +2117,28 @@ show_info_verbose (struct ui_file *file, int from_tty,
const char *value)
{
if (info_verbose)
fprintf_filtered (file,
_("Verbose printing of informational messages is %s.\n"),
value);
gdb_printf (file,
_("Verbose printing of informational messages is %s.\n"),
value);
else
fprintf_filtered (file, _("Verbosity is %s.\n"), value);
gdb_printf (file, _("Verbosity is %s.\n"), value);
}
static void
show_history_expansion_p (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("History expansion on command input is %s.\n"),
value);
gdb_printf (file, _("History expansion on command input is %s.\n"),
value);
}
static void
show_max_user_call_depth (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file,
_("The max call depth for user-defined commands is %s.\n"),
value);
gdb_printf (file,
_("The max call depth for user-defined commands is %s.\n"),
value);
}
/* Implement 'show suppress-cli-notifications'. */
@ -2147,8 +2147,8 @@ static void
show_suppress_cli_notifications (ui_file *file, int from_tty,
cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("Suppression of printing CLI notifications "
"is %s.\n"), value);
gdb_printf (file, _("Suppression of printing CLI notifications "
"is %s.\n"), value);
}
/* Implement 'set suppress-cli-notifications'. */