From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id D5C36386549C; Tue, 29 Mar 2022 19:42:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5C36386549C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Unify vprintf functions X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: f4bf8795b382327001cf467b855e5dcd6f30fe5d X-Git-Newrev: 19a7b8ab871b92dee32a0ebffe274388d3426564 Message-Id: <20220329194245.D5C36386549C@sourceware.org> Date: Tue, 29 Mar 2022 19:42:45 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 19:42:45 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D19a7b8ab871b= 92dee32a0ebffe274388d3426564 commit 19a7b8ab871b92dee32a0ebffe274388d3426564 Author: Tom Tromey Date: Sun Jan 2 11:13:35 2022 -0700 Unify vprintf functions =20 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. Diff: --- gdb/cli/cli-cmds.c | 2 +- gdb/cli/cli-script.c | 2 +- gdb/complaints.c | 2 +- gdb/debug.c | 2 +- gdb/disasm.c | 2 +- gdb/exceptions.c | 2 +- gdb/language.c | 2 +- gdb/mi/mi-out.c | 2 +- gdb/parse.c | 4 ++-- gdb/remote-sim.c | 8 +++---- gdb/sol-thread.c | 2 +- gdb/target-descriptions.c | 2 +- gdb/ui-file.c | 2 +- gdb/utils.c | 59 +++++++++----------------------------------= ---- 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 sals, { va_list ap; va_start (ap, format); - vprintf_filtered (format, ap); + gdb_vprintf (format, ap); va_end (ap); =20 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; =20 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); } =20 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 =3D 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; =20 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 g= db_exception &e, =20 /* Print the prefix. */ va_start (args, prefix); - vfprintf_filtered (file, prefix, args); + gdb_vprintf (file, prefix, args); va_end (args); =20 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=3D\"", fldname); else fputs_unfiltered ("\"", stream); - vfprintf_unfiltered (stream, format, args); + gdb_vprintf (stream, format, args); fputs_unfiltered ("\"", stream); } =20 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, ...) =20 va_start (args, y); if (x =3D=3D stderr) - vfprintf_unfiltered (gdb_stderr, y, args);=20 + gdb_vprintf (gdb_stderr, y, args);=20 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; =20 va_start (args, format); - vfprintf_filtered (gdb_stdout, format, args); + gdb_vprintf (gdb_stdout, format, args); va_end (args); } =20 -/* GDB version of error vprintf_filtered. */ +/* GDB version of error gdb_vprintf. */ =20 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); } =20 /* 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 a= p) { - vfprintf_filtered (gdb_stderr, format, ap); + gdb_vprintf (gdb_stderr, format, ap); } =20 /* 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, ...) =20 va_start (args, fmt); =20 - vfprintf_filtered (gdb_stderr, fmt, args); + gdb_vprintf (gdb_stderr, fmt, args); } =20 /* 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: =20 va_list args; va_start (args, fmt); - vprintf_filtered (fmt, args); + gdb_vprintf (fmt, args); va_end (args); } =20 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; =20 va_start (args, format); - vfprintf_unfiltered (this, format, args); + vprintf (format, args); va_end (args); } =20 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); =20 /* Prototypes for local functions */ =20 -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); =20 @@ -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); =20 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; } =20 -/* 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 arg= s) -{ - vfprintf_maybe_filtered (stream, format, args, true); -} - void -vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list a= rgs) +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); } =20 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); } =20 void @@ -1878,7 +1841,7 @@ fprintf_filtered (struct ui_file *stream, const char = *format, ...) va_list args; =20 va_start (args, format); - vfprintf_filtered (stream, format, args); + gdb_vprintf (stream, format, args); va_end (args); } =20 @@ -1888,7 +1851,7 @@ fprintf_unfiltered (struct ui_file *stream, const cha= r *format, ...) va_list args; =20 va_start (args, format); - vfprintf_unfiltered (stream, format, args); + gdb_vprintf (stream, format, args); va_end (args); } =20 @@ -1902,7 +1865,7 @@ fprintf_styled (struct ui_file *stream, const ui_file= _style &style, =20 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_fil= e_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 ()); } =20 @@ -1924,7 +1887,7 @@ printf_filtered (const char *format, ...) va_list args; =20 va_start (args, format); - vfprintf_filtered (gdb_stdout, format, args); + gdb_vprintf (gdb_stdout, format, args); va_end (args); } =20 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 *); =20 extern void puts_filtered_tabular (char *string, int width, int right); =20 -extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, = 0); +extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0); =20 -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); =20 extern void fprintf_filtered (struct ui_file *, const char *, ...) @@ -257,11 +257,6 @@ extern void fprintf_filtered (struct ui_file *, const = char *, ...) =20 extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2); =20 -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);