From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 609403858D28 for ; Fri, 29 Apr 2022 19:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 609403858D28 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-tp8nbOhcNy6k4wn00FJLEg-1; Fri, 29 Apr 2022 15:50:01 -0400 X-MC-Unique: tp8nbOhcNy6k4wn00FJLEg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A39223C0D1A5; Fri, 29 Apr 2022 19:50:00 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.8.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AB5B2024CB6; Fri, 29 Apr 2022 19:49:59 +0000 (UTC) From: Aaron Merey To: pedro@palves.net Cc: tom@tromey.com, gdb-patches@sourceware.org Subject: [PATCH] gdb/debuginfod: Whitespace-only URL should disable debuginfod Date: Fri, 29 Apr 2022 15:49:58 -0400 Message-Id: <20220429194958.481475-1-amerey@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_BADIPHTTP, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2022 19:50:06 -0000 On Fri, Apr 29, 2022 at 10:22 AM Pedro Alves wrote: > Does the rest of the function need to see "urls" with the leading space?  It seems like the > code further below will also skip leading spaces anyhow.  IOW, we can't make this be: > >     urls = skip_spaces (urls); > > or both lines replaced with: > >     const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR)); > > ? I kept the "urls" with the leading whitespace so that we parse each URL consistent with debuginfod's use of ' ' as the sole URL delimiter (skip_space also skips tabs, newlines, etc). However debuginfod severs should not have URLs containing unescaped whitespace so it's really a moot point. I've fixed this by combining skip_spaces and getenv on one line. Aaron >From 4cd3582892440d2092c65df8472427566dbceaa9 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Wed, 27 Apr 2022 16:41:24 -0400 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 | 7 ++++--- .../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" -- 2.35.1