diff options
author | Tom Tromey <tom@tromey.com> | 2022-01-02 11:13:35 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-03-29 12:46:24 -0600 |
commit | 19a7b8ab871b92dee32a0ebffe274388d3426564 (patch) | |
tree | f020eb4af0b4587d3270ae8c62603bae39475715 | |
parent | f4bf8795b382327001cf467b855e5dcd6f30fe5d (diff) | |
download | binutils-gdb-19a7b8ab871b92dee32a0ebffe274388d3426564.tar.gz |
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.
-rw-r--r-- | gdb/cli/cli-cmds.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-script.c | 2 | ||||
-rw-r--r-- | gdb/complaints.c | 2 | ||||
-rw-r--r-- | gdb/debug.c | 2 | ||||
-rw-r--r-- | gdb/disasm.c | 2 | ||||
-rw-r--r-- | gdb/exceptions.c | 2 | ||||
-rw-r--r-- | gdb/language.c | 2 | ||||
-rw-r--r-- | gdb/mi/mi-out.c | 2 | ||||
-rw-r--r-- | gdb/parse.c | 4 | ||||
-rw-r--r-- | gdb/remote-sim.c | 8 | ||||
-rw-r--r-- | gdb/sol-thread.c | 2 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 2 | ||||
-rw-r--r-- | gdb/ui-file.c | 2 | ||||
-rw-r--r-- | gdb/utils.c | 59 | ||||
-rw-r--r-- | gdb/utils.h | 9 |
15 files changed, 30 insertions, 72 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index b6baca94859..a4c257e511f 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -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) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 55248de649b..67613aa0bc0 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -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"); } diff --git a/gdb/complaints.c b/gdb/complaints.c index 2c2d90a39d2..b582bf38f11 100644 --- a/gdb/complaints.c +++ b/gdb/complaints.c @@ -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); } diff --git a/gdb/debug.c b/gdb/debug.c index 6f9cad0ddd0..b29a6620afe 100644 --- a/gdb/debug.c +++ b/gdb/debug.c @@ -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); } diff --git a/gdb/disasm.c b/gdb/disasm.c index b4cde801cb0..c179b2e03c8 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -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; diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 16e26d5e4b1..b23ab0e4f33 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -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); diff --git a/gdb/language.c b/gdb/language.c index 69c73b0318e..28a98abca92 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -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: diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 53f7206addd..5145bea4b75 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -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); } diff --git a/gdb/parse.c b/gdb/parse.c index 23f0e66bf27..866bb9e6006 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -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); } diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 39bddec77b3..a87e86aaeaf 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -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. */ diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 0bfdbdf5037..f1991bec342 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -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. */ diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 7c380cdb60f..4c187754c65 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1581,7 +1581,7 @@ private: va_list args; va_start (args, fmt); - vprintf_filtered (fmt, args); + gdb_vprintf (fmt, args); va_end (args); } diff --git a/gdb/ui-file.c b/gdb/ui-file.c index f6878f76cf1..ec441a73a8c 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -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); } diff --git a/gdb/utils.c b/gdb/utils.c index a86d2c4d386..7df17af670e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -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) -{ - stream->vprintf (format, args); -} - - -void -vfprintf_filtered (struct ui_file *stream, 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) +gdb_vprintf (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); + stream->vprintf (format, args); } void -vprintf_unfiltered (const char *format, va_list args) +gdb_vprintf (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); } diff --git a/gdb/utils.h b/gdb/utils.h index e721b45d7ba..09c971fc7c0 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -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); |