From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 5C1643858D39 for ; Sat, 5 Mar 2022 00:17:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C1643858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id C345410047514 for ; Sat, 5 Mar 2022 00:17:45 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QI7Fn4Ew1Qs3CQI7FnAHOl; Sat, 05 Mar 2022 00:17:45 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=d8AwdTvE c=1 sm=1 tr=0 ts=6222ac29 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=o8Y5sQTvuykA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=ylecqwsWDPke91Q53OMA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type: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=7Sg+hbsz3hNdJbpGyWWEcmH4Yul2xeW8UQZtBQwB7bk=; b=eF6TOCislW5b6dw1o2gYVwDSKB Sn7f2LzkRgW1zhm0gajsjB58pK+EUnrkIlTaIBuwOlMOLG3BDn1O8p+gz9YvK+DiOrWTbsILT5Xuv qEpgLrnpDPYfjbVkxof68wtLd; Received: from [161.98.8.2] (port=47122 helo=prentzel.ci.boulder.co.us) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nQI7F-0042o0-12; Fri, 04 Mar 2022 17:17:45 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Simplify hppa-tdep.c use of objfile_key Date: Fri, 4 Mar 2022 17:17:42 -0700 Message-Id: <20220305001742.16165-1-tom@tromey.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 161.98.8.2 X-Source-L: No X-Exim-ID: 1nQI7F-0042o0-12 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (prentzel.ci.boulder.co.us) [161.98.8.2]:47122 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Sat, 05 Mar 2022 00:17:49 -0000 I happened to notice a couple of unnecessary casts in hppa-tdep.c, and then I saw that the use of objfile_key could be simplified -- removing some code and using the default deleter rather than noop_deleter. Tested by rebuilding. Let me know what you think. --- gdb/hppa-tdep.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 760cb1bea13..cf84555a28c 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -70,12 +70,12 @@ struct hppa_unwind_info struct hppa_objfile_private { - struct hppa_unwind_info *unwind_info; /* a pointer */ - struct so_list *so_info; /* a pointer */ - CORE_ADDR dp; + struct hppa_unwind_info *unwind_info = nullptr; /* a pointer */ + struct so_list *so_info = nullptr; /* a pointer */ + CORE_ADDR dp = 0; - int dummy_call_sequence_reg; - CORE_ADDR dummy_call_sequence_addr; + int dummy_call_sequence_reg = 0; + CORE_ADDR dummy_call_sequence_addr = 0; }; /* hppa-specific object data -- unwind and solib info. @@ -84,9 +84,7 @@ struct hppa_objfile_private that separately and make this static. The solib data is probably hpux- specific, so we can create a separate extern objfile_data that is registered by hppa-hpux-tdep.c and shared with pa64solib.c and somsolib.c. */ -static const struct objfile_key> - hppa_objfile_priv_data; +static const struct objfile_key hppa_objfile_priv_data; /* Get at various relevant fields of an instruction word. */ #define MASK_5 0x1f @@ -204,16 +202,6 @@ hppa_symbol_address(const char *sym) return (CORE_ADDR)-1; } -static struct hppa_objfile_private * -hppa_init_objfile_priv_data (struct objfile *objfile) -{ - hppa_objfile_private *priv - = OBSTACK_ZALLOC (&objfile->objfile_obstack, hppa_objfile_private); - - hppa_objfile_priv_data.set (objfile, priv); - - return priv; -} /* Compare the start address for two unwind entries returning 1 if @@ -471,7 +459,7 @@ read_unwind_info (struct objfile *objfile) /* Keep a pointer to the unwind information. */ obj_private = hppa_objfile_priv_data.get (objfile); if (obj_private == NULL) - obj_private = hppa_init_objfile_priv_data (objfile); + obj_private = hppa_objfile_priv_data.emplace (objfile); obj_private->unwind_info = ui; } @@ -485,7 +473,6 @@ struct unwind_table_entry * find_unwind_entry (CORE_ADDR pc) { int first, middle, last; - struct hppa_objfile_private *priv; if (hppa_debug) fprintf_unfiltered (gdb_stdlog, "{ find_unwind_entry %s -> ", @@ -503,9 +490,9 @@ find_unwind_entry (CORE_ADDR pc) { struct hppa_unwind_info *ui; ui = NULL; - priv = hppa_objfile_priv_data.get (objfile); + struct hppa_objfile_private *priv = hppa_objfile_priv_data.get (objfile); if (priv) - ui = ((struct hppa_objfile_private *) priv)->unwind_info; + ui = priv->unwind_info; if (!ui) { @@ -513,7 +500,7 @@ find_unwind_entry (CORE_ADDR pc) priv = hppa_objfile_priv_data.get (objfile); if (priv == NULL) error (_("Internal error reading unwind information.")); - ui = ((struct hppa_objfile_private *) priv)->unwind_info; + ui = priv->unwind_info; } /* First, check the cache. */ -- 2.34.1