Unify vprintf functions

Now that filtered and unfiltered output can be treated identically, we
can unify the vprintf family of functions: vprintf_filtered,
vprintf_unfiltered, vfprintf_filtered and vfprintf_unfiltered.  (For
the gdb_stdout variants, recall that only printf_unfiltered gets truly
unfiltered output at this point.)  This removes one such function and
renames the remaining two to "gdb_vprintf".  All callers are updated.
Much of this patch was written by script.
This commit is contained in:
Tom Tromey 2022-01-02 11:13:35 -07:00
parent f4bf8795b3
commit 19a7b8ab87
15 changed files with 30 additions and 72 deletions

View File

@ -2038,7 +2038,7 @@ ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
{
va_list ap;
va_start (ap, format);
vprintf_filtered (format, ap);
gdb_vprintf (format, ap);
va_end (ap);
for (const auto &sal : sals)

View File

@ -501,7 +501,7 @@ print_command_trace (const char *fmt, ...)
va_list args;
va_start (args, fmt);
vprintf_filtered (fmt, args);
gdb_vprintf (fmt, args);
va_end (args);
puts_filtered ("\n");
}

View File

@ -51,7 +51,7 @@ complaint_internal (const char *fmt, ...)
else
{
fputs_filtered (_("During symbol reading: "), gdb_stderr);
vfprintf_filtered (gdb_stderr, fmt, args);
gdb_vprintf (gdb_stderr, fmt, args);
fputs_filtered ("\n", gdb_stderr);
}

View File

@ -30,5 +30,5 @@ int debug_print_depth = 0;
void
debug_vprintf (const char *fmt, va_list ap)
{
vfprintf_unfiltered (gdb_stdlog, fmt, ap);
gdb_vprintf (gdb_stdlog, fmt, ap);
}

View File

@ -171,7 +171,7 @@ gdb_disassembler::dis_asm_fprintf (void *stream, const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_filtered ((struct ui_file *) stream, format, args);
gdb_vprintf ((struct ui_file *) stream, format, args);
va_end (args);
/* Something non -ve. */
return 0;

View File

@ -127,7 +127,7 @@ exception_fprintf (struct ui_file *file, const struct gdb_exception &e,
/* Print the prefix. */
va_start (args, prefix);
vfprintf_filtered (file, prefix, args);
gdb_vprintf (file, prefix, args);
va_end (args);
print_exception (file, e);

View File

@ -414,7 +414,7 @@ range_error (const char *string,...)
case range_check_off:
/* FIXME: cagney/2002-01-30: Should this function print anything
when range error is off? */
vfprintf_filtered (gdb_stderr, string, args);
gdb_vprintf (gdb_stderr, string, args);
fprintf_filtered (gdb_stderr, "\n");
break;
default:

View File

@ -151,7 +151,7 @@ mi_ui_out::do_field_fmt (int fldno, int width, ui_align align,
fprintf_unfiltered (stream, "%s=\"", fldname);
else
fputs_unfiltered ("\"", stream);
vfprintf_unfiltered (stream, format, args);
gdb_vprintf (stream, format, args);
fputs_unfiltered ("\"", stream);
}

View File

@ -632,11 +632,11 @@ parser_fprintf (FILE *x, const char *y, ...)
va_start (args, y);
if (x == stderr)
vfprintf_unfiltered (gdb_stderr, y, args);
gdb_vprintf (gdb_stderr, y, args);
else
{
fprintf_unfiltered (gdb_stderr, " Unknown FILE used.\n");
vfprintf_unfiltered (gdb_stderr, y, args);
gdb_vprintf (gdb_stderr, y, args);
}
va_end (args);
}

View File

@ -401,16 +401,16 @@ gdb_os_printf_filtered (host_callback * p, const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_filtered (gdb_stdout, format, args);
gdb_vprintf (gdb_stdout, format, args);
va_end (args);
}
/* GDB version of error vprintf_filtered. */
/* GDB version of error gdb_vprintf. */
static void ATTRIBUTE_PRINTF (2, 0)
gdb_os_vprintf_filtered (host_callback * p, const char *format, va_list ap)
{
vfprintf_filtered (gdb_stdout, format, ap);
gdb_vprintf (gdb_stdout, format, ap);
}
/* GDB version of error evprintf_filtered. */
@ -418,7 +418,7 @@ gdb_os_vprintf_filtered (host_callback * p, const char *format, va_list ap)
static void ATTRIBUTE_PRINTF (2, 0)
gdb_os_evprintf_filtered (host_callback * p, const char *format, va_list ap)
{
vfprintf_filtered (gdb_stderr, format, ap);
gdb_vprintf (gdb_stderr, format, ap);
}
/* GDB version of error callback. */

View File

@ -882,7 +882,7 @@ ps_plog (const char *fmt, ...)
va_start (args, fmt);
vfprintf_filtered (gdb_stderr, fmt, args);
gdb_vprintf (gdb_stderr, fmt, args);
}
/* Get size of extra register set. Currently a noop. */

View File

@ -1581,7 +1581,7 @@ private:
va_list args;
va_start (args, fmt);
vprintf_filtered (fmt, args);
gdb_vprintf (fmt, args);
va_end (args);
}

View File

@ -42,7 +42,7 @@ ui_file::printf (const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_unfiltered (this, format, args);
vprintf (format, args);
va_end (args);
}

View File

@ -83,10 +83,6 @@ void (*deprecated_error_begin_hook) (void);
/* Prototypes for local functions */
static void vfprintf_maybe_filtered (struct ui_file *, const char *,
va_list, bool)
ATTRIBUTE_PRINTF (2, 0);
static void set_screen_size (void);
static void set_width (void);
@ -155,7 +151,7 @@ vwarning (const char *string, va_list args)
gdb_flush (gdb_stdout);
if (warning_pre_print)
fputs_unfiltered (warning_pre_print, gdb_stderr);
vfprintf_unfiltered (gdb_stderr, string, args);
gdb_vprintf (gdb_stderr, string, args);
fprintf_unfiltered (gdb_stderr, "\n");
}
}
@ -879,7 +875,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
target_terminal::scoped_restore_terminal_state term_state;
target_terminal::ours_for_output ();
gdb_stdout->wrap_here (0);
vfprintf_filtered (gdb_stdout, ctlstr, args);
gdb_vprintf (gdb_stdout, ctlstr, args);
printf_filtered (_("(%s or %s) [answered %c; "
"input not from terminal]\n"),
@ -1827,49 +1823,16 @@ fputc_filtered (int c, struct ui_file *stream)
return c;
}
/* Print a variable number of ARGS using format FORMAT. If this
information is going to put the amount written (since the last call
to REINITIALIZE_MORE_FILTER or the last page break) over the page size,
call prompt_for_continue to get the users permission to continue.
Unlike fprintf, this function does not return a value.
We implement three variants, vfprintf (takes a vararg list and stream),
fprintf (takes a stream to write on), and printf (the usual).
Note also that this may throw a quit (since prompt_for_continue may
do so). */
static void
vfprintf_maybe_filtered (struct ui_file *stream, const char *format,
va_list args, bool filter)
void
gdb_vprintf (struct ui_file *stream, const char *format, va_list args)
{
stream->vprintf (format, args);
}
void
vfprintf_filtered (struct ui_file *stream, const char *format, va_list args)
gdb_vprintf (const char *format, va_list args)
{
vfprintf_maybe_filtered (stream, format, args, true);
}
void
vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
{
vfprintf_maybe_filtered (stream, format, args, false);
}
void
vprintf_filtered (const char *format, va_list args)
{
vfprintf_filtered (gdb_stdout, format, args);
}
void
vprintf_unfiltered (const char *format, va_list args)
{
vfprintf_unfiltered (gdb_stdout, format, args);
gdb_stdout->vprintf (format, args);
}
void
@ -1878,7 +1841,7 @@ fprintf_filtered (struct ui_file *stream, const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_filtered (stream, format, args);
gdb_vprintf (stream, format, args);
va_end (args);
}
@ -1888,7 +1851,7 @@ fprintf_unfiltered (struct ui_file *stream, const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_unfiltered (stream, format, args);
gdb_vprintf (stream, format, args);
va_end (args);
}
@ -1902,7 +1865,7 @@ fprintf_styled (struct ui_file *stream, const ui_file_style &style,
stream->emit_style_escape (style);
va_start (args, format);
vfprintf_filtered (stream, format, args);
gdb_vprintf (stream, format, args);
va_end (args);
stream->emit_style_escape (ui_file_style ());
}
@ -1914,7 +1877,7 @@ vfprintf_styled (struct ui_file *stream, const ui_file_style &style,
const char *format, va_list args)
{
stream->emit_style_escape (style);
vfprintf_filtered (stream, format, args);
gdb_vprintf (stream, format, args);
stream->emit_style_escape (ui_file_style ());
}
@ -1924,7 +1887,7 @@ printf_filtered (const char *format, ...)
va_list args;
va_start (args, format);
vfprintf_filtered (gdb_stdout, format, args);
gdb_vprintf (gdb_stdout, format, args);
va_end (args);
}

View File

@ -247,9 +247,9 @@ extern void puts_filtered (const char *);
extern void puts_filtered_tabular (char *string, int width, int right);
extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
extern void vfprintf_filtered (struct ui_file *, const char *, va_list)
extern void gdb_vprintf (struct ui_file *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
extern void fprintf_filtered (struct ui_file *, const char *, ...)
@ -257,11 +257,6 @@ extern void fprintf_filtered (struct ui_file *, const char *, ...)
extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
extern void vprintf_unfiltered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
ATTRIBUTE_PRINTF (2, 3);