From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCHv3 3/3] WIP: disable progress bars setting
Date: Tue, 09 Dec 2025 17:32:59 +0000 [thread overview]
Message-ID: <87h5tz5zn8.fsf@redhat.com> (raw)
In-Reply-To: <32f0ffdfd85e7a3d62a2dc3a7b06b01275412920.1764964133.git.aburgess@redhat.com>
Andrew Burgess <aburgess@redhat.com> writes:
> ---
> gdb/NEWS | 6 ++
> gdb/cli-out.c | 66 ++++++++++++++++++-
> gdb/doc/gdb.texinfo | 15 +++++
> .../build-id-no-debug-warning.exp | 1 +
> .../gdb.debuginfod/corefile-mapped-file.exp | 1 +
> gdb/testsuite/gdb.debuginfod/crc_mismatch.exp | 1 +
> .../gdb.debuginfod/fetch_src_and_symbols.exp | 4 ++
> .../gdb.debuginfod/solib-with-soname.exp | 1 +
> 8 files changed, 93 insertions(+), 2 deletions(-)
I realise I posted this without writing an actual commit message.
That's pretty poor form. Apologies. I think I was having a bad day.
Anyway, here's the same patch (no code or doc changes) but with an
actual commit message.
Thanks,
Andrew
---
commit d60de316ab832dcfdbd8cef11ff22a95ef27baa4
Author: Andrew Burgess <aburgess@redhat.com>
Date: Fri Dec 5 11:33:29 2025 +0000
gdb: new setting to disable progress bars
Two commits ago, in the commit titled:
gdb: make get_chars_per_line return an unsigned value
A bodge was added in cli-out.c so that progress bars (as seen when
debuginfod downloads a file) would be disabled when the output
terminal had unlimited width.
The hack was added because this previous commit fixed a bug such that
progress bars could now be displayed in very wide, or even on
unlimited width output terminals. By fixing this bug, progress bars
were now being displayed when running the testsuite, as the testsuite
sets the output terminal to unlimited width.
To avoid breaking the tests, this previous commit added a bodge such
that on unlimited width output terminals, progress bars would always
be disabled. This got the tests passing again, but isn't an ideal
solution.
This commit cleans things up. We now have a new setting:
set progress-bars enabled on|off
show progress-bars enabled
This setting allows progress bars to be turned off. The tests are
then updated to explicitly turn off progress bars. The bodge from the
earlier commit is then removed.
Now, progress bars should display correctly on any width of output
terminal over 50 characters, the minimum required. And the debuginfod
tests should all pass as they turn off progress bars.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
diff --git a/gdb/NEWS b/gdb/NEWS
index 01c998f4ea0..0e43de89e8a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -59,6 +59,12 @@ maintenance test-remote-args ARGS
Test splitting and joining of inferior arguments ARGS as they would
be split and joined when being passed to a remote target.
+set progress-bars enabled on|off
+show progress-bars enabled
+ Allows the progress bars, used when debuginfod is downloading
+ content, to be disabled (the set command), or to see if
+ progress-bars are currently enabled or not (the show command).
+
* Changed commands
maintenance info program-spaces
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 5aa13a64271..ae60b65064b 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -26,6 +26,7 @@
#include "readline/readline.h"
#include "cli/cli-style.h"
#include "ui.h"
+#include "cli/cli-cmds.h"
/* These are the CLI output functions */
@@ -275,6 +276,31 @@ cli_ui_out::do_progress_start ()
#define MIN_CHARS_PER_LINE 50
#define MAX_CHARS_PER_LINE 4096
+/* When this is false no progress bars will be displayed. When true,
+ progress bars can be displayed if the output stream supports them. */
+
+static bool progress_bars_enabled = true;
+
+/* The "show progress-bars enabled" command. */
+
+static void
+show_progress_bars_enabled (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ if (progress_bars_enabled && get_chars_per_line () < MIN_CHARS_PER_LINE)
+ gdb_printf (file, _("Progress bars are currently \"off\". "
+ "The terminal is too narrow.\n"));
+ else if (progress_bars_enabled && (!gdb_stdout->isatty ()
+ || !current_ui->input_interactive_p ()))
+ gdb_printf (file, _("Progress bars are currently \"off\". "
+ "The terminal doesn't support them.\n"));
+ else
+ gdb_printf (file,
+ _("Progress bars are currently \"%s\".\n"),
+ value);
+}
+
/* Print a progress update. MSG is a string to be printed on the line above
the progress bar. TOTAL is the size of the download whose progress is
being displayed. UNIT should be the unit of TOTAL (ex. "K"). If HOWMUCH
@@ -307,7 +333,7 @@ cli_ui_out::do_progress_notify (const std::string &msg,
if (stream->isatty ()
&& current_ui->input_interactive_p ()
&& chars_per_line >= MIN_CHARS_PER_LINE
- && chars_per_line != UINT_MAX)
+ && progress_bars_enabled)
{
gdb_printf (stream, "%s\n", msg.c_str ());
info.state = progress_update::BAR;
@@ -393,7 +419,7 @@ cli_ui_out::clear_progress_notify ()
if (!stream->isatty ()
|| !current_ui->input_interactive_p ()
|| chars_per_line < MIN_CHARS_PER_LINE
- || chars_per_line == UINT_MAX)
+ || !progress_bars_enabled)
return;
if (chars_per_line > MAX_CHARS_PER_LINE)
@@ -542,3 +568,39 @@ cli_display_match_list (char **matches, int len, int max)
gdb_display_match_list (matches, len, max, &displayer);
rl_forced_update_display ();
}
+
+/* Set/show progress-bars commands. */
+static cmd_list_element *set_progress_bars_prefix_list;
+static cmd_list_element *show_progress_bars_prefix_list;
+
+/* Initialization for this file. */
+
+INIT_GDB_FILE (cli_out)
+{
+ /* set/show debuginfod */
+ add_setshow_prefix_cmd ("progress-bars", class_obscure,
+ _("Set progress-bars options."),
+ _("Show progress-bars options."),
+ &set_progress_bars_prefix_list,
+ &show_progress_bars_prefix_list,
+ &setlist, &showlist);
+
+ /* Adds 'set|show progress-bars enabled'. */
+ add_setshow_boolean_cmd ("enabled", class_obscure,
+ &progress_bars_enabled, _("\
+Set whether progress bars should be displayed."), _("\
+Show whether progress bars should be displayed."),_("\
+During some slow operations, for example, fetching debug information\n\
+from debuginfod, GDB will display an animated progress bar when this\n\
+setting is \"on\". When this setting is \"off\", no progress bars\n\
+will be displayed.\n\
+\n\
+Even when \"on\", progress bars can be disabled if the output terminal\n\
+doesn't support them."),
+ nullptr,
+ show_progress_bars_enabled,
+ &set_progress_bars_prefix_list,
+ &show_progress_bars_prefix_list);
+
+
+}
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e4469227a9e..4a6bc7355b5 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -51323,6 +51323,21 @@ Debuginfod Settings
@item show debuginfod verbose
Show the current verbosity setting.
+@kindex set progress-bars enabled
+@cindex progress bars, disabling
+@item set progress-bars enabled @r{[}on@r{|}off@r{]}
+Set whether @value{GDBN} can display a progress bar when downloading a
+file from debuginfod. When @value{off}, @value{GDBN} will not display
+a progress bar. When @value{on}, @value{GDBN} will display a progress
+bar if @value{GDBN}'s output console supports it.
+
+@kindex show progress-bars enabled
+@item show progress-bars enabled
+Shows whether progress bars are currently enabled or not. Progress
+bars can be automatically disabled if @value{GDBN}'s output console
+doesn't support them, or if the terminal width is too small
+(@pxref{Screen Size,,@kbd{set width} command}).
+
@end table
@node Man Pages
diff --git a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
index 7a0cfda627c..eb4d0589478 100644
--- a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
+++ b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
@@ -132,6 +132,7 @@ proc_with_prefix local_debuginfod { } {
# Enable debuginfod and fetch the debuginfo.
gdb_test_no_output "set debuginfod enabled on"
+ gdb_test_no_output "set progress-bars enabled off"
# "separate debug info file has no debug info" warning should not be
# reported now because the correct debuginfo should be fetched from
diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
index 83472f00bb0..df84a1dcb98 100644
--- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
+++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
@@ -371,6 +371,7 @@ with_debuginfod_env $cache {
clean_restart
gdb_test_no_output "set debuginfod enabled on" \
"enabled debuginfod for initial test"
+ gdb_test_no_output "set progress-bars enabled off"
gdb_load $binfile
load_core_file "load corefile, download library from debuginfod" \
diff --git a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
index e44748f8205..92de3ee2167 100644
--- a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
+++ b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
@@ -113,6 +113,7 @@ proc_with_prefix local_debuginfod { } {
# Enable debuginfod and fetch the debuginfo.
gdb_test_no_output "set debuginfod enabled on"
+ gdb_test_no_output "set progress-bars enabled off"
gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
"file [file tail $binfile] cmd on"
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index 9078068c8fe..e3d9c36777b 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -218,6 +218,7 @@ proc_with_prefix local_url { } {
clean_restart
gdb_test_no_output "set debuginfod enabled on" \
"enabled debuginfod for initial test"
+ gdb_test_no_output "set progress-bars enabled off"
gdb_load $binfile
gdb_test_no_output "set substitute-path $outputdir /dev/null" \
"set substitute-path"
@@ -243,11 +244,13 @@ proc_with_prefix local_url { } {
set enable_debuginfod_question \
"Enable debuginfod for this session. \\(y or \\\[n\\\]\\) "
clean_restart
+ gdb_test_no_output -nopass "set progress-bars enabled off"
gdb_test "core $::corefile" ".*return 0.*" "file [file tail $::corefile]" \
$enable_debuginfod_question "y"
# GDB should now find the debugaltlink file.
clean_restart
+ gdb_test_no_output -nopass "set progress-bars enabled off"
gdb_test "file ${binfile}_alt.o" \
".*Downloading.*separate debug info.*" \
"file [file tail ${binfile}_alt.o]" \
@@ -269,6 +272,7 @@ proc_with_prefix local_url { } {
# Enable debuginfod and fetch the debuginfo.
gdb_test_no_output "set debuginfod enabled on"
+ gdb_test_no_output -nopass "set progress-bars enabled off"
gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
"file [file tail $binfile] cmd on"
diff --git a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
index a22fa597602..5ff65e8f769 100644
--- a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
+++ b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
@@ -281,6 +281,7 @@ with_debuginfod_env $cache {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set debuginfod enabled on\""
+ append GDBFLAGS " -ex \"set progress-bars enabled off\""
# Reload the executable and core file. GDB should download
# the file libfoo_1.so using debuginfod during the mapped file
next prev parent reply other threads:[~2025-12-09 17:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 16:38 [PATCH 0/4] Fixes and tests related to new boxed hint startup text Andrew Burgess
2025-12-04 16:38 ` [PATCH 1/4] gdb: remove some unnecessary code from print_gdb_hints Andrew Burgess
2025-12-04 17:14 ` Patrick Monnerat
2025-12-04 16:38 ` [PATCH 2/4] gdb: small white space fix in print_gdb_hints Andrew Burgess
2025-12-04 16:38 ` [PATCH 3/4] gdb: make get_chars_per_line return an unsigned value Andrew Burgess
2025-12-04 16:38 ` [PATCH 4/4] gdb: fix crashes and weird output from new boxed hint text Andrew Burgess
2025-12-04 19:02 ` [PATCH 0/4] Fixes and tests related to new boxed hint startup text Guinevere Larsen
2025-12-04 19:32 ` Andrew Burgess
2025-12-04 19:47 ` [PATCH 0/2] " Andrew Burgess
2025-12-04 19:47 ` [PATCH 1/2] gdb: make get_chars_per_line return an unsigned value Andrew Burgess
2025-12-04 19:47 ` [PATCH 2/2] gdb: fix crashes and weird output from new boxed hint text Andrew Burgess
2025-12-05 7:06 ` Eli Zaretskii
2025-12-05 10:17 ` Andrew Burgess
2025-12-05 11:19 ` Eli Zaretskii
2025-12-05 19:53 ` [PATCHv3 0/3] Fixes and tests related to new boxed hint startup text Andrew Burgess
2025-12-05 19:53 ` [PATCHv3 1/3] gdb: make get_chars_per_line return an unsigned value Andrew Burgess
2025-12-10 16:48 ` Tom Tromey
2025-12-05 19:53 ` [PATCHv3 2/3] gdb: fix crashes and weird output from new boxed hint text Andrew Burgess
2025-12-10 16:51 ` Tom Tromey
2025-12-05 19:53 ` [PATCHv3 3/3] WIP: disable progress bars setting Andrew Burgess
2025-12-06 9:12 ` Eli Zaretskii
2025-12-09 17:32 ` Andrew Burgess [this message]
2025-12-10 16:55 ` Tom Tromey
2025-12-15 15:33 ` Andrew Burgess
2025-12-16 7:40 ` Tom de Vries
2025-12-16 10:05 ` Andrew Burgess
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=87h5tz5zn8.fsf@redhat.com \
--to=aburgess@redhat.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