public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/debuginfod: Whitespace-only URL should disable debuginfod
@ 2022-05-02 20:15 Aaron Merey
  0 siblings, 0 replies; only message in thread
From: Aaron Merey @ 2022-05-02 20:15 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95929abb498786d9dce36bb94b6c3f1d63178956

commit 95929abb498786d9dce36bb94b6c3f1d63178956
Author: Aaron Merey <amerey@redhat.com>
Date:   Wed Apr 27 16:41:24 2022 -0400

    gdb/debuginfod: Whitespace-only URL should disable debuginfod
    
    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.

Diff:
---
 gdb/debuginfod-support.c                               |  7 ++++---
 gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 4ce2e786b6a..dffcd782e7d 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -173,10 +173,11 @@ get_debuginfod_client ()
 static bool
 debuginfod_is_enabled ()
 {
-  const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
+  const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR));
 
-  if (urls == nullptr || urls[0] == '\0'
-      || debuginfod_enabled == debuginfod_off)
+  if (debuginfod_enabled == debuginfod_off
+      || urls == nullptr
+      || *urls == '\0')
     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..74d026464b9 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -309,7 +309,8 @@ proc local_url { } {
     clean_restart
     # Disable confirmation to avoid having to deal with a query.  See
     # test_urls.
-    gdb_test_multiple "with confirm off -- file $binfile" "notice empty URL" {
+    set file_cmd "with confirm off -- file $binfile"
+    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"


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-02 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 20:15 [binutils-gdb] gdb/debuginfod: Whitespace-only URL should disable debuginfod Aaron Merey

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).