Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 2/2] gdb: remove set_width
Date: Wed, 21 Oct 2026 18:28:59 -0400	[thread overview]
Message-ID: <20261021222903.769497-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261021222903.769497-1-simon.marchi@efficios.com>

set_width does not do anything useful anymore.  What remains is:

 - Calling init_page_info if chars_per_line is 0.  This can't happen:
   all callers call set_screen_size just before, which changes a
   chars_per_line of 0 to UINT_MAX.

 - Setting filtered_printing_initialized.  This only matters the first
   time, when called from init_page_info, from gdb_init.  The other
   callers (the "set width" command, set_screen_width_and_height and
   ~set_batch_flag_and_restore_page_info) can only run after that.

Remove set_width, and set filtered_printing_initialized directly in
init_page_info.  The "set width" and "set height" callbacks are now
identical, so replace them with a single set_screen_size_command.

Change-Id: I3631223cd02c0ffe4b8e9ccef958e8ea8782d6aa
---
 gdb/utils.c | 33 +++++++--------------------------
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index f6ebda29784e..4d03ccd5c2da 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -87,9 +87,8 @@ void (*deprecated_error_begin_hook) (void);
 /* Prototypes for local functions */
 
 static void set_screen_size (void);
-static void set_width (void);
 
-/* True once set_width has run and filtered printing can be used.  */
+/* True once init_page_info has run and filtered printing can be used.  */
 
 static bool filtered_printing_initialized = false;
 
@@ -1176,7 +1175,7 @@ init_page_info (void)
   rl_catch_sigwinch = 0;
 
   set_screen_size ();
-  set_width ();
+  filtered_printing_initialized = true;
 }
 
 set_batch_flag_and_restore_page_info::set_batch_flag_and_restore_page_info ()
@@ -1195,7 +1194,6 @@ set_batch_flag_and_restore_page_info::~set_batch_flag_and_restore_page_info ()
   lines_per_page = m_save_lines_per_page;
 
   set_screen_size ();
-  set_width ();
 }
 
 /* An approximation of SQRT(INT_MAX) that is:
@@ -1242,27 +1240,11 @@ set_screen_size (void)
   rl_set_screen_size (rows, cols);
 }
 
-/* Initialize the page info if needed, and mark filtered printing as
-   initialized.  */
+/* Callback for "set width" and "set height".  */
 
 static void
-set_width ()
-{
-  if (chars_per_line == 0)
-    init_page_info ();
-
-  filtered_printing_initialized = true;
-}
-
-static void
-set_width_command (const char *args, int from_tty, struct cmd_list_element *c)
-{
-  set_screen_size ();
-  set_width ();
-}
-
-static void
-set_height_command (const char *args, int from_tty, struct cmd_list_element *c)
+set_screen_size_command (const char *args, int from_tty,
+			 cmd_list_element *c)
 {
   set_screen_size ();
 }
@@ -1276,7 +1258,6 @@ set_screen_width_and_height (int width, int height)
   chars_per_line = width;
 
   set_screen_size ();
-  set_width ();
 }
 
 /* Import termcap variable UP (instead of readline private variable
@@ -3678,7 +3659,7 @@ Set number of characters where GDB should wrap lines of its output."), _("\
 Show number of characters where GDB should wrap lines of its output."), _("\
 This affects where GDB wraps its output to fit the screen width.\n\
 Setting this to \"unlimited\" or zero prevents GDB from wrapping its output."),
-			    set_width_command,
+			    set_screen_size_command,
 			    show_chars_per_line,
 			    &setlist, &showlist);
 
@@ -3688,7 +3669,7 @@ Show number of lines in a page for GDB output pagination."), _("\
 This affects the number of lines after which GDB will pause\n\
 its output and ask you whether to continue.\n\
 Setting this to \"unlimited\" or zero causes GDB never pause during output."),
-			    set_height_command,
+			    set_screen_size_command,
 			    show_lines_per_page,
 			    &setlist, &showlist);
 
-- 
2.56.0


  reply	other threads:[~2026-10-21 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 22:28 [PATCH 1/2] gdb: remove filtered_printing_initialized function Simon Marchi
2026-10-21 22:28 ` Simon Marchi [this message]
2026-10-22 13:05   ` [PATCH 2/2] gdb: remove set_width Tom Tromey
2026-10-22 16:30     ` Simon Marchi
2026-10-22 13:05 ` [PATCH 1/2] gdb: remove filtered_printing_initialized function Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261021222903.769497-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox