From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2009) id 65F643858C50; Mon, 2 May 2022 20:15:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65F643858C50 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Aaron Merey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/debuginfod: Whitespace-only URL should disable debuginfod X-Act-Checkin: binutils-gdb X-Git-Author: Aaron Merey X-Git-Refname: refs/heads/master X-Git-Oldrev: 03ada39ea590fec3bd722e9ea776049213da8b58 X-Git-Newrev: 95929abb498786d9dce36bb94b6c3f1d63178956 Message-Id: <20220502201528.65F643858C50@sourceware.org> Date: Mon, 2 May 2022 20:15:28 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2022 20:15:28 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D95929abb4987= 86d9dce36bb94b6c3f1d63178956 commit 95929abb498786d9dce36bb94b6c3f1d63178956 Author: Aaron Merey Date: Wed Apr 27 16:41:24 2022 -0400 gdb/debuginfod: Whitespace-only URL should disable debuginfod =20 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). =20 Extend this functionality so that a whitespace-only URL also disables debuginfod. =20 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 =3D getenv (DEBUGINFOD_URLS_ENV_VAR); + const char *urls =3D skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR)); =20 - if (urls =3D=3D nullptr || urls[0] =3D=3D '\0' - || debuginfod_enabled =3D=3D debuginfod_off) + if (debuginfod_enabled =3D=3D debuginfod_off + || urls =3D=3D nullptr + || *urls =3D=3D '\0') return false; =20 if (debuginfod_enabled =3D=3D debuginfod_ask) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/t= estsuite/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 UR= L" { + 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 { } { } } =20 - 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 + } + } =20 set url "http://127.0.0.1:$port"