From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wI6yHJhfsl9WXAAAWB0awg (envelope-from ) for ; Mon, 16 Nov 2020 06:16:40 -0500 Received: by simark.ca (Postfix, from userid 112) id 72E341F08B; Mon, 16 Nov 2020 06:16:40 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 201871E58E for ; Mon, 16 Nov 2020 06:16:40 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE0F83861026; Mon, 16 Nov 2020 11:16:39 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 5E63B3857C6D for ; Mon, 16 Nov 2020 11:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5E63B3857C6D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 752CAAD2B for ; Mon, 16 Nov 2020 11:16:36 +0000 (UTC) Date: Mon, 16 Nov 2020 12:16:34 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Don't return non-existing path in debuginfod_source_query Message-ID: <20201116111633.GA3063@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, When setting env var DEBUGINFOD_URLS to " " and running the testsuite, we run into these regressions: ... FAIL: gdb.base/list-missing-source.exp: info source FAIL: gdb.base/source-dir.exp: info source before setting directory search list ... Setting var DEBUGINFOD_URLS to " " allows the debuginfod query function debuginfod_source_query to get past its early exit. The function debuginfod_source_query is documented as: "If the file is successfully retrieved, its path on the local machine is stored in DESTNAME". However, in case we get back -ENOENT from libdebuginfod, we still set DESTNAME: .... if (fd.get () < 0 && fd.get () != -ENOENT) printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"), safe_strerror (-fd.get ()), styled_string (file_name_style.style (), srcpath)); else *destname = make_unique_xstrdup (srcpath); return fd; ... Fix this by making debuginfod_source_query fit it's documentation and only setting DESTNAME when successfully retrieving a file. Likewise in debuginfod_debuginfo_query. Any comments? Thanks, - Tom [gdb] Don't return non-existing path in debuginfod_source_query gdb/ChangeLog: 2020-11-16 Tom de Vries * debuginfod-support.c (debuginfod_source_query) (debuginfod_debuginfo_query): Only set DESTNAME if successful. --- gdb/debuginfod-support.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index a7c76ab6134..e21b2f40cae 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -134,7 +134,8 @@ debuginfod_source_query (const unsigned char *build_id, printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"), safe_strerror (-fd.get ()), styled_string (file_name_style.style (), srcpath)); - else + + if (fd.get () >= 0) *destname = make_unique_xstrdup (srcpath); return fd; @@ -169,7 +170,8 @@ debuginfod_debuginfo_query (const unsigned char *build_id, safe_strerror (-fd.get ()), styled_string (file_name_style.style (), filename)); - destname->reset (dname); + if (fd.get () >= 0) + destname->reset (dname); return fd; }