From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id AD3723858433 for ; Sat, 22 Jan 2022 01:38:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD3723858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 0EA2710047781 for ; Sat, 22 Jan 2022 01:38:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id B5M0nIXYE2s5dB5M0nxF1Q; Sat, 22 Jan 2022 01:38:09 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=BOh2EHcG c=1 sm=1 tr=0 ts=61eb6001 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=DghFqjY3_ZEA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=sSSYG4ISQlO5HU6CO2YA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5/uwTm3VL4lv0P51g1cJ/8ih7zNWWE5CU91EiBVfKdE=; b=qCiKMODHB8lJ/gXIP+2QBEsbvT x2EN6SM6wZ02alAtNXLkud+UIzfCL0MfHq9xyLMmCzvtO+MM1pE2QAoylVwnhkXA8iJpEy/FrxdqR YOKEx3hgi0Qm+YsqAB3QGsEQ5; Received: from 75-166-128-165.hlrn.qwest.net ([75.166.128.165]:40602 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nB5M0-001DeE-5M; Fri, 21 Jan 2022 18:38:08 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/19] Unify vprintf functions Date: Fri, 21 Jan 2022 18:37:51 -0700 Message-Id: <20220122013801.666659-10-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220122013801.666659-1-tom@tromey.com> References: <20220122013801.666659-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.128.165 X-Source-L: No X-Exim-ID: 1nB5M0-001DeE-5M X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-128-165.hlrn.qwest.net (prentzel.Home) [75.166.128.165]:40602 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Jan 2022 01:38:12 -0000 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. --- 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 3cdc7cde9a5..aaa07b7dc50 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -2020,7 +2020,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); 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 3000e5dddad..9564f1ca8ec 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 0846b3e5eeb..c4d11758d10 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 a6595e3da06..abd6beac2d0 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 @@ class print_c_tdesc : public tdesc_element_visitor 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 0254286e8ac..4a3d5397bc7 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"), @@ -1841,49 +1837,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 @@ -1892,7 +1855,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); } @@ -1902,7 +1865,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); } @@ -1916,7 +1879,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 ()); } @@ -1928,7 +1891,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 ()); } @@ -1938,7 +1901,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 cb322c34396..268886d716a 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -244,9 +244,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 *, ...) @@ -254,11 +254,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); -- 2.31.1