From patchwork Mon Mar 13 22:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66347 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB18E384842D for ; Mon, 13 Mar 2023 22:10:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 0E2613858417 for ; Mon, 13 Mar 2023 22:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E2613858417 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id C4D3E10048299 for ; Mon, 13 Mar 2023 22:08:06 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKspFhYpUEmJbqKsp3I78; Mon, 13 Mar 2023 22:08:06 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=TLSA93pa c=1 sm=1 tr=0 ts=640f9ec6 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=k__wU0fu6RkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=LwEYB1O3oJgRZ08wLgkA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=NBI/wxasuK3V672b7dYv2JN+O281xKK98+xkSEkUDp0=; b=bwV4tgFVjNhY5FJ7pqR0Rlvbzp o8Ls7JqotIi9fz7CItG6ZZJ6hSpQrBzn+F12AOkoQgvyTM0BvaS4t8gKXoSyDUjzOHDcXNCjx5eYT L1RC40FO4id8Ci1GMkyhpomWU; Received: from 71-211-185-113.hlrn.qwest.net ([71.211.185.113]:52788 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pbqKs-000u2m-Fp for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:06 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:02 -0600 Subject: [PATCH 02/20] Remove alloc_type_arch MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-2-69ba773ac17b@tromey.com> References: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com> In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 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: 71.211.185.113 X-Source-L: No X-Exim-ID: 1pbqKs-000u2m-Fp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-185-113.hlrn.qwest.net ([192.168.0.21]) [71.211.185.113]:52788 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This removes alloc_type_arch, replacing all uses with the new type allocator. --- gdb/gdbtypes.c | 37 ++++--------------------------------- gdb/gdbtypes.h | 2 -- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 5bb49063d5a..1e880edf681 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -258,32 +258,6 @@ alloc_type (struct objfile *objfile) return type; } -/* Allocate a new GDBARCH-associated type structure and fill it - with some defaults. Space for the type structure is allocated - on the obstack associated with GDBARCH. */ - -struct type * -alloc_type_arch (struct gdbarch *gdbarch) -{ - struct type *type; - - gdb_assert (gdbarch != NULL); - - /* Alloc the structure and start off with all fields zeroed. */ - - type = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct type); - TYPE_MAIN_TYPE (type) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct main_type); - - type->set_owner (gdbarch); - - /* Initialize the fields that might not be zero. */ - - type->set_code (TYPE_CODE_UNDEF); - TYPE_CHAIN (type) = type; /* Chain back to itself. */ - - return type; -} - /* If TYPE is objfile-associated, allocate a new type structure associated with the same objfile. If TYPE is gdbarch-associated, allocate a new type structure associated with the same gdbarch. */ @@ -291,10 +265,7 @@ alloc_type_arch (struct gdbarch *gdbarch) struct type * alloc_type_copy (const struct type *type) { - if (type->is_objfile_owned ()) - return alloc_type (type->objfile_owner ()); - else - return alloc_type_arch (type->arch_owner ()); + return type_allocator (type).new_type (); } /* See gdbtypes.h. */ @@ -3112,7 +3083,7 @@ check_typedef (struct type *type) if (sym) type->set_target_type (sym->type ()); else /* TYPE_CODE_UNDEF */ - type->set_target_type (alloc_type_arch (type->arch ())); + type->set_target_type (type_allocator (type->arch ()).new_type ()); } type = type->target_type (); @@ -5689,7 +5660,7 @@ copy_type_recursive (struct type *type, htab_t copied_types) if (*slot != NULL) return ((struct type_pair *) *slot)->newobj; - new_type = alloc_type_arch (type->arch ()); + new_type = type_allocator (type->arch ()).new_type (); /* We must add the new type to the hash table immediately, in case we encounter this type again during a recursive call below. */ @@ -5861,7 +5832,7 @@ arch_type (struct gdbarch *gdbarch, { struct type *type; - type = alloc_type_arch (gdbarch); + type = type_allocator (gdbarch).new_type (); set_type_code (type, code); gdb_assert ((bit % TARGET_CHAR_BIT) == 0); type->set_length (bit / TARGET_CHAR_BIT); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 613c22d676b..861d0021d30 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2187,12 +2187,10 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN]; #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size)) /* Use alloc_type to allocate a type owned by an objfile. Use - alloc_type_arch to allocate a type owned by an architecture. Use alloc_type_copy to allocate a type with the same owner as a pre-existing template type, no matter whether objfile or gdbarch. */ extern struct type *alloc_type (struct objfile *); -extern struct type *alloc_type_arch (struct gdbarch *); extern struct type *alloc_type_copy (const struct type *); /* * This returns the target type (or NULL) of TYPE, also skipping