From patchwork Fri May 4 17:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27113 Received: (qmail 125635 invoked by alias); 4 May 2018 17:34:18 -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 125247 invoked by uid 89); 4 May 2018 17:34:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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.2 spammy=bfd-target.c, UD:bfd-target.c, bfdtargetc, target_bfd X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 17:34:16 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 1E363400C85C3 for ; Fri, 4 May 2018 12:34:15 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Eeb1fqRsMWCOCEeb1fjO3l; Fri, 04 May 2018 12:34:15 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:55638 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fEeb0-002WAV-RO; Fri, 04 May 2018 12:34:14 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Use gdb_bfd_ref_ptr in target_bfd Date: Fri, 4 May 2018 11:34:12 -0600 Message-Id: <20180504173412.13030-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fEeb0-002WAV-RO X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:55638 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes I noticed that target_bfd was using manual reference counting for the BFD it held. This patch changes it to use gdb_bfd_ref_ptr instead. Tested by the buildbot. ChangeLog 2018-05-04 Tom Tromey * bfd-target.c (target_bfd::m_bfd): Now a gdb_bfd_ref_ptr. (target_bfd::target_bfd, target_bfd::~target_bfd): Update. --- gdb/ChangeLog | 5 +++++ gdb/bfd-target.c | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index ba194d7b04..6138d450d9 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -53,7 +53,7 @@ public: private: /* The BFD we're wrapping. */ - struct bfd *m_bfd; + gdb_bfd_ref_ptr m_bfd; /* The section table build from the ALLOC sections in BFD. Note that we can't rely on extracting the BFD from a random section in @@ -90,10 +90,9 @@ target_bfd::get_section_table () } target_bfd::target_bfd (struct bfd *abfd) + : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd)) { this->to_stratum = file_stratum; - m_bfd = abfd; - gdb_bfd_ref (abfd); m_table.sections = NULL; m_table.sections_end = NULL; build_section_table (abfd, &m_table.sections, &m_table.sections_end); @@ -101,7 +100,6 @@ target_bfd::target_bfd (struct bfd *abfd) target_bfd::~target_bfd () { - gdb_bfd_unref (m_bfd); xfree (m_table.sections); }