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.133.124]) by sourceware.org (Postfix) with ESMTPS id 3678F385B804 for ; Fri, 1 Apr 2022 20:08:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3678F385B804 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-10-HZqd8-mQMECYC9mB2x3Pzw-1; Fri, 01 Apr 2022 16:08:09 -0400 X-MC-Unique: HZqd8-mQMECYC9mB2x3Pzw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8720089C5E3 for ; Fri, 1 Apr 2022 20:08:08 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.10.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 573EC40E58A4; Fri, 1 Apr 2022 20:08:08 +0000 (UTC) From: Aaron Merey To: gdb-patches@sourceware.org Subject: [PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name Date: Fri, 1 Apr 2022 16:07:51 -0400 Message-Id: <20220401200751.242370-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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, 01 Apr 2022 20:08:13 -0000 The call to debuginfod_debuginfo_query in elf_symfile_read is given objfile->original_name as the filename to print when downloading the objfile's debuginfo. In some cases original_name is prefixed with gdb's working directory even though the objfile is not located in the working directory. This causes debuginfod to display the wrong path of the objfile during a download. Fix this by using the objfile's bfd filename instead. --- gdb/elfread.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/elfread.c b/gdb/elfread.c index fb40032c505..3554e5d71a2 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1286,13 +1286,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) { has_dwarf2 = false; const struct bfd_build_id *build_id = build_id_bfd_get (objfile->obfd); + const char *filename = bfd_get_filename (objfile->obfd); if (build_id != nullptr) { gdb::unique_xmalloc_ptr symfile_path; scoped_fd fd (debuginfod_debuginfo_query (build_id->data, build_id->size, - objfile->original_name, + filename, &symfile_path)); if (fd.get () >= 0) @@ -1302,7 +1303,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) if (debug_bfd == nullptr) warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), - objfile->original_name); + filename); else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data)) { symbol_file_add_separate (debug_bfd.get (), symfile_path.get (), -- 2.35.1