From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eFoiGssIjl9yRwAAWB0awg (envelope-from ) for ; Mon, 19 Oct 2020 17:44:43 -0400 Received: by simark.ca (Postfix, from userid 112) id 6851B1EFBD; Mon, 19 Oct 2020 17:44:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 4AB4D1E58E for ; Mon, 19 Oct 2020 17:44:42 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA8003865C2A; Mon, 19 Oct 2020 21:44:38 +0000 (GMT) Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.50.28]) by sourceware.org (Postfix) with ESMTPS id E9547388EC00 for ; Mon, 19 Oct 2020 21:44:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E9547388EC00 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 438EB400C4D53 for ; Mon, 19 Oct 2020 16:42:54 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id UcxGkSRU0PiqfUcxGkYhRZ; Mon, 19 Oct 2020 16:44:34 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6e4elfAVoRk79U2VD31EitrDwMFFubNN53A5ONic5bM=; b=qSJtl4jhuNLCO1nh07kZgcAvuM ArNmx0zUWByIds4p80yLhiAoq32vtImCAUlgKTqWf5wFHU/1sCg6xqMvMCBjRHYCLdH1S99T0eZuX d896PIPF1cAlU28zbjp5wh3UZ; Received: from 75-166-102-113.hlrn.qwest.net ([75.166.102.113]:45712 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kUcxG-004Oci-Am; Mon, 19 Oct 2020 15:44:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH v2 08/16] Change program_space::ebfd to a gdb_bfd_ref_ptr Date: Mon, 19 Oct 2020 15:44:21 -0600 Message-Id: <20201019214429.13815-9-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20201019214429.13815-1-tom@tromey.com> References: <20201019214429.13815-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.102.113 X-Source-L: No X-Exim-ID: 1kUcxG-004Oci-Am X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-102-113.hlrn.qwest.net (bapiya.Home) [75.166.102.113]:45712 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This changes program_space::ebfd to a gdb_bfd_ref_ptr, removing some manual management. gdb/ChangeLog 2020-10-19 Tom Tromey * exec.c (exec_file_attach): Update. * progspace.c (program_space::exec_close): Update. * progspace.h (struct program_space) : Now a gdb_bfd_ref_ptr. : Change argument type. : Update. --- gdb/ChangeLog | 9 +++++++++ gdb/exec.c | 2 +- gdb/progspace.c | 6 ++---- gdb/progspace.h | 8 ++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 85ad1aa49cb..4a82b38ea41 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -453,7 +453,7 @@ exec_file_attach (const char *filename, int from_tty) FOPEN_RUB, scratch_chan); else temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan); - current_program_space->set_exec_bfd (temp.release ()); + current_program_space->set_exec_bfd (std::move (temp)); if (!current_program_space->exec_bfd ()) { diff --git a/gdb/progspace.c b/gdb/progspace.c index 57edc298da7..52482ca8f64 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -228,13 +228,11 @@ program_space::solibs () const void program_space::exec_close () { - if (ebfd) + if (ebfd != nullptr) { - gdb_bfd_unref (ebfd); - /* Removing target sections may close the exec_ops target. Clear ebfd before doing so to prevent recursion. */ - ebfd = NULL; + ebfd.reset (nullptr); ebfd_mtime = 0; remove_target_sections (&ebfd); diff --git a/gdb/progspace.h b/gdb/progspace.h index 5e49083884a..8150d8a2a62 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -279,13 +279,13 @@ struct program_space /* Return the exec BFD for this program space. */ bfd *exec_bfd () const { - return ebfd; + return ebfd.get (); } /* Set the exec BFD for this program space to ABFD. */ - void set_exec_bfd (bfd *abfd) + void set_exec_bfd (gdb_bfd_ref_ptr &&abfd) { - ebfd = abfd; + ebfd = std::move (abfd); } /* Unique ID number. */ @@ -295,7 +295,7 @@ struct program_space managed by the exec target. */ /* The BFD handle for the main executable. */ - bfd *ebfd = NULL; + gdb_bfd_ref_ptr ebfd; /* The last-modified time, from when the exec was brought in. */ long ebfd_mtime = 0; /* Similar to bfd_get_filename (exec_bfd) but in original form given -- 2.17.2