From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WWYmAtY82WoSUQkAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 18:29:42 -0400 Received: by simark.ca (Postfix, from userid 112) id E8B601E050; Wed, 21 Oct 2026 18:29:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 26BC91E050 for ; Wed, 21 Oct 2026 18:29:40 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 560814BA23FD for ; Wed, 21 Oct 2026 22:29:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 560814BA23FD Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 853BE4BA2E38 for ; Wed, 21 Oct 2026 22:29:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 853BE4BA2E38 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 853BE4BA2E38 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792621755; cv=none; b=cCFHBFNagwpEDvKU0O1exu3lQBQIKDIh/ZIBVeF2Gver6e9/d2U6V6nDmY2SzKrvmn5j3D+Rg2yJ7deohtwNcZjkDKJA72oGQaY9IsRc/9vMCVmME/pfo11z3yQ0/iZttio4xdXtbkDC2Y0AYEq+HJf9ps3IWpt/b7LvhNvzAOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792621755; c=relaxed/simple; bh=A+uy76z+RFYBhadNo1pHYU6UbFh6J1YSaaXWK1eQkUw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=e5uDxJDMyK1HD0C2XrtQL2IBtzuhUTClC34Sxlq5t6sejcWfojBD22uRHgOg/ln27acAcR1WyHcUoIOyXEeH+DAh8nywuygru67nbSNZBU0iggV8mtn5XmL2Qzd9FKi/+h0I4+PvAPeX0m5Bw1UXAVpmdARaZYnqGlTxeLdTSK4= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 853BE4BA2E38 Received: by simark.ca (Postfix) id B22C81E04D; Wed, 21 Oct 2026 18:29:14 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb: remove filtered_printing_initialized function Date: Wed, 21 Oct 2026 18:28:58 -0400 Message-ID: <20261021222903.769497-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Since commit ebfc93611b64 ("Remove unnecessary calls to wrap_here and gdb_flush", 2022-01-03), the filtered_printing_initialized function is only used in utils.c, by internal_vproblem. Remove it and its declaration in utils.h. Rename the filter_initialized variable it returned to filtered_printing_initialized, and use it directly. Move the variable up so that it is defined before internal_vproblem. Replace its comment, which was really about the wrap buffer variables and a general description of the wrap mechanism. Fix the comment of set_width, which was also stale. The description of the wrapping mechanism in that old comment was interesting to keep though, so add an updated version of it to the comment of pager_file::m_wrap_buffer. Change-Id: Ie927aa0f60a2cdf24c288b5ee5df3009a23a521e --- gdb/pager.h | 9 ++++++++- gdb/utils.c | 38 +++++++++++++------------------------- gdb/utils.h | 3 --- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/gdb/pager.h b/gdb/pager.h index 114024d5e5f3..f497ea931f7a 100644 --- a/gdb/pager.h +++ b/gdb/pager.h @@ -85,7 +85,14 @@ class pager_file : public wrapped_file } /* Contains characters which are waiting to be output (they have - already been counted in chars_printed). */ + already been counted in chars_printed). + + All output is accumulated here. A call to wrap_here flushes the + buffer and records the current column as a possible line break + point. A newline flushes the buffer and cancels the break point. + If the line overflows while a break point is set, a newline and + the indentation are emitted at that point, and the buffered text + follows on the next line. */ std::string m_wrap_buffer; /* Amount to indent by if the wrap occurs. */ diff --git a/gdb/utils.c b/gdb/utils.c index b3ba01d0e47d..f6ebda29784e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -89,6 +89,10 @@ void (*deprecated_error_begin_hook) (void); static void set_screen_size (void); static void set_width (void); +/* True once set_width has run and filtered printing can be used. */ + +static bool filtered_printing_initialized = false; + /* Time spent in prompt_for_continue in the currently executing command waiting for user to respond. Initialized in make_command_stats_cleanup. @@ -419,13 +423,13 @@ internal_vproblem (struct internal_problem *problem, term_state.emplace (); target_terminal::ours_for_output (); } - if (filtered_printing_initialized ()) + if (filtered_printing_initialized) begin_line (); /* Emit the message unless query will emit it below. */ if (problem->should_quit != internal_problem_ask || !confirm - || !filtered_printing_initialized () + || !filtered_printing_initialized || !readline_initialized (current_ui) || problem->should_print_backtrace) gdb_printf (gdb_stderr, "%s\n", reason.c_str ()); @@ -438,7 +442,7 @@ internal_vproblem (struct internal_problem *problem, /* Default (yes/batch case) is to quit GDB. When in batch mode this lessens the likelihood of GDB going into an infinite loop. */ - if (!confirm || !filtered_printing_initialized () + if (!confirm || !filtered_printing_initialized || !readline_initialized (current_ui)) quit_p = 1; else @@ -463,7 +467,7 @@ internal_vproblem (struct internal_problem *problem, { if (!can_dump_core_warn (LIMIT_MAX, reason.c_str ())) dump_core_p = 0; - else if (!filtered_printing_initialized () + else if (!filtered_printing_initialized || !readline_initialized (current_ui)) dump_core_p = 1; else @@ -1091,16 +1095,6 @@ static unsigned int lines_printed, chars_printed; static bool pagination_disabled_for_command; -/* Buffer and start column of buffered text, for doing smarter word- - wrapping. When someone calls wrap_here(), we start buffering output - that comes through gdb_puts(). If we see a newline, we just - spit it out and forget about the wrap_here(). If we see another - wrap_here(), we spit it out and remember the newer one. If we see - the end of the line, we spit out a newline, the indent, and then - the buffered output. */ - -static bool filter_initialized = false; - /* See utils.h. */ @@ -1185,13 +1179,6 @@ init_page_info (void) set_width (); } -/* Return nonzero if filtered printing is initialized. */ -int -filtered_printing_initialized (void) -{ - return filter_initialized; -} - set_batch_flag_and_restore_page_info::set_batch_flag_and_restore_page_info () : m_save_lines_per_page (lines_per_page), m_save_chars_per_line (chars_per_line), @@ -1255,15 +1242,16 @@ set_screen_size (void) rl_set_screen_size (rows, cols); } -/* Reinitialize WRAP_BUFFER. */ +/* Initialize the page info if needed, and mark filtered printing as + initialized. */ static void -set_width (void) +set_width () { if (chars_per_line == 0) init_page_info (); - filter_initialized = true; + filtered_printing_initialized = true; } static void @@ -1565,7 +1553,7 @@ void pager_file::wrap_here (int indent) { /* This should have been allocated, but be paranoid anyway. */ - gdb_assert (filter_initialized); + gdb_assert (filtered_printing_initialized); flush_wrap_buffer (); if (chars_per_line == UINT_MAX) /* No line overflow checking. */ diff --git a/gdb/utils.h b/gdb/utils.h index 7e59037bf5f5..4f465e7077f9 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -257,9 +257,6 @@ extern void print_spaces (int, struct ui_file *); extern const char *n_spaces (int); -/* Return nonzero if filtered printing is initialized. */ -extern int filtered_printing_initialized (void); - /* Like gdb_printf, but styles the output according to STYLE, when appropriate. */ base-commit: ecca519b2096f9a1f11ac34db1f6c4dddb5d995e -- 2.56.0