From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH v5 1/4] [gdb] Simplify debuginfod_is_enabled
Date: Tue, 14 Apr 2026 14:40:15 +0200 [thread overview]
Message-ID: <fe9d48b7-817f-4abe-9b7b-c0057e9bd365@suse.de> (raw)
In-Reply-To: <20260314173737.1436116-2-tdevries@suse.de>
On 3/14/26 6:37 PM, Tom de Vries wrote:
> Simplify debuginfod_is_enabled by adding an early-exit for the
> debuginfod_enabled == debuginfod_on case.
I've pushed this.
I noticed I got the indentation of this bit wrong (I used emacs auto-ident):
...
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
off = url_view.find_first_of (' ');
DIAGNOSTIC_POP
...
so I've fixed that before pushing.
Thanks,
- Tom
> ---
> gdb/debuginfod-support.c | 81 ++++++++++++++++++++--------------------
> 1 file changed, 41 insertions(+), 40 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 3da3edc432d..ca4a5b1a7af 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -232,57 +232,58 @@ debuginfod_is_enabled ()
> {
> const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR));
>
> - if (debuginfod_enabled == debuginfod_off
> - || urls == nullptr
> + if (urls == nullptr
> || *urls == '\0')
> return false;
>
> - if (debuginfod_enabled == debuginfod_ask)
> - {
> - gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
> - "from the following URLs:\n"));
> + if (debuginfod_enabled != debuginfod_ask)
> + return debuginfod_enabled == debuginfod_on;
>
> - std::string_view url_view (urls);
> - while (true)
> - {
> - size_t off = url_view.find_first_not_of (' ');
> - if (off == std::string_view::npos)
> - break;
> - url_view = url_view.substr (off);
> - /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
> - hppa seem convinced url_view might be of SIZE_MAX length.
> - And so complains because the length of an array can only
> - be PTRDIFF_MAX. */
> - DIAGNOSTIC_PUSH
> - DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
> - off = url_view.find_first_of (' ');
> - DIAGNOSTIC_POP
> - gdb_printf
> - (_(" <%ps>\n"),
> - styled_string (file_name_style.style (),
> - std::string (url_view.substr (0, off)).c_str ()));
> - if (off == std::string_view::npos)
> - break;
> - url_view = url_view.substr (off);
> - }
> + gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
> + "from the following URLs:\n"));
>
> - int resp = nquery (_("Enable debuginfod for this session? "));
> - if (!resp)
> - {
> - gdb_printf (_("Debuginfod has been disabled.\nTo make this " \
> - "setting permanent, add \'set debuginfod " \
> - "enabled off\' to .gdbinit.\n"));
> - debuginfod_enabled = debuginfod_off;
> - return false;
> - }
> + std::string_view url_view (urls);
> + while (true)
> + {
> + size_t off = url_view.find_first_not_of (' ');
> + if (off == std::string_view::npos)
> + break;
> + url_view = url_view.substr (off);
> + /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
> + hppa seem convinced url_view might be of SIZE_MAX length.
> + And so complains because the length of an array can only
> + be PTRDIFF_MAX. */
> + DIAGNOSTIC_PUSH
> + DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
> + off = url_view.find_first_of (' ');
> + DIAGNOSTIC_POP
> + gdb_printf
> + (_(" <%ps>\n"),
> + styled_string (file_name_style.style (),
> + std::string (url_view.substr (0, off)).c_str ()));
> + if (off == std::string_view::npos)
> + break;
> + url_view = url_view.substr (off);
> + }
>
> - gdb_printf (_("Debuginfod has been enabled.\nTo make this " \
> + int resp = nquery (_("Enable debuginfod for this session? "));
> + if (!resp)
> + {
> + gdb_printf (_("Debuginfod has been disabled.\nTo make this " \
> + "setting permanent, add \'set debuginfod " \
> + "enabled off\' to .gdbinit.\n"));
> + debuginfod_enabled = debuginfod_off;
> + }
> + else
> + {
> + gdb_printf (_("Debuginfod has been enabled.\nTo make this " \
> "setting permanent, add \'set debuginfod enabled " \
> "on\' to .gdbinit.\n"));
> debuginfod_enabled = debuginfod_on;
> }
>
> - return true;
> + gdb_assert (debuginfod_enabled != debuginfod_ask);
> + return debuginfod_enabled == debuginfod_on;
> }
>
> /* Print the result of the most recent attempted download. */
next prev parent reply other threads:[~2026-04-14 12:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 17:37 [PATCH v5 0/4] [gdb/tui] Fix crash with debuginfod query Tom de Vries
2026-03-14 17:37 ` [PATCH v5 1/4] [gdb] Simplify debuginfod_is_enabled Tom de Vries
2026-04-14 12:40 ` Tom de Vries [this message]
2026-03-14 17:37 ` [PATCH v5 2/4] [gdb] Add debuginfod_enabled_ask_p Tom de Vries
2026-03-14 17:37 ` [PATCH v5 3/4] [gdb] Add defaulted_query_auto_answers_p Tom de Vries
2026-03-14 17:37 ` [PATCH v5 4/4] [gdb/tui] Don't enter TUI if debuginfod enabled == ask Tom de Vries
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=fe9d48b7-817f-4abe-9b7b-c0057e9bd365@suse.de \
--to=tdevries@suse.de \
--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