From patchwork Wed Feb 12 00:11:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37982 Received: (qmail 105268 invoked by alias); 12 Feb 2020 00:13:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 105257 invoked by uid 89); 12 Feb 2020 00:13:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=arranges X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.199.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2020 00:13:41 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 5985F4020F90A for ; Tue, 11 Feb 2020 17:25:52 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 1fd9jl3lqAGTX1fd9jxQZ9; Tue, 11 Feb 2020 18:11:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vUv0cUqzVs+Hy/Fcpr50/4jHhDV03JdEF3FcW9Glaug=; b=xLq5teCBwmVXKqJLos7MYUJr/m 9RMCcLZawA8ySTmjPWSTUzXT2Pr4oiWcOTEqKVqkV58Zd4BW8eybQR2uJu3lhmFD5S0RVgsMPsrP3 Gy+NksMUHr0Csu7yj22buDMxL; Received: from 50-194-130-62-static.hfc.comcastbusiness.net ([50.194.130.62]:59166 helo=bapiya.hsd1.co.comcast.net) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j1fd9-001FJV-KJ; Tue, 11 Feb 2020 17:11:51 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Cache .gnu_debugdata BFD Date: Tue, 11 Feb 2020 17:11:49 -0700 Message-Id: <20200212001149.1458-1-tom@tromey.com> While looking at the output of "maint info bfd" with multiple inferiors, I noticed that there were duplicate entries for .gnu_debugdata. There is no reason to re-create this BFD each time it is needed. This patch arranges to share the data. gdb/ChangeLog 2020-02-11 Tom Tromey * minidebug.c (gnu_debug_key): New global. (find_separate_debug_file_in_section): Use it. Change-Id: If139f89f0f07db33f399afdbcfbf5aaeffe4de46 --- gdb/ChangeLog | 5 +++++ gdb/minidebug.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/gdb/minidebug.c b/gdb/minidebug.c index a56a822628e..dbf14c79fb9 100644 --- a/gdb/minidebug.c +++ b/gdb/minidebug.c @@ -26,6 +26,10 @@ #ifdef HAVE_LIBLZMA +/* We stash a reference to the .gnu_debugdata BFD on the enclosing + BFD. */ +static const bfd_key gnu_debug_key; + #include /* Allocator function for LZMA. */ @@ -269,6 +273,10 @@ find_separate_debug_file_in_section (struct objfile *objfile) return NULL; #ifdef HAVE_LIBLZMA + gdb_bfd_ref_ptr *shared = gnu_debug_key.get (objfile->obfd); + if (shared != nullptr) + return *shared; + std::string filename = string_printf (_(".gnu_debugdata for %s"), objfile_name (objfile)); @@ -282,6 +290,9 @@ find_separate_debug_file_in_section (struct objfile *objfile) warning (_("Cannot parse .gnu_debugdata section; not a BFD object")); return NULL; } + + gnu_debug_key.emplace (objfile->obfd, abfd); + #else warning (_("Cannot parse .gnu_debugdata section; LZMA support was " "disabled at compile time"));