From: Aaron Merey <amerey@redhat.com>
To: gdb-patches@sourceware.org
Cc: pedro@palves.net, Aaron Merey <amerey@redhat.com>
Subject: [PATCH] gdb/debuginfod: Whitespace-only URL should disable debuginfod
Date: Wed, 27 Apr 2022 17:46:53 -0400 [thread overview]
Message-ID: <20220427214653.311789-1-amerey@redhat.com> (raw)
Currently debuginfod is disabled when the string of server URLs
is unset or set to be the empty string (via the $DEBUGINFOD_URLS
environment variable or the 'set debuginfod urls' gdb command).
Extend this functionality so that a whitespace-only URL also disables
debuginfod.
Modify a testcase to verify that a whitespace-only URL disables
debuginfod.
---
gdb/debuginfod-support.c | 6 +++---
.../gdb.debuginfod/fetch_src_and_symbols.exp | 17 +++++++++++++----
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 4ce2e786b6a..f47ed515e28 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -173,10 +173,10 @@ get_debuginfod_client ()
static bool
debuginfod_is_enabled ()
{
- const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
+ std::string urls = getenv (DEBUGINFOD_URLS_ENV_VAR) ?: "";
- if (urls == nullptr || urls[0] == '\0'
- || debuginfod_enabled == debuginfod_off)
+ if (debuginfod_enabled == debuginfod_off
+ || urls.find_first_not_of (' ') == std::string::npos)
return false;
if (debuginfod_enabled == debuginfod_ask)
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index bd90bcd0cfe..8b1618c242b 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -307,9 +307,10 @@ proc local_url { } {
# Empty URLS disables Debuginfod.
setenv DEBUGINFOD_URLS ""
clean_restart
+ set file_cmd "with confirm off -- file $binfile"
# Disable confirmation to avoid having to deal with a query. See
# test_urls.
- gdb_test_multiple "with confirm off -- file $binfile" "notice empty URL" {
+ gdb_test_multiple $file_cmd "notice empty URL" {
-re -wrap "This GDB supports auto-downloading.*" {
fail $gdb_test_name
}
@@ -318,9 +319,17 @@ proc local_url { } {
}
}
- test_urls " " \
- "" \
- "notice whitespace URL"
+ # Whitespace-only URLS disables Debuginfod.
+ setenv DEBUGINFOD_URLS " "
+ clean_restart
+ gdb_test_multiple $file_cmd "notice whitespace URL" {
+ -re -wrap "This GDB supports auto-downloading.*" {
+ fail $gdb_test_name
+ }
+ -re -wrap "" {
+ pass $gdb_test_name
+ }
+ }
set url "http://127.0.0.1:$port"
--
2.35.1
next reply other threads:[~2022-04-27 21:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 21:46 Aaron Merey [this message]
2022-04-28 15:34 ` Tom Tromey
2022-04-28 16:28 ` Pedro Alves
2022-04-28 22:37 ` Aaron Merey
2022-04-29 14:22 ` Pedro Alves
2022-04-29 19:49 ` Aaron Merey
2022-05-02 14:33 ` Pedro Alves
2022-05-02 20:16 ` Aaron Merey
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=20220427214653.311789-1-amerey@redhat.com \
--to=amerey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).