From patchwork Mon Mar 13 22:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66341 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 779B1384F036 for ; Mon, 13 Mar 2023 22:09:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 0B48C3858D32 for ; Mon, 13 Mar 2023 22:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B48C3858D32 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id C20AB1004CA47 for ; Mon, 13 Mar 2023 22:08:06 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKspXv3xNX2abqKspEw58; Mon, 13 Mar 2023 22:08:06 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g 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=9lwuInUVEUyxk41ULTgA: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=fLf+OkbrWirWwuGVIdorsV1XLWuU/zXDPq6a92EyntM=; b=JWMJoJ6lDlKreEUmPBZKZn299d inkgky6qnQyTYZvgAqV0kW2DGVarazxFpsViyiS8gIN603TQ2N++CcGKWxV/EdZ1lNXszfE/Mn1ur uSRqgSh6Ml9LTeDWy/y5Q+/yM; 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-Bn for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:06 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:01 -0600 Subject: [PATCH 01/20] Introduce type_allocator MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-1-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-Bn 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: 2 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 introduces a new type_allocator class. This class will be used to abstract out the placement of new types, so that type-creation code can be simplified and shared. --- gdb/gdbtypes.c | 118 ++++++++++++++++++++++++++++++++++++++++++++------------- gdb/gdbtypes.h | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 27 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index cfd0a1b62c7..5bb49063d5a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -173,6 +173,64 @@ show_strict_type_checking (struct ui_file *file, int from_tty, } +/* Helper function to initialize a newly allocated type. Set type code + to CODE and initialize the type-specific fields accordingly. */ + +static void +set_type_code (struct type *type, enum type_code code) +{ + type->set_code (code); + + switch (code) + { + case TYPE_CODE_STRUCT: + case TYPE_CODE_UNION: + case TYPE_CODE_NAMESPACE: + INIT_CPLUS_SPECIFIC (type); + break; + case TYPE_CODE_FLT: + TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FLOATFORMAT; + break; + case TYPE_CODE_FUNC: + INIT_FUNC_SPECIFIC (type); + break; + case TYPE_CODE_FIXED_POINT: + INIT_FIXED_POINT_SPECIFIC (type); + break; + } +} + +/* See gdbtypes.h. */ + +type * +type_allocator::new_type () +{ + if (m_smash) + return m_data.type; + + obstack *obstack = (m_is_objfile + ? &m_data.objfile->objfile_obstack + : gdbarch_obstack (m_data.gdbarch)); + + /* Alloc the structure and start off with all fields zeroed. */ + struct type *type = OBSTACK_ZALLOC (obstack, struct type); + TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (obstack, struct main_type); + + if (m_is_objfile) + { + OBJSTAT (m_data.objfile, n_types++); + type->set_owner (m_data.objfile); + } + else + type->set_owner (m_data.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; +} + /* Allocate a new OBJFILE-associated type structure and fill it with some defaults. Space for the type structure is allocated on the objfile's objfile_obstack. */ @@ -241,6 +299,39 @@ alloc_type_copy (const struct type *type) /* See gdbtypes.h. */ +type * +type_allocator::new_type (enum type_code code, int bit, const char *name) +{ + struct type *type = new_type (); + set_type_code (type, code); + gdb_assert ((bit % TARGET_CHAR_BIT) == 0); + type->set_length (bit / TARGET_CHAR_BIT); + + if (name != nullptr) + { + obstack *obstack = (m_is_objfile + ? &m_data.objfile->objfile_obstack + : gdbarch_obstack (m_data.gdbarch)); + type->set_name (obstack_strdup (obstack, name)); + } + + return type; +} + +/* See gdbtypes.h. */ + +gdbarch * +type_allocator::arch () +{ + if (m_smash) + return m_data.type->arch (); + if (m_is_objfile) + return m_data.objfile->arch (); + return m_data.gdbarch; +} + +/* See gdbtypes.h. */ + gdbarch * type::arch () const { @@ -3344,33 +3435,6 @@ allocate_gnat_aux_type (struct type *type) *(TYPE_GNAT_SPECIFIC (type)) = gnat_aux_default; } -/* Helper function to initialize a newly allocated type. Set type code - to CODE and initialize the type-specific fields accordingly. */ - -static void -set_type_code (struct type *type, enum type_code code) -{ - type->set_code (code); - - switch (code) - { - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_NAMESPACE: - INIT_CPLUS_SPECIFIC (type); - break; - case TYPE_CODE_FLT: - TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FLOATFORMAT; - break; - case TYPE_CODE_FUNC: - INIT_FUNC_SPECIFIC (type); - break; - case TYPE_CODE_FIXED_POINT: - INIT_FIXED_POINT_SPECIFIC (type); - break; - } -} - /* Helper function to verify floating-point format and size. BIT is the type size in bits; if BIT equals -1, the size is determined by the floatformat. Returns size to be used. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 52475d5afb4..613c22d676b 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2205,6 +2205,104 @@ extern struct type *get_target_type (struct type *type); extern unsigned int type_length_units (struct type *type); +/* An object of this type is passed when allocating certain types. It + determines where the new type is allocated. Ultimately a type is + either allocated on a on an objfile obstack or on a gdbarch + obstack. However, it's also possible to request that a new type be + allocated on the same obstack as some existing type, or that a + "new" type instead overwrite a supplied type object. */ + +class type_allocator +{ +public: + + /* Create new types on OBJFILE. */ + explicit type_allocator (objfile *objfile) + : m_is_objfile (true) + { + m_data.objfile = objfile; + } + + /* Create new types on GDBARCH. */ + explicit type_allocator (gdbarch *gdbarch) + { + m_data.gdbarch = gdbarch; + } + + /* This determines whether a passed-in type should be rewritten in + place, or whether it should simply determine where the new type + is created. */ + enum type_allocator_kind + { + /* Allocate on same obstack as existing type. */ + SAME = 0, + /* Smash the existing type. */ + SMASH = 1, + }; + + /* Create new types either on the same obstack as TYPE; or if SMASH + is passed, overwrite TYPE. */ + explicit type_allocator (struct type *type, + type_allocator_kind kind = SAME) + { + if (kind == SAME) + { + if (type->is_objfile_owned ()) + { + m_data.objfile = type->objfile_owner (); + m_is_objfile = true; + } + else + m_data.gdbarch = type->arch_owner (); + } + else + { + m_smash = true; + m_data.type = type; + } + } + + /* Create new types on the same obstack as TYPE. */ + explicit type_allocator (const struct type *type) + : m_is_objfile (type->is_objfile_owned ()) + { + if (type->is_objfile_owned ()) + m_data.objfile = type->objfile_owner (); + else + m_data.gdbarch = type->arch_owner (); + } + + /* Create a new type on the desired obstack. Note that a "new" type + is not created if type-smashing was selected at construction. */ + type *new_type (); + + /* Create a new type on the desired obstack, and fill in its code, + length, and name. If NAME is non-null, it is copied to the + destination obstack first. Note that a "new" type is not created + if type-smashing was selected at construction. */ + type *new_type (enum type_code code, int bit, const char *name); + + /* Return the architecture associated with this allocator. This + comes from whatever object was supplied to the constructor. */ + gdbarch *arch (); + +private: + + /* Where the type should wind up. */ + union + { + struct objfile *objfile; + struct gdbarch *gdbarch; + struct type *type; + } m_data {}; + + /* True if this allocator uses the objfile field above. */ + bool m_is_objfile = false; + /* True if this allocator uses the type field above, indicating that + the "allocation" should be done in-place. */ + bool m_smash = false; +}; + /* * Helper function to construct objfile-owned types. */ extern struct type *init_type (struct objfile *, enum type_code, int, 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 From patchwork Mon Mar 13 22:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66334 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 3C23F3850232 for ; Mon, 13 Mar 2023 22:08:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id A74B43858C27 for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A74B43858C27 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 progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id E3C481004A3F6 for ; Mon, 13 Mar 2023 22:08:06 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKspfLG5HIU4bqKspFy9r; Mon, 13 Mar 2023 22:08:06 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NfUja0P4 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=Dhl7312aG6fIw3zdZO4A: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=wDsFtfh8JrJh3SSgoeZKq/+gSlsh++hAcjreiDqoISs=; b=vjWcqlkSxuZaCIC2sdPGxfgwaB Y8FGQtFHrNwMyWE6yc1xXWj3gDVlPDSfTsNJgEIGWssI+RATwGVzlGCAkDeQZcx9HLjJAveV79FU5 XjqKXN/bsLjs2jZma6RWlKpBi; 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-L0 for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:06 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:03 -0600 Subject: [PATCH 03/20] Remove alloc_type_copy MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-3-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-L0 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: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.2 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_copy, replacing all uses with the new type allocator. --- gdb/ada-lang.c | 25 +++++++++++++------------ gdb/gdbtypes.c | 30 ++++++++++-------------------- gdb/gdbtypes.h | 6 +----- gdb/rust-lang.c | 2 +- gdb/stabsread.c | 2 +- 5 files changed, 26 insertions(+), 39 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7b07c4f9473..624584e8ee5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2140,8 +2140,9 @@ ada_type_of_array (struct value *arr, int bounds) return NULL; while (arity > 0) { - struct type *range_type = alloc_type_copy (arr->type ()); - struct type *array_type = alloc_type_copy (arr->type ()); + type_allocator alloc (arr->type ()); + struct type *range_type = alloc.new_type (); + struct type *array_type = alloc.new_type (); struct value *low = desc_one_bound (descriptor, arity, 0); struct value *high = desc_one_bound (descriptor, arity, 1); @@ -2382,7 +2383,7 @@ constrained_packed_array_type (struct type *type, long *elt_bits) else index_type = type->index_type (); - new_type = alloc_type_copy (type); + new_type = type_allocator (type).new_type (); new_elt_type = constrained_packed_array_type (ada_check_typedef (type->target_type ()), elt_bits); @@ -7816,7 +7817,7 @@ variant_field_index (struct type *type) static struct type * empty_record (struct type *templ) { - struct type *type = alloc_type_copy (templ); + struct type *type = type_allocator (templ).new_type (); type->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (type); @@ -7872,7 +7873,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, nfields++; } - rtype = alloc_type_copy (type); + rtype = type_allocator (type).new_type (); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); @@ -8123,7 +8124,7 @@ template_to_static_fixed_type (struct type *type0) /* Clone TYPE0 only the first time we get a new field type. */ if (type == type0) { - type = alloc_type_copy (type0); + type = type_allocator (type0).new_type (); type0->set_target_type (type); type->set_code (type0->code ()); INIT_NONE_SPECIFIC (type); @@ -8177,7 +8178,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, else dval = dval0; - rtype = alloc_type_copy (type); + rtype = type_allocator (type).new_type (); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); @@ -8470,7 +8471,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, if (elt_type0 == elt_type && !constrained_packed_array_p) result = type0; else - result = create_array_type (alloc_type_copy (type0), + result = create_array_type (type_allocator (type0).new_type (), elt_type, type0->index_type ()); } else @@ -8502,7 +8503,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, struct type *range_type = to_fixed_range_type (index_type_desc->field (i).type (), dval); - result = create_array_type (alloc_type_copy (elt_type0), + result = create_array_type (type_allocator (elt_type0).new_type (), result, range_type); elt_type0 = elt_type0->target_type (); } @@ -11514,8 +11515,8 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) if (L < INT_MIN || U > INT_MAX) return raw_type; else - return create_static_range_type (alloc_type_copy (raw_type), raw_type, - L, U); + return create_static_range_type (type_allocator (raw_type).new_type (), + raw_type, L, U); } else { @@ -11566,7 +11567,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) } } - type = create_static_range_type (alloc_type_copy (raw_type), + type = create_static_range_type (type_allocator (raw_type).new_type (), base_type, L, U); /* create_static_range_type alters the resulting type's length to match the size of the base_type, which is not what we want. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1e880edf681..6ad6aadb468 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -258,16 +258,6 @@ alloc_type (struct objfile *objfile) 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. */ - -struct type * -alloc_type_copy (const struct type *type) -{ - return type_allocator (type).new_type (); -} - /* See gdbtypes.h. */ type * @@ -421,7 +411,7 @@ make_pointer_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -499,7 +489,7 @@ make_reference_type (struct type *type, struct type **typeptr, if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -574,7 +564,7 @@ make_function_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -906,7 +896,7 @@ lookup_memberptr_type (struct type *type, struct type *domain) { struct type *mtype; - mtype = alloc_type_copy (type); + mtype = type_allocator (type).new_type (); smash_to_memberptr_type (mtype, domain, type); return mtype; } @@ -918,7 +908,7 @@ lookup_methodptr_type (struct type *to_type) { struct type *mtype; - mtype = alloc_type_copy (to_type); + mtype = type_allocator (to_type).new_type (); smash_to_methodptr_type (mtype, to_type); return mtype; } @@ -981,7 +971,7 @@ create_range_type (struct type *result_type, struct type *index_type, gdb_assert (index_type->length () > 0); if (result_type == NULL) - result_type = alloc_type_copy (index_type); + result_type = type_allocator (index_type).new_type (); result_type->set_code (TYPE_CODE_RANGE); result_type->set_target_type (index_type); if (index_type->is_stub ()) @@ -1425,7 +1415,7 @@ create_array_type_with_stride (struct type *result_type, } if (result_type == NULL) - result_type = alloc_type_copy (range_type); + result_type = type_allocator (range_type).new_type (); result_type->set_code (TYPE_CODE_ARRAY); result_type->set_target_type (element_type); @@ -1527,7 +1517,7 @@ struct type * create_set_type (struct type *result_type, struct type *domain_type) { if (result_type == NULL) - result_type = alloc_type_copy (domain_type); + result_type = type_allocator (domain_type).new_type (); result_type->set_code (TYPE_CODE_SET); result_type->set_num_fields (1); @@ -3597,7 +3587,7 @@ init_complex_type (const char *name, struct type *target_type) name = new_name; } - t = alloc_type_copy (target_type); + t = type_allocator (target_type).new_type (); set_type_code (t, TYPE_CODE_COMPLEX); t->set_length (2 * target_type->length ()); t->set_name (name); @@ -5804,7 +5794,7 @@ copy_type_recursive (struct type *type, htab_t copied_types) struct type * copy_type (const struct type *type) { - struct type *new_type = alloc_type_copy (type); + struct type *new_type = type_allocator (type).new_type (); new_type->set_instance_flags (type->instance_flags ()); new_type->set_length (type->length ()); memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type), diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 861d0021d30..03f94709006 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2186,12 +2186,8 @@ 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_copy to allocate a type with the same owner as a - pre-existing template type, no matter whether objfile or - gdbarch. */ +/* Use alloc_type to allocate a type owned by an objfile. */ extern struct type *alloc_type (struct objfile *); -extern struct type *alloc_type_copy (const struct type *); /* * This returns the target type (or NULL) of TYPE, also skipping past typedefs. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 6fc73b262f5..82004da53d4 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -939,7 +939,7 @@ rust_composite_type (struct type *original, const char *field1, struct type *type1, const char *field2, struct type *type2) { - struct type *result = alloc_type_copy (original); + struct type *result = type_allocator (original).new_type (); int i, nfields, bitpos; nfields = 0; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 73f05c44b23..cfe245325f5 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1475,7 +1475,7 @@ allocate_stub_method (struct type *type) { struct type *mtype; - mtype = alloc_type_copy (type); + mtype = type_allocator (type).new_type (); mtype->set_code (TYPE_CODE_METHOD); mtype->set_length (1); mtype->set_is_stub (true); From patchwork Mon Mar 13 22:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66330 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 C49AC3850877 for ; Mon, 13 Mar 2023 22:08:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 22FE63858C62 for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22FE63858C62 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 progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 0CC7D100423E0 for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKspFhZDUEmJbqKsp3I7W; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=TLSA93pa c=1 sm=1 tr=0 ts=640f9ec7 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=SR8IpdxFiSXF5A8S8bQA: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=xYwYD6ydK4sjnRqqLpqDyObC2SP+8L6ZTqjeVPkHmYM=; b=FUW7mPCs1hXUIsMqbNcLyIfauA dTsRKXkWATWzgxYhhi6DQIf3ho6Zbkpv2Kxh/KVx7r2CHRDgbZcdWc3td2q58CeQHE8dPeRuS5EwA M9ZniGtiyRUif8eY5pk4ZAn+i; 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-PS for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:06 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:04 -0600 Subject: [PATCH 04/20] Remove alloc_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-4-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-PS 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: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.1 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, replacing all uses with the new type allocator. --- gdb/coffread.c | 2 +- gdb/ctfread.c | 8 ++++---- gdb/dwarf2/read.c | 15 ++++++++------- gdb/gdbtypes.c | 29 +---------------------------- gdb/gdbtypes.h | 3 --- gdb/mdebugread.c | 2 +- gdb/stabsread.c | 4 ++-- 7 files changed, 17 insertions(+), 46 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 4da3799243b..6b2ba96c997 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -354,7 +354,7 @@ coff_alloc_type (int index) We will fill it in later if we find out how. */ if (type == NULL) { - type = alloc_type (coffread_objfile); + type = type_allocator (coffread_objfile).new_type (); *type_addr = type; } return type; diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 69906c9cb2e..94597af58a9 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -629,7 +629,7 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid) struct type *type; uint32_t kind; - type = alloc_type (of); + type = type_allocator (of).new_type (); const char *name = ctf_type_name_raw (fp, tid); if (name != nullptr && strlen (name) != 0) @@ -688,7 +688,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) ctf_funcinfo_t cfi; uint32_t argc; - type = alloc_type (of); + type = type_allocator (of).new_type (); type->set_code (TYPE_CODE_FUNC); if (ctf_func_type_info (fp, tid, &cfi) < 0) @@ -740,7 +740,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid) ctf_dict_t *fp = ccp->fp; struct type *type; - type = alloc_type (of); + type = type_allocator (of).new_type (); const char *name = ctf_type_name_raw (fp, tid); if (name != nullptr && strlen (name) != 0) @@ -976,7 +976,7 @@ read_forward_type (struct ctf_context *ccp, ctf_id_t tid) struct type *type; uint32_t kind; - type = alloc_type (of); + type = type_allocator (of).new_type (); const char *name = ctf_type_name_raw (fp, tid); if (name != nullptr && strlen (name) != 0) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7ff090225e0..450bf73a886 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -12147,7 +12147,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, fnp->physname = physname ? physname : ""; } - fnp->type = alloc_type (objfile); + fnp->type = type_allocator (objfile).new_type (); this_type = read_type_die (die, cu); if (this_type && this_type->code () == TYPE_CODE_FUNC) { @@ -12369,7 +12369,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) return; self_type = pfn_type->field (0).type ()->target_type (); - new_type = alloc_type (objfile); + new_type = type_allocator (objfile).new_type (); smash_to_method_type (new_type, self_type, pfn_type->target_type (), pfn_type->fields (), pfn_type->num_fields (), pfn_type->has_varargs ()); @@ -12608,7 +12608,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } - type = alloc_type (objfile); + type = type_allocator (objfile).new_type (); INIT_CPLUS_SPECIFIC (type); name = dwarf2_name (die, cu); @@ -13215,7 +13215,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) return set_die_type (die, type, cu); } - type = alloc_type (objfile); + type = type_allocator (objfile).new_type (); type->set_code (TYPE_CODE_ENUM); name = dwarf2_full_name (NULL, die, cu); @@ -13545,7 +13545,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, range_fields[i + 1].set_name (objfile->intern (name)); } - struct type *bounds = alloc_type (objfile); + struct type *bounds = type_allocator (objfile).new_type (); bounds->set_code (TYPE_CODE_STRUCT); bounds->set_num_fields (range_fields.size ()); @@ -13573,7 +13573,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, iter = iter->target_type (); } - struct type *result = alloc_type (objfile); + struct type *result = type_allocator (objfile).new_type (); result->set_code (TYPE_CODE_STRUCT); result->set_num_fields (2); @@ -14255,7 +14255,8 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu) type = lookup_methodptr_type (to_type); else if (check_typedef (to_type)->code () == TYPE_CODE_FUNC) { - struct type *new_type = alloc_type (cu->per_objfile->objfile); + struct type *new_type + = type_allocator (cu->per_objfile->objfile).new_type (); smash_to_method_type (new_type, domain, to_type->target_type (), to_type->fields (), to_type->num_fields (), diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6ad6aadb468..3d1d9239758 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -231,33 +231,6 @@ type_allocator::new_type () return type; } -/* Allocate a new OBJFILE-associated type structure and fill it - with some defaults. Space for the type structure is allocated - on the objfile's objfile_obstack. */ - -struct type * -alloc_type (struct objfile *objfile) -{ - struct type *type; - - gdb_assert (objfile != NULL); - - /* Alloc the structure and start off with all fields zeroed. */ - type = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct type); - TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (&objfile->objfile_obstack, - struct main_type); - OBJSTAT (objfile, n_types++); - - type->set_owner (objfile); - - /* Initialize the fields that might not be zero. */ - - type->set_code (TYPE_CODE_UNDEF); - TYPE_CHAIN (type) = type; /* Chain back to itself. */ - - return type; -} - /* See gdbtypes.h. */ type * @@ -3437,7 +3410,7 @@ init_type (struct objfile *objfile, enum type_code code, int bit, { struct type *type; - type = alloc_type (objfile); + type = type_allocator (objfile).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 03f94709006..c052b74d1f3 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2186,9 +2186,6 @@ 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. */ -extern struct type *alloc_type (struct objfile *); - /* * This returns the target type (or NULL) of TYPE, also skipping past typedefs. */ diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 13dc7899d44..e4814b2b81e 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4725,7 +4725,7 @@ new_type (char *name) { struct type *t; - t = alloc_type (mdebugread_objfile); + t = type_allocator (mdebugread_objfile).new_type (); t->set_name (name); INIT_CPLUS_SPECIFIC (t); return t; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index cfe245325f5..8eac7ab6261 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -346,7 +346,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile) if (typenums[0] == -1) { - return (alloc_type (objfile)); + return type_allocator (objfile).new_type (); } type_addr = dbx_lookup_type (typenums, objfile); @@ -356,7 +356,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile) We will fill it in later if we find out how. */ if (*type_addr == 0) { - *type_addr = alloc_type (objfile); + *type_addr = type_allocator (objfile).new_type (); } return (*type_addr); From patchwork Mon Mar 13 22:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66329 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 5D44A385B535 for ; Mon, 13 Mar 2023 22:08:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id F2EC03858C60 for ; Mon, 13 Mar 2023 22:08:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2EC03858C60 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 progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 1CEEF1003BE06 for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKtpfLGPHIU4bqKtpFyAC; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NfUja0P4 c=1 sm=1 tr=0 ts=640f9ec7 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=xKO94FZI0hc4bIEnGXcA: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=fQyODqGSZKydQH01VRQyuvIsVSIS9CGmn+O9g7Ag8ic=; b=qgcUgYXNRXlfeZPyP0PrmsMYJi QMQy4TiHxJKNpnqp5u2W+i6oT3OV4tzWv6GLj74/LXtYm8bSLNBFeotjyVse/pcPI/SKt3LG342xo TfxSjVGWAsf0UTEvCD4wEoYxG; 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-UH for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:06 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:05 -0600 Subject: [PATCH 05/20] Reuse existing builtin types MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-5-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-UH 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: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.1 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 changes a few spots to reuse the existing builting "void" type, rather than construct a new one. --- gdb/d-lang.c | 3 +-- gdb/f-lang.c | 3 +-- gdb/go-lang.c | 3 +-- gdb/jit.c | 5 +---- gdb/opencl-lang.c | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 8286c5be646..457e367fd51 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -201,8 +201,7 @@ build_d_types (struct gdbarch *gdbarch) struct builtin_d_type *builtin_d_type = new struct builtin_d_type; /* Basic types. */ - builtin_d_type->builtin_void - = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_d_type->builtin_bool = arch_boolean_type (gdbarch, 8, 1, "bool"); builtin_d_type->builtin_byte diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 0d7863e4fd1..e1eb47577d6 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1725,8 +1725,7 @@ build_fortran_types (struct gdbarch *gdbarch) { struct builtin_f_type *builtin_f_type = new struct builtin_f_type; - builtin_f_type->builtin_void - = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + builtin_f_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_f_type->builtin_character = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character"); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index bbf80af1f5c..456b74d80df 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -483,8 +483,7 @@ build_go_types (struct gdbarch *gdbarch) { struct builtin_go_type *builtin_go_type = new struct builtin_go_type; - builtin_go_type->builtin_void - = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_go_type->builtin_char = arch_character_type (gdbarch, 8, 1, "char"); builtin_go_type->builtin_bool diff --git a/gdb/jit.c b/gdb/jit.c index a93813b3f7f..b5386df2b46 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -571,10 +571,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) { struct block *new_block = new (&objfile->objfile_obstack) block; struct symbol *block_name = new (&objfile->objfile_obstack) symbol; - struct type *block_type = arch_type (objfile->arch (), - TYPE_CODE_VOID, - TARGET_CHAR_BIT, - "void"); + struct type *block_type = builtin_type (objfile->arch ())->builtin_void; new_block->set_multidict (mdict_create_linear (&objfile->objfile_obstack, NULL)); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index ae1a6d4446d..9b5304f588f 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -941,7 +941,7 @@ class opencl_language : public language_defn add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t")); add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t")); add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t")); - add (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void")); + add (builtin_type (gdbarch)->builtin_void); /* Type of elements of strings. */ lai->set_string_char_type (char_type); From patchwork Mon Mar 13 22:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66332 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 B92E7385040B for ; Mon, 13 Mar 2023 22:08:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id EF9EA3858C5F for ; Mon, 13 Mar 2023 22:08:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF9EA3858C5F 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 progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 53B801003BDFB for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKtpFhZZUEmJbqKtp3I7s; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=TLSA93pa c=1 sm=1 tr=0 ts=640f9ec7 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=LYk4rCbB9lQvAmMRl-gA: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=I0KNQoFgCgVU7zWPZ6x0RSxX5X1RIouv7fCCNmvyJiQ=; b=pFzCjujd/Yj4+ukcUYyAlKVnGn 3isW1k/lWUV9c92lo6sWsHiX7HnhXhbvl4OR7DpcATWUeS0sXr3I3NXERlDXj1DReU019LLlhyn8F GSTmWM62NGG3Y6c/jNxigrncZ; 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 1pbqKt-000u2m-2h for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:06 -0600 Subject: [PATCH 06/20] Remove arch_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-6-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: 1pbqKt-000u2m-2h 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: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.2 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 arch_type, replacing all uses with the new type allocator. --- gdb/ada-lang.c | 5 +++-- gdb/amdgpu-tdep.c | 5 +++-- gdb/avr-tdep.c | 4 ++-- gdb/f-lang.c | 8 +++++--- gdb/fbsd-tdep.c | 12 +++++++----- gdb/ft32-tdep.c | 3 ++- gdb/gdbtypes.c | 48 +++++++++++++++-------------------------------- gdb/gdbtypes.h | 2 -- gdb/gnu-v3-abi.c | 7 +++++-- gdb/linux-tdep.c | 18 +++++++++++------- gdb/m32c-tdep.c | 3 ++- gdb/netbsd-tdep.c | 22 +++++++++++++--------- gdb/rl78-tdep.c | 4 ++-- gdb/target-descriptions.c | 5 +++-- gdb/windows-tdep.c | 28 ++++++++++++++------------- gdb/z80-tdep.c | 5 +++-- 16 files changed, 91 insertions(+), 88 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 624584e8ee5..2e99dfa0c6f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13556,6 +13556,7 @@ class ada_language : public language_defn lai->add_primitive_type (t); }; + type_allocator alloc (gdbarch); add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "integer")); add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), @@ -13584,8 +13585,8 @@ class ada_language : public language_defn add (builtin->builtin_void); struct type *system_addr_ptr - = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, - "void")); + = lookup_pointer_type (alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, + "void")); system_addr_ptr->set_name ("system__address"); add (system_addr_ptr); diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index d681d9d6a50..1077fab5c65 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -749,8 +749,9 @@ amd_dbgapi_register_type_to_gdb_type (const amd_dbgapi_register_type &type, const auto &enum_type = static_cast (type); struct type *gdb_type - = arch_type (gdbarch, TYPE_CODE_ENUM, enum_type.bit_size (), - enum_type.name ().c_str ()); + = (type_allocator (gdbarch) + .new_type (TYPE_CODE_ENUM, enum_type.bit_size (), + enum_type.name ().c_str ())); gdb_type->set_num_fields (enum_type.size ()); gdb_type->set_fields diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index ba98fbf6f82..f9f498bfed2 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1473,8 +1473,8 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Create a type for PC. We can't use builtin types here, as they may not be defined. */ - tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, - "void"); + type_allocator alloc (gdbarch); + tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->func_void_type = make_function_type (tdep->void_type, NULL); tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, tdep->func_void_type); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index e1eb47577d6..3bf33d020c6 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1727,8 +1727,10 @@ build_fortran_types (struct gdbarch *gdbarch) builtin_f_type->builtin_void = builtin_type (gdbarch)->builtin_void; + type_allocator alloc (gdbarch); + builtin_f_type->builtin_character - = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character"); + = alloc.new_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character"); builtin_f_type->builtin_logical_s1 = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1"); @@ -1774,7 +1776,7 @@ build_fortran_types (struct gdbarch *gdbarch) "real*16", gdbarch_long_double_format (gdbarch)); else builtin_f_type->builtin_real_s16 - = arch_type (gdbarch, TYPE_CODE_ERROR, 128, "real*16"); + = alloc.new_type (TYPE_CODE_ERROR, 128, "real*16"); builtin_f_type->builtin_complex = init_complex_type ("complex*4", builtin_f_type->builtin_real); @@ -1784,7 +1786,7 @@ build_fortran_types (struct gdbarch *gdbarch) if (builtin_f_type->builtin_real_s16->code () == TYPE_CODE_ERROR) builtin_f_type->builtin_complex_s16 - = arch_type (gdbarch, TYPE_CODE_ERROR, 256, "complex*16"); + = alloc.new_type (TYPE_CODE_ERROR, 256, "complex*16"); else builtin_f_type->builtin_complex_s16 = init_complex_type ("complex*16", builtin_f_type->builtin_real_s16); diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 3a7cb9b14ea..236a9f4d615 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1609,15 +1609,17 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); /* __pid_t */ - pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - int32_type->length () * TARGET_CHAR_BIT, "__pid_t"); + type_allocator alloc (gdbarch); + pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int32_type->length () * TARGET_CHAR_BIT, + "__pid_t"); pid_type->set_target_type (int32_type); pid_type->set_target_is_stub (true); /* __uid_t */ - uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - uint32_type->length () * TARGET_CHAR_BIT, - "__uid_t"); + uid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + uint32_type->length () * TARGET_CHAR_BIT, + "__uid_t"); uid_type->set_target_type (uint32_type); pid_type->set_target_is_stub (true); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 7a69da61fdb..7182185313f 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -573,7 +573,8 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Create a type for PC. We can't use builtin types here, as they may not be defined. */ - void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + type_allocator alloc (gdbarch); + void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); func_void_type = make_function_type (void_type, NULL); tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, func_void_type); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 3d1d9239758..f52899e0a5e 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5786,26 +5786,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a type structure associated with GDBARCH and set its - CODE, LENGTH, and NAME fields. */ - -struct type * -arch_type (struct gdbarch *gdbarch, - enum type_code code, int bit, const char *name) -{ - struct type *type; - - 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); - - if (name) - type->set_name (gdbarch_obstack_strdup (gdbarch, name)); - - return type; -} - /* Allocate a TYPE_CODE_INT type structure associated with GDBARCH. BIT is the type size in bits. If UNSIGNED_P is non-zero, set the type's TYPE_UNSIGNED flag. NAME is the type name. */ @@ -5816,7 +5796,7 @@ arch_integer_type (struct gdbarch *gdbarch, { struct type *t; - t = arch_type (gdbarch, TYPE_CODE_INT, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_INT, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5833,7 +5813,7 @@ arch_character_type (struct gdbarch *gdbarch, { struct type *t; - t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_CHAR, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5850,7 +5830,7 @@ arch_boolean_type (struct gdbarch *gdbarch, { struct type *t; - t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_BOOL, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5871,7 +5851,7 @@ arch_float_type (struct gdbarch *gdbarch, struct type *t; bit = verify_floatformat (bit, fmt); - t = arch_type (gdbarch, TYPE_CODE_FLT, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name); TYPE_FLOATFORMAT (t) = fmt; return t; @@ -5885,7 +5865,7 @@ arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name) { struct type *t; - t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name); return t; } @@ -5900,7 +5880,7 @@ arch_pointer_type (struct gdbarch *gdbarch, { struct type *t; - t = arch_type (gdbarch, TYPE_CODE_PTR, bit, name); + t = type_allocator (gdbarch).new_type (TYPE_CODE_PTR, bit, name); t->set_target_type (target_type); t->set_is_unsigned (true); return t; @@ -5914,7 +5894,7 @@ arch_flags_type (struct gdbarch *gdbarch, const char *name, int bit) { struct type *type; - type = arch_type (gdbarch, TYPE_CODE_FLAGS, bit, name); + type = type_allocator (gdbarch).new_type (TYPE_CODE_FLAGS, bit, name); type->set_is_unsigned (true); type->set_num_fields (0); /* Pre-allocate enough space assuming every field is one bit. */ @@ -5970,7 +5950,7 @@ arch_composite_type (struct gdbarch *gdbarch, const char *name, struct type *t; gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION); - t = arch_type (gdbarch, code, 0, NULL); + t = type_allocator (gdbarch).new_type (code, 0, NULL); t->set_name (name); INIT_CPLUS_SPECIFIC (t); return t; @@ -6134,9 +6114,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch) { struct builtin_type *builtin_type = new struct builtin_type; + type_allocator alloc (gdbarch); + /* Basic types. */ builtin_type->builtin_void - = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); builtin_type->builtin_char = arch_integer_type (gdbarch, TARGET_CHAR_BIT, !gdbarch_char_signed (gdbarch), "char"); @@ -6191,7 +6173,7 @@ create_gdbtypes_data (struct gdbarch *gdbarch) builtin_type->builtin_double_complex = init_complex_type ("double complex", builtin_type->builtin_double); builtin_type->builtin_string - = arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); + = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); builtin_type->builtin_bool = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool"); @@ -6265,12 +6247,12 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* This type represents a GDB internal function. */ builtin_type->internal_fn - = arch_type (gdbarch, TYPE_CODE_INTERNAL_FUNCTION, 0, - ""); + = alloc.new_type (TYPE_CODE_INTERNAL_FUNCTION, 0, + ""); /* This type represents an xmethod. */ builtin_type->xmethod - = arch_type (gdbarch, TYPE_CODE_XMETHOD, 0, ""); + = alloc.new_type (TYPE_CODE_XMETHOD, 0, ""); return builtin_type; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index c052b74d1f3..657c04be56e 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2316,8 +2316,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_type (struct gdbarch *, enum type_code, int, - const char *); extern struct type *arch_integer_type (struct gdbarch *, int, int, const char *); extern struct type *arch_character_type (struct gdbarch *, int, int, diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 6d1a36623f8..a3e2d73f10a 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -125,6 +125,8 @@ get_gdb_vtable_type (struct gdbarch *arch) struct type *ptr_to_void_fn_type = builtin_type (arch)->builtin_func_ptr; + type_allocator alloc (arch); + /* ARCH can't give us the true ptrdiff_t type, so we guess. */ struct type *ptrdiff_type = arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t"); @@ -170,7 +172,7 @@ get_gdb_vtable_type (struct gdbarch *arch) /* We assumed in the allocation above that there were four fields. */ gdb_assert (field == (field_list + 4)); - t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); + t = alloc.new_type (TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); t->set_num_fields (field - field_list); t->set_fields (field_list); t->set_name ("gdb_gnu_v3_abi_vtable"); @@ -1053,7 +1055,8 @@ build_std_type_info_type (struct gdbarch *arch) gdb_assert (field == (field_list + 2)); - t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); + t = type_allocator (arch).new_type (TYPE_CODE_STRUCT, + offset * TARGET_CHAR_BIT, nullptr); t->set_num_fields (field - field_list); t->set_fields (field_list); t->set_name ("gdb_gnu_v3_type_info"); diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index e6ce13a1c67..9192fc99be3 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -275,6 +275,8 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, if (linux_gdbarch_data->siginfo_type != NULL) return linux_gdbarch_data->siginfo_type; + type_allocator alloc (gdbarch); + int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "int"); uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), @@ -292,21 +294,23 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); /* __pid_t */ - pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - int_type->length () * TARGET_CHAR_BIT, "__pid_t"); + pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int_type->length () * TARGET_CHAR_BIT, + "__pid_t"); pid_type->set_target_type (int_type); pid_type->set_target_is_stub (true); /* __uid_t */ - uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - uint_type->length () * TARGET_CHAR_BIT, "__uid_t"); + uid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + uint_type->length () * TARGET_CHAR_BIT, + "__uid_t"); uid_type->set_target_type (uint_type); uid_type->set_target_is_stub (true); /* __clock_t */ - clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - long_type->length () * TARGET_CHAR_BIT, - "__clock_t"); + clock_type = alloc.new_type (TYPE_CODE_TYPEDEF, + long_type->length () * TARGET_CHAR_BIT, + "__clock_t"); clock_type->set_target_type (long_type); clock_type->set_target_is_stub (true); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 2899c9aef90..e500ba88a42 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -185,7 +185,8 @@ make_types (struct gdbarch *arch) /* The builtin_type_mumble variables are sometimes uninitialized when this is called, so we avoid using them. */ - tdep->voyd = arch_type (arch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + type_allocator alloc (arch); + tdep->voyd = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->ptr_voyd = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd); tdep->func_voyd = lookup_function_type (tdep->voyd); diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c index 05f8d27f32d..ed60200f958 100644 --- a/gdb/netbsd-tdep.c +++ b/gdb/netbsd-tdep.c @@ -414,24 +414,28 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch) size_t char_bits = gdbarch_addressable_memory_unit_size (gdbarch) * 8; /* pid_t */ - type *pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - int32_type->length () * char_bits, "pid_t"); + type_allocator alloc (gdbarch); + type *pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int32_type->length () * char_bits, + "pid_t"); pid_type->set_target_type (int32_type); /* uid_t */ - type *uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - uint32_type->length () * char_bits, "uid_t"); + type *uid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + uint32_type->length () * char_bits, + "uid_t"); uid_type->set_target_type (uint32_type); /* clock_t */ - type *clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - int_type->length () * char_bits, "clock_t"); + type *clock_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int_type->length () * char_bits, + "clock_t"); clock_type->set_target_type (int_type); /* lwpid_t */ - type *lwpid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - int32_type->length () * char_bits, - "lwpid_t"); + type *lwpid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int32_type->length () * char_bits, + "lwpid_t"); lwpid_type->set_target_type (int32_type); /* union sigval */ diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 1af78d9c652..1177215490f 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1409,8 +1409,8 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->elf_flags = elf_flags; /* Initialize types. */ - tdep->rl78_void = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, - "void"); + type_allocator alloc (gdbarch); + tdep->rl78_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->rl78_uint8 = arch_integer_type (gdbarch, 8, 1, "uint8_t"); tdep->rl78_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t"); tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t"); diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index c62d4368d6b..7af3875b48b 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -284,8 +284,9 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) void make_gdb_type_enum (const tdesc_type_with_fields *e) { - m_type = arch_type (m_gdbarch, TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT, - e->name.c_str ()); + m_type = (type_allocator (m_gdbarch) + .new_type (TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT, + e->name.c_str ())); m_type->set_is_unsigned (true); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 97199527c8b..5a58aa37953 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -214,6 +214,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch) if (windows_gdbarch_data->tib_ptr_type != nullptr) return windows_gdbarch_data->tib_ptr_type; + type_allocator alloc (gdbarch); + dword_ptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "DWORD_PTR"); dword32_type = arch_integer_type (gdbarch, 32, @@ -243,9 +245,9 @@ windows_get_tlb_type (struct gdbarch *gdbarch) seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); seh_type->set_name (xstrdup ("seh")); - seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - void_ptr_type->length () * TARGET_CHAR_BIT, - NULL); + seh_ptr_type = alloc.new_type (TYPE_CODE_PTR, + void_ptr_type->length () * TARGET_CHAR_BIT, + NULL); seh_ptr_type->set_target_type (seh_type); append_composite_type_field (seh_type, "next_seh", seh_ptr_type); @@ -264,9 +266,9 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (peb_ldr_type, "in_init_order", list_type); append_composite_type_field (peb_ldr_type, "entry_in_progress", void_ptr_type); - peb_ldr_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - void_ptr_type->length () * TARGET_CHAR_BIT, - NULL); + peb_ldr_ptr_type = alloc.new_type (TYPE_CODE_PTR, + void_ptr_type->length () * TARGET_CHAR_BIT, + NULL); peb_ldr_ptr_type->set_target_type (peb_ldr_type); /* struct UNICODE_STRING */ @@ -334,9 +336,9 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (peb_type, "sub_system_data", void_ptr_type); append_composite_type_field (peb_type, "process_heap", void_ptr_type); append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type); - peb_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - void_ptr_type->length () * TARGET_CHAR_BIT, - NULL); + peb_ptr_type = alloc.new_type (TYPE_CODE_PTR, + void_ptr_type->length () * TARGET_CHAR_BIT, + NULL); peb_ptr_type->set_target_type (peb_type); @@ -378,9 +380,9 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* uint32_t last_error_number; %fs:0x0034 */ append_composite_type_field (tib_type, "last_error_number", dword_ptr_type); - tib_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - void_ptr_type->length () * TARGET_CHAR_BIT, - NULL); + tib_ptr_type = alloc.new_type (TYPE_CODE_PTR, + void_ptr_type->length () * TARGET_CHAR_BIT, + NULL); tib_ptr_type->set_target_type (tib_type); windows_gdbarch_data->tib_ptr_type = tib_ptr_type; @@ -742,7 +744,7 @@ create_enum (struct gdbarch *gdbarch, int bit, const char *name, struct type *type; int i; - type = arch_type (gdbarch, TYPE_CODE_ENUM, bit, name); + type = type_allocator (gdbarch).new_type (TYPE_CODE_ENUM, bit, name); type->set_num_fields (count); type->set_fields ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * count)); diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index fb4077088eb..78b3827b54d 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -1139,8 +1139,9 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Create a type for PC. We can't use builtin types here, as they may not be defined. */ - tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, - "void"); + type_allocator alloc (gdbarch); + tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, + "void"); tdep->func_void_type = make_function_type (tdep->void_type, NULL); tdep->pc_type = arch_pointer_type (gdbarch, tdep->addr_length * TARGET_CHAR_BIT, From patchwork Mon Mar 13 22:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66331 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 945353850223 for ; Mon, 13 Mar 2023 22:08:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 36EE63858C66 for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 36EE63858C66 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 7051710047FA0 for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKtpXv50NX2abqKtpEw6A; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=640f9ec7 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=rto37pdvy23tO6xjDnYA: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=qdXbBxO1pileCfY64kzKkBrJibyBEowOIGWYtwUYti4=; b=LzWNH7nkCVw1TIsw4+EIbuo/vs 8kaY28pFZ0IMmHRWB8SQmIsz6Dlbv6mcLPcmQXKE+AvITt284bRcKW3hq/pAto8lBlVK9yfGuBAZI kRjGF0PmuTIMy1aVNoJwg1FCY; 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 1pbqKt-000u2m-7X for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:07 -0600 Subject: [PATCH 07/20] Remove init_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-7-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: 1pbqKt-000u2m-7X 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: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.1 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 init_type, replacing all uses with the new type allocator. --- gdb/ctfread.c | 8 ++++--- gdb/dwarf2/read.c | 31 +++++++++++++----------- gdb/gdbtypes.c | 70 ++++++++++++++++--------------------------------------- gdb/gdbtypes.h | 2 -- gdb/mdebugread.c | 24 ++++++++++++------- gdb/stabsread.c | 17 +++++++++----- 6 files changed, 69 insertions(+), 83 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 94597af58a9..82c2cdb3abb 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -372,11 +372,12 @@ ctf_init_float_type (struct objfile *objfile, const struct floatformat **format; struct type *type; + type_allocator alloc (objfile); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format != nullptr) type = init_float_type (objfile, bits, name, format); else - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); + type = alloc.new_type (TYPE_CODE_ERROR, bits, name); return type; } @@ -554,6 +555,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) ctf_errmsg (ctf_errno (fp))); } + type_allocator alloc (of); kind = ctf_type_kind (fp, tid); if (kind == CTF_K_INTEGER) { @@ -596,7 +598,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) else { complaint (_("read_base_type: unsupported base kind (%d)"), kind); - type = init_type (of, TYPE_CODE_ERROR, cet.cte_bits, name); + type = alloc.new_type (TYPE_CODE_ERROR, cet.cte_bits, name); } if (name != nullptr && strcmp (name, "char") == 0) @@ -928,7 +930,7 @@ read_typedef_type (struct ctf_context *ccp, ctf_id_t tid, struct type *this_type, *target_type; char *aname = obstack_strdup (&objfile->objfile_obstack, name); - this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, aname); + this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, aname); set_tid_type (objfile, tid, this_type); target_type = fetch_tid_type (ccp, btid); if (target_type != this_type) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 450bf73a886..e2571667aa2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5860,8 +5860,9 @@ fixup_go_packaging (struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_objfile->objfile; const char *saved_package_name = objfile->intern (package_name.get ()); - struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0, - saved_package_name); + struct type *type + = type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0, + saved_package_name); struct symbol *sym; sym = new (&objfile->objfile_obstack) symbol; @@ -6048,8 +6049,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) const char *dataless_name = rust_fully_qualify (&objfile->objfile_obstack, type->name (), name); - struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0, - dataless_name); + struct type *dataless_type + = type_allocator (objfile).new_type (TYPE_CODE_VOID, 0, + dataless_name); type->field (2).set_type (dataless_type); /* NAME points into the original discriminant name, which already has the correct lifetime. */ @@ -14039,7 +14041,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu) previous_prefix, name, 0, cu); /* Create the type. */ - type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name); + type = type_allocator (objfile).new_type (TYPE_CODE_NAMESPACE, 0, name); return set_die_type (die, type, cu); } @@ -14101,7 +14103,7 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu) struct type *type; module_name = dwarf2_name (die, cu); - type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name); + type = type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0, module_name); return set_die_type (die, type, cu); } @@ -14700,7 +14702,7 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu) struct type *this_type, *target_type; name = dwarf2_full_name (NULL, die, cu); - this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name); + this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, name); this_type->set_target_is_stub (true); set_die_type (die, this_type, cu); target_type = die_type (die, cu); @@ -15015,11 +15017,12 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name, const struct floatformat **format; struct type *type; + type_allocator alloc (objfile); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format) type = init_float_type (objfile, bits, name, format, byte_order); else - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); + type = alloc.new_type (TYPE_CODE_ERROR, bits, name); return type; } @@ -15223,11 +15226,12 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) } } + type_allocator alloc (objfile); switch (encoding) { case DW_ATE_address: /* Turn DW_ATE_address into a void * pointer. */ - type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); + type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); type = init_pointer_type (objfile, bits, name, type); break; case DW_ATE_boolean: @@ -15245,7 +15249,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) name = obconcat (obstack, "_Complex ", type->name (), nullptr); } - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); + type = alloc.new_type (TYPE_CODE_ERROR, bits, name); } else type = init_complex_type (name, type); @@ -15304,7 +15308,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) default: complaint (_("unsupported DW_AT_encoding: '%s'"), dwarf_type_encoding_name (encoding)); - type = init_type (objfile, TYPE_CODE_ERROR, bits, name); + type = alloc.new_type (TYPE_CODE_ERROR, bits, name); break; } @@ -15750,7 +15754,8 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu) { struct type *type; - type = init_type (cu->per_objfile->objfile, TYPE_CODE_VOID, 0, NULL); + type = (type_allocator (cu->per_objfile->objfile) + .new_type (TYPE_CODE_VOID, 0, nullptr)); type->set_name (dwarf2_name (die, cu)); /* In Ada, an unspecified type is typically used when the description @@ -19466,7 +19471,7 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die) sect_offset_str (die->sect_off)); saved = obstack_strdup (&objfile->objfile_obstack, message); - return init_type (objfile, TYPE_CODE_ERROR, 0, saved); + return type_allocator (objfile).new_type (TYPE_CODE_ERROR, 0, saved); } /* Look up the type of DIE in CU using its type attribute ATTR. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f52899e0a5e..c16651534ed 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3398,37 +3398,6 @@ floatformat_from_type (const struct type *type) return TYPE_FLOATFORMAT (type); } -/* Helper function to initialize the standard scalar types. - - If NAME is non-NULL, then it is used to initialize the type name. - Note that NAME is not copied; it is required to have a lifetime at - least as long as OBJFILE. */ - -struct type * -init_type (struct objfile *objfile, enum type_code code, int bit, - const char *name) -{ - struct type *type; - - type = type_allocator (objfile).new_type (); - set_type_code (type, code); - gdb_assert ((bit % TARGET_CHAR_BIT) == 0); - type->set_length (bit / TARGET_CHAR_BIT); - type->set_name (name); - - return type; -} - -/* Allocate a TYPE_CODE_ERROR type structure associated with OBJFILE, - to use with variables that have no debug info. NAME is the type - name. */ - -static struct type * -init_nodebug_var_type (struct objfile *objfile, const char *name) -{ - return init_type (objfile, TYPE_CODE_ERROR, 0, name); -} - /* Allocate a TYPE_CODE_INT type structure associated with OBJFILE. BIT is the type size in bits. If UNSIGNED_P is non-zero, set the type's TYPE_UNSIGNED flag. NAME is the type name. */ @@ -3439,7 +3408,7 @@ init_integer_type (struct objfile *objfile, { struct type *t; - t = init_type (objfile, TYPE_CODE_INT, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_INT, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -3460,7 +3429,7 @@ init_character_type (struct objfile *objfile, { struct type *t; - t = init_type (objfile, TYPE_CODE_CHAR, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_CHAR, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -3477,7 +3446,7 @@ init_boolean_type (struct objfile *objfile, { struct type *t; - t = init_type (objfile, TYPE_CODE_BOOL, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_BOOL, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -3510,7 +3479,7 @@ init_float_type (struct objfile *objfile, struct type *t; bit = verify_floatformat (bit, fmt); - t = init_type (objfile, TYPE_CODE_FLT, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_FLT, bit, name); TYPE_FLOATFORMAT (t) = fmt; return t; @@ -3522,10 +3491,7 @@ init_float_type (struct objfile *objfile, struct type * init_decfloat_type (struct objfile *objfile, int bit, const char *name) { - struct type *t; - - t = init_type (objfile, TYPE_CODE_DECFLOAT, bit, name); - return t; + return type_allocator (objfile).new_type (TYPE_CODE_DECFLOAT, bit, name); } /* Return true if init_complex_type can be called with TARGET_TYPE. */ @@ -3583,7 +3549,7 @@ init_pointer_type (struct objfile *objfile, { struct type *t; - t = init_type (objfile, TYPE_CODE_PTR, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_PTR, bit, name); t->set_target_type (target_type); t->set_is_unsigned (true); return t; @@ -3600,7 +3566,7 @@ init_fixed_point_type (struct objfile *objfile, { struct type *t; - t = init_type (objfile, TYPE_CODE_FIXED_POINT, bit, name); + t = type_allocator (objfile).new_type (TYPE_CODE_FIXED_POINT, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -6291,9 +6257,11 @@ objfile_type (struct objfile *objfile) /* Use the objfile architecture to determine basic type properties. */ gdbarch = objfile->arch (); + type_allocator alloc (objfile); + /* Basic types. */ objfile_type->builtin_void - = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); objfile_type->builtin_char = init_integer_type (objfile, TARGET_CHAR_BIT, !gdbarch_char_signed (gdbarch), "char"); @@ -6340,17 +6308,17 @@ objfile_type (struct objfile *objfile) /* This type represents a type that was unrecognized in symbol read-in. */ objfile_type->builtin_error - = init_type (objfile, TYPE_CODE_ERROR, 0, ""); + = alloc.new_type (TYPE_CODE_ERROR, 0, ""); /* The following set of types is used for symbols with no debug information. */ objfile_type->nodebug_text_symbol - = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT, - ""); + = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, + ""); objfile_type->nodebug_text_gnu_ifunc_symbol - = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT, - ""); + = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, + ""); objfile_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true); objfile_type->nodebug_got_plt_symbol @@ -6358,11 +6326,13 @@ objfile_type (struct objfile *objfile) "", objfile_type->nodebug_text_symbol); objfile_type->nodebug_data_symbol - = init_nodebug_var_type (objfile, ""); + = alloc.new_type (TYPE_CODE_ERROR, 0, ""); objfile_type->nodebug_unknown_symbol - = init_nodebug_var_type (objfile, ""); + = alloc.new_type (TYPE_CODE_ERROR, 0, + ""); objfile_type->nodebug_tls_symbol - = init_nodebug_var_type (objfile, ""); + = alloc.new_type (TYPE_CODE_ERROR, 0, + ""); /* NOTE: on some targets, addresses and pointers are not necessarily the same. diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 657c04be56e..4a1d2027568 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2296,8 +2296,6 @@ class type_allocator /* * Helper function to construct objfile-owned types. */ -extern struct type *init_type (struct objfile *, enum type_code, int, - const char *); extern struct type *init_integer_type (struct objfile *, int, int, const char *); extern struct type *init_character_type (struct objfile *, int, int, diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index e4814b2b81e..ae563f83457 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1386,6 +1386,8 @@ basic_type (int bt, struct objfile *objfile) if (map_bt[bt]) return map_bt[bt]; + type_allocator alloc (objfile); + switch (bt) { case btNil: @@ -1457,14 +1459,14 @@ basic_type (int bt, struct objfile *objfile) break; case btFloatDec: - tp = init_type (objfile, TYPE_CODE_ERROR, - gdbarch_double_bit (gdbarch), "floating decimal"); + tp = alloc.new_type (TYPE_CODE_ERROR, + gdbarch_double_bit (gdbarch), "floating decimal"); break; case btString: /* Is a "string" the way btString means it the same as TYPE_CODE_STRING? FIXME. */ - tp = init_type (objfile, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); + tp = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); break; case btVoid: @@ -1573,6 +1575,8 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, } } + type_allocator alloc (mdebugread_objfile); + /* Move on to next aux. */ ax++; @@ -1647,7 +1651,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, /* Try to cross reference this type, build new type on failure. */ ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name); if (tp == NULL) - tp = init_type (mdebugread_objfile, type_code, 0, NULL); + tp = alloc.new_type (type_code, 0, NULL); /* DEC c89 produces cross references to qualified aggregate types, dereference them. */ @@ -1705,7 +1709,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, /* Try to cross reference this type, build new type on failure. */ ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name); if (tp == NULL) - tp = init_type (mdebugread_objfile, type_code, 0, NULL); + tp = alloc.new_type (type_code, 0, NULL); /* Make sure that TYPE_CODE(tp) has an expected type code. Any type may be returned from cross_ref if file indirect entries @@ -4264,13 +4268,15 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, rf = rn->rfd; } + type_allocator alloc (mdebugread_objfile); + /* mips cc uses a rf of -1 for opaque struct definitions. Set TYPE_STUB for these types so that check_typedef will resolve them if the struct gets defined in another compilation unit. */ if (rf == -1) { *pname = ""; - *tpp = init_type (mdebugread_objfile, type_code, 0, NULL); + *tpp = alloc.new_type (type_code, 0, NULL); (*tpp)->set_is_stub (true); return result; } @@ -4356,7 +4362,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, switch (tir.bt) { case btVoid: - *tpp = init_type (mdebugread_objfile, type_code, 0, NULL); + *tpp = alloc.new_type (type_code, 0, NULL); *pname = ""; break; @@ -4390,7 +4396,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, default: complaint (_("illegal bt %d in forward typedef for %s"), tir.bt, sym_name); - *tpp = init_type (mdebugread_objfile, type_code, 0, NULL); + *tpp = alloc.new_type (type_code, 0, NULL); break; } return result; @@ -4418,7 +4424,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, has not been parsed yet. Initialize the type only, it will be filled in when it's definition is parsed. */ - *tpp = init_type (mdebugread_objfile, type_code, 0, NULL); + *tpp = alloc.new_type (type_code, 0, NULL); } add_pending (fh, esh, *tpp); } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 8eac7ab6261..7a31d559831 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -372,10 +372,11 @@ dbx_init_float_type (struct objfile *objfile, int bits) struct type *type; format = gdbarch_floatformat_for_type (gdbarch, NULL, bits); + type_allocator alloc (objfile); if (format) type = init_float_type (objfile, bits, NULL, format); else - type = init_type (objfile, TYPE_CODE_ERROR, bits, NULL); + type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL); return type; } @@ -2080,6 +2081,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) TARGET_CHAR_BIT. */ #endif + type_allocator alloc (objfile); switch (-typenum) { case 1: @@ -2119,7 +2121,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_integer_type (objfile, 32, 1, "unsigned long"); break; case 11: - rettype = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); + rettype = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); break; case 12: /* IEEE single precision (32 bit). */ @@ -2153,7 +2155,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) floatformats_ieee_double); break; case 19: - rettype = init_type (objfile, TYPE_CODE_ERROR, 0, "stringptr"); + rettype = alloc.new_type (TYPE_CODE_ERROR, 0, "stringptr"); break; case 20: rettype = init_character_type (objfile, 8, 1, "character"); @@ -3745,10 +3747,11 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile if (**pp == ';') ++(*pp); + type_allocator alloc (objfile); if (type_bits == 0) { - struct type *type = init_type (objfile, TYPE_CODE_VOID, - TARGET_CHAR_BIT, NULL); + struct type *type = alloc.new_type (TYPE_CODE_VOID, + TARGET_CHAR_BIT, nullptr); if (unsigned_type) type->set_is_unsigned (true); @@ -4013,6 +4016,8 @@ read_range_type (const char **pp, int typenums[2], int type_size, if (n2bits == -1 || n3bits == -1) return error_type (pp, objfile); + type_allocator alloc (objfile); + if (index_type) goto handle_true_range; @@ -4061,7 +4066,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, /* A type defined as a subrange of itself, with bounds both 0, is void. */ if (self_subrange && n2 == 0 && n3 == 0) - return init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); + return alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, nullptr); /* If n3 is zero and n2 is positive, we want a floating type, and n2 is the width in bytes. From patchwork Mon Mar 13 22:08:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66337 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 392D4384B07C for ; Mon, 13 Mar 2023 22:09:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 90C9B3858C00 for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90C9B3858C00 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id CFEC21004CA5F for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKtpsRrVUIcAbqKtpbHN1; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZcHYiuZA c=1 sm=1 tr=0 ts=640f9ec7 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=Wbu06DId-hmKLo3WMV8A: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=KqQA5iuyvMrnSLWetOP5JpI+Fms+psqxGGiWvQic4CM=; b=gOZDiWn0nl9kr/BZtl+fFV9n25 ZWlAmijKSspCAuXCgL1O+dahgn7RGssy8DRx203UuZL4lqiXnUcu/io79T7nNm/JPpRG518WOpOe6 jDfeIcOxWkNv29AO4FTNG0CPi; 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 1pbqKt-000u2m-H4 for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:08 -0600 Subject: [PATCH 08/20] Unify arch_integer_type and init_integer_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-8-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: 1pbqKt-000u2m-H4 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: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 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 unifies arch_integer_type and init_integer_type by using a type allocator. --- gdb/ada-lang.c | 14 ++++---- gdb/ctfread.c | 2 +- gdb/d-lang.c | 21 +++++------ gdb/dwarf2/expr.c | 9 +++-- gdb/dwarf2/read.c | 5 ++- gdb/f-lang.c | 8 ++--- gdb/fbsd-tdep.c | 10 +++--- gdb/gdbtypes.c | 103 ++++++++++++++++++++++------------------------------- gdb/gdbtypes.h | 8 ++--- gdb/gnu-v3-abi.c | 2 +- gdb/go-lang.c | 23 ++++++------ gdb/linux-tdep.c | 11 +++--- gdb/m2-lang.c | 6 ++-- gdb/m32c-tdep.c | 12 +++---- gdb/mdebugread.c | 30 ++++++++-------- gdb/opencl-lang.c | 33 ++++++++--------- gdb/rl78-tdep.c | 12 +++---- gdb/rust-lang.c | 23 ++++++------ gdb/stabsread.c | 56 ++++++++++++++--------------- gdb/windows-tdep.c | 13 +++---- gdb/xtensa-tdep.c | 3 +- 21 files changed, 200 insertions(+), 204 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2e99dfa0c6f..a3ceb3ae838 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13557,11 +13557,11 @@ class ada_language : public language_defn }; type_allocator alloc (gdbarch); - add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "integer")); - add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long_integer")); - add (arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "short_integer")); struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "character"); @@ -13573,14 +13573,14 @@ class ada_language : public language_defn "float", gdbarch_float_format (gdbarch))); add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), "long_float", gdbarch_double_format (gdbarch))); - add (arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0, "long_long_integer")); add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), "long_long_float", gdbarch_long_double_format (gdbarch))); - add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "natural")); - add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + add (init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "positive")); add (builtin->builtin_void); @@ -13594,7 +13594,7 @@ class ada_language : public language_defn type. This is a signed integral type whose size is the same as the size of addresses. */ unsigned int addr_length = system_addr_ptr->length (); - add (arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0, + add (init_integer_type (alloc, addr_length * HOST_CHAR_BIT, 0, "storage_offset")); lai->set_bool_type (builtin->builtin_bool); diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 82c2cdb3abb..879fdeb74d6 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -577,7 +577,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) bits = cet.cte_bits; else bits = gdbarch_int_bit (gdbarch); - type = init_integer_type (of, bits, !issigned, name); + type = init_integer_type (alloc, bits, !issigned, name); } } else if (kind == CTF_K_FLOAT) diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 457e367fd51..af9a81d1b1b 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -201,29 +201,30 @@ build_d_types (struct gdbarch *gdbarch) struct builtin_d_type *builtin_d_type = new struct builtin_d_type; /* Basic types. */ + type_allocator alloc (gdbarch); builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_d_type->builtin_bool = arch_boolean_type (gdbarch, 8, 1, "bool"); builtin_d_type->builtin_byte - = arch_integer_type (gdbarch, 8, 0, "byte"); + = init_integer_type (alloc, 8, 0, "byte"); builtin_d_type->builtin_ubyte - = arch_integer_type (gdbarch, 8, 1, "ubyte"); + = init_integer_type (alloc, 8, 1, "ubyte"); builtin_d_type->builtin_short - = arch_integer_type (gdbarch, 16, 0, "short"); + = init_integer_type (alloc, 16, 0, "short"); builtin_d_type->builtin_ushort - = arch_integer_type (gdbarch, 16, 1, "ushort"); + = init_integer_type (alloc, 16, 1, "ushort"); builtin_d_type->builtin_int - = arch_integer_type (gdbarch, 32, 0, "int"); + = init_integer_type (alloc, 32, 0, "int"); builtin_d_type->builtin_uint - = arch_integer_type (gdbarch, 32, 1, "uint"); + = init_integer_type (alloc, 32, 1, "uint"); builtin_d_type->builtin_long - = arch_integer_type (gdbarch, 64, 0, "long"); + = init_integer_type (alloc, 64, 0, "long"); builtin_d_type->builtin_ulong - = arch_integer_type (gdbarch, 64, 1, "ulong"); + = init_integer_type (alloc, 64, 1, "ulong"); builtin_d_type->builtin_cent - = arch_integer_type (gdbarch, 128, 0, "cent"); + = init_integer_type (alloc, 128, 0, "cent"); builtin_d_type->builtin_ucent - = arch_integer_type (gdbarch, 128, 1, "ucent"); + = init_integer_type (alloc, 128, 1, "ucent"); builtin_d_type->builtin_float = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch)); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 2b41372be8a..d245bc65ef2 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -700,9 +700,12 @@ dwarf_expr_context::address_type () const 8 * this->m_addr_size); if (types->dw_types[ndx] == NULL) - types->dw_types[ndx] - = arch_integer_type (arch, 8 * this->m_addr_size, - 0, ""); + { + type_allocator alloc (arch); + types->dw_types[ndx] + = init_integer_type (alloc, 8 * this->m_addr_size, + 0, ""); + } return types->dw_types[ndx]; } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e2571667aa2..f3cc78ce10b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15042,7 +15042,10 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile, && strcmp (name, "void") == 0) type = objfile_type (objfile)->builtin_void; else - type = init_integer_type (objfile, bits, unsigned_p, name); + { + type_allocator alloc (objfile); + type = init_integer_type (alloc, bits, unsigned_p, name); + } return type; } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 3bf33d020c6..cb63c3704c1 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1746,16 +1746,16 @@ build_fortran_types (struct gdbarch *gdbarch) "logical*8"); builtin_f_type->builtin_integer_s1 - = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "integer*1"); + = init_integer_type (alloc, TARGET_CHAR_BIT, 0, "integer*1"); builtin_f_type->builtin_integer_s2 - = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0, "integer*2"); + = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "integer*2"); builtin_f_type->builtin_integer - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "integer*4"); + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "integer*4"); builtin_f_type->builtin_integer_s8 - = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), 0, + = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0, "integer*8"); builtin_f_type->builtin_real diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 236a9f4d615..dc5020d92d2 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1594,11 +1594,12 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) if (fbsd_gdbarch_data->siginfo_type != NULL) return fbsd_gdbarch_data->siginfo_type; - int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + type_allocator alloc (gdbarch); + int_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); - int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t"); - uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t"); - long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + int32_type = init_integer_type (alloc, 32, 0, "int32_t"); + uint32_type = init_integer_type (alloc, 32, 1, "uint32_t"); + long_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long"); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); @@ -1609,7 +1610,6 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); /* __pid_t */ - type_allocator alloc (gdbarch); pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, int32_type->length () * TARGET_CHAR_BIT, "__pid_t"); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index c16651534ed..f5ddc869ebf 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3398,17 +3398,15 @@ floatformat_from_type (const struct type *type) return TYPE_FLOATFORMAT (type); } -/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_integer_type (struct objfile *objfile, +init_integer_type (type_allocator &alloc, int bit, int unsigned_p, const char *name) { struct type *t; - t = type_allocator (objfile).new_type (TYPE_CODE_INT, bit, name); + t = alloc.new_type (TYPE_CODE_INT, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5752,23 +5750,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_INT type structure associated with GDBARCH. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ - -struct type * -arch_integer_type (struct gdbarch *gdbarch, - int bit, int unsigned_p, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_INT, bit, name); - if (unsigned_p) - t->set_is_unsigned (true); - - return t; -} - /* Allocate a TYPE_CODE_CHAR type structure associated with GDBARCH. BIT is the type size in bits. If UNSIGNED_P is non-zero, set the type's TYPE_UNSIGNED flag. NAME is the type name. */ @@ -6086,38 +6067,38 @@ create_gdbtypes_data (struct gdbarch *gdbarch) builtin_type->builtin_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); builtin_type->builtin_char - = arch_integer_type (gdbarch, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, !gdbarch_char_signed (gdbarch), "char"); builtin_type->builtin_char->set_has_no_signedness (true); builtin_type->builtin_signed_char - = arch_integer_type (gdbarch, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, 0, "signed char"); builtin_type->builtin_unsigned_char - = arch_integer_type (gdbarch, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, 1, "unsigned char"); builtin_type->builtin_short - = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), + = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "short"); builtin_type->builtin_unsigned_short - = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), + = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 1, "unsigned short"); builtin_type->builtin_int - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); builtin_type->builtin_unsigned_int - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "unsigned int"); builtin_type->builtin_long - = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long"); builtin_type->builtin_unsigned_long - = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 1, "unsigned long"); builtin_type->builtin_long_long - = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0, "long long"); builtin_type->builtin_unsigned_long_long - = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "unsigned long long"); builtin_type->builtin_half = arch_float_type (gdbarch, gdbarch_half_bit (gdbarch), @@ -6160,31 +6141,31 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* Fixed-size integer types. */ builtin_type->builtin_int0 - = arch_integer_type (gdbarch, 0, 0, "int0_t"); + = init_integer_type (alloc, 0, 0, "int0_t"); builtin_type->builtin_int8 - = arch_integer_type (gdbarch, 8, 0, "int8_t"); + = init_integer_type (alloc, 8, 0, "int8_t"); builtin_type->builtin_uint8 - = arch_integer_type (gdbarch, 8, 1, "uint8_t"); + = init_integer_type (alloc, 8, 1, "uint8_t"); builtin_type->builtin_int16 - = arch_integer_type (gdbarch, 16, 0, "int16_t"); + = init_integer_type (alloc, 16, 0, "int16_t"); builtin_type->builtin_uint16 - = arch_integer_type (gdbarch, 16, 1, "uint16_t"); + = init_integer_type (alloc, 16, 1, "uint16_t"); builtin_type->builtin_int24 - = arch_integer_type (gdbarch, 24, 0, "int24_t"); + = init_integer_type (alloc, 24, 0, "int24_t"); builtin_type->builtin_uint24 - = arch_integer_type (gdbarch, 24, 1, "uint24_t"); + = init_integer_type (alloc, 24, 1, "uint24_t"); builtin_type->builtin_int32 - = arch_integer_type (gdbarch, 32, 0, "int32_t"); + = init_integer_type (alloc, 32, 0, "int32_t"); builtin_type->builtin_uint32 - = arch_integer_type (gdbarch, 32, 1, "uint32_t"); + = init_integer_type (alloc, 32, 1, "uint32_t"); builtin_type->builtin_int64 - = arch_integer_type (gdbarch, 64, 0, "int64_t"); + = init_integer_type (alloc, 64, 0, "int64_t"); builtin_type->builtin_uint64 - = arch_integer_type (gdbarch, 64, 1, "uint64_t"); + = init_integer_type (alloc, 64, 1, "uint64_t"); builtin_type->builtin_int128 - = arch_integer_type (gdbarch, 128, 0, "int128_t"); + = init_integer_type (alloc, 128, 0, "int128_t"); builtin_type->builtin_uint128 - = arch_integer_type (gdbarch, 128, 1, "uint128_t"); + = init_integer_type (alloc, 128, 1, "uint128_t"); builtin_type->builtin_int8->set_instance_flags (builtin_type->builtin_int8->instance_flags () @@ -6196,11 +6177,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* Wide character types. */ builtin_type->builtin_char16 - = arch_integer_type (gdbarch, 16, 1, "char16_t"); + = init_integer_type (alloc, 16, 1, "char16_t"); builtin_type->builtin_char32 - = arch_integer_type (gdbarch, 32, 1, "char32_t"); + = init_integer_type (alloc, 32, 1, "char32_t"); builtin_type->builtin_wchar - = arch_integer_type (gdbarch, gdbarch_wchar_bit (gdbarch), + = init_integer_type (alloc, gdbarch_wchar_bit (gdbarch), !gdbarch_wchar_signed (gdbarch), "wchar_t"); /* Default data/code pointer types. */ @@ -6263,38 +6244,38 @@ objfile_type (struct objfile *objfile) objfile_type->builtin_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); objfile_type->builtin_char - = init_integer_type (objfile, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, !gdbarch_char_signed (gdbarch), "char"); objfile_type->builtin_char->set_has_no_signedness (true); objfile_type->builtin_signed_char - = init_integer_type (objfile, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, 0, "signed char"); objfile_type->builtin_unsigned_char - = init_integer_type (objfile, TARGET_CHAR_BIT, + = init_integer_type (alloc, TARGET_CHAR_BIT, 1, "unsigned char"); objfile_type->builtin_short - = init_integer_type (objfile, gdbarch_short_bit (gdbarch), + = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "short"); objfile_type->builtin_unsigned_short - = init_integer_type (objfile, gdbarch_short_bit (gdbarch), + = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 1, "unsigned short"); objfile_type->builtin_int - = init_integer_type (objfile, gdbarch_int_bit (gdbarch), + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); objfile_type->builtin_unsigned_int - = init_integer_type (objfile, gdbarch_int_bit (gdbarch), + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "unsigned int"); objfile_type->builtin_long - = init_integer_type (objfile, gdbarch_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long"); objfile_type->builtin_unsigned_long - = init_integer_type (objfile, gdbarch_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 1, "unsigned long"); objfile_type->builtin_long_long - = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0, "long long"); objfile_type->builtin_unsigned_long_long - = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch), + = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "unsigned long long"); objfile_type->builtin_float = init_float_type (objfile, gdbarch_float_bit (gdbarch), @@ -6354,7 +6335,7 @@ objfile_type (struct objfile *objfile) are indeed in the unified virtual address space. */ objfile_type->builtin_core_addr - = init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1, + = init_integer_type (alloc, gdbarch_addr_bit (gdbarch), 1, "__CORE_ADDR"); objfile_type_data.set (objfile, objfile_type); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 4a1d2027568..7f2da7a6572 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2294,9 +2294,11 @@ class type_allocator bool m_smash = false; }; -/* * Helper function to construct objfile-owned types. */ +/* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the + type size in bits. If UNSIGNED_P is non-zero, set the type's + TYPE_UNSIGNED flag. NAME is the type name. */ -extern struct type *init_integer_type (struct objfile *, int, int, +extern struct type *init_integer_type (type_allocator &, int, int, const char *); extern struct type *init_character_type (struct objfile *, int, int, const char *); @@ -2314,8 +2316,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_integer_type (struct gdbarch *, int, int, - const char *); extern struct type *arch_character_type (struct gdbarch *, int, int, const char *); extern struct type *arch_boolean_type (struct gdbarch *, int, int, diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index a3e2d73f10a..12bc5b09a93 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -129,7 +129,7 @@ get_gdb_vtable_type (struct gdbarch *arch) /* ARCH can't give us the true ptrdiff_t type, so we guess. */ struct type *ptrdiff_type - = arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t"); + = init_integer_type (alloc, gdbarch_ptr_bit (arch), 0, "ptrdiff_t"); /* We assume no padding is necessary, since GDB doesn't know anything about alignment at the moment. If this assumption bites diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 456b74d80df..8cdd6b124c4 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -483,33 +483,34 @@ build_go_types (struct gdbarch *gdbarch) { struct builtin_go_type *builtin_go_type = new struct builtin_go_type; + type_allocator alloc (gdbarch); builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_go_type->builtin_char = arch_character_type (gdbarch, 8, 1, "char"); builtin_go_type->builtin_bool = arch_boolean_type (gdbarch, 8, 0, "bool"); builtin_go_type->builtin_int - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "int"); + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); builtin_go_type->builtin_uint - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "uint"); + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "uint"); builtin_go_type->builtin_uintptr - = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr"); + = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "uintptr"); builtin_go_type->builtin_int8 - = arch_integer_type (gdbarch, 8, 0, "int8"); + = init_integer_type (alloc, 8, 0, "int8"); builtin_go_type->builtin_int16 - = arch_integer_type (gdbarch, 16, 0, "int16"); + = init_integer_type (alloc, 16, 0, "int16"); builtin_go_type->builtin_int32 - = arch_integer_type (gdbarch, 32, 0, "int32"); + = init_integer_type (alloc, 32, 0, "int32"); builtin_go_type->builtin_int64 - = arch_integer_type (gdbarch, 64, 0, "int64"); + = init_integer_type (alloc, 64, 0, "int64"); builtin_go_type->builtin_uint8 - = arch_integer_type (gdbarch, 8, 1, "uint8"); + = init_integer_type (alloc, 8, 1, "uint8"); builtin_go_type->builtin_uint16 - = arch_integer_type (gdbarch, 16, 1, "uint16"); + = init_integer_type (alloc, 16, 1, "uint16"); builtin_go_type->builtin_uint32 - = arch_integer_type (gdbarch, 32, 1, "uint32"); + = init_integer_type (alloc, 32, 1, "uint32"); builtin_go_type->builtin_uint64 - = arch_integer_type (gdbarch, 64, 1, "uint64"); + = init_integer_type (alloc, 64, 1, "uint64"); builtin_go_type->builtin_float32 = arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single); builtin_go_type->builtin_float64 diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 9192fc99be3..d66534e9182 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -277,13 +277,13 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, type_allocator alloc (gdbarch); - int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + int_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); - uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + uint_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "unsigned int"); - long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + long_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long"); - short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), + short_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "short"); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); @@ -1742,8 +1742,9 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) { struct linux_make_mappings_data mapping_data; + type_allocator alloc (gdbarch); struct type *long_type - = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), 0, "long"); + = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long"); gdb_byte buf[sizeof (ULONGEST)]; auto_obstack data_obstack, filename_obstack; diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 72d0b58d675..218867d408e 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -281,11 +281,13 @@ build_m2_types (struct gdbarch *gdbarch) { struct builtin_m2_type *builtin_m2_type = new struct builtin_m2_type; + type_allocator alloc (gdbarch); + /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */ builtin_m2_type->builtin_int - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "INTEGER"); + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "INTEGER"); builtin_m2_type->builtin_card - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "CARDINAL"); + = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL"); builtin_m2_type->builtin_real = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", gdbarch_float_format (gdbarch)); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index e500ba88a42..65d5df330b1 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -201,12 +201,12 @@ make_types (struct gdbarch *arch) tdep->code_addr_reg_type = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd); - tdep->uint8 = arch_integer_type (arch, 8, 1, "uint8_t"); - tdep->uint16 = arch_integer_type (arch, 16, 1, "uint16_t"); - tdep->int8 = arch_integer_type (arch, 8, 0, "int8_t"); - tdep->int16 = arch_integer_type (arch, 16, 0, "int16_t"); - tdep->int32 = arch_integer_type (arch, 32, 0, "int32_t"); - tdep->int64 = arch_integer_type (arch, 64, 0, "int64_t"); + tdep->uint8 = init_integer_type (alloc, 8, 1, "uint8_t"); + tdep->uint16 = init_integer_type (alloc, 16, 1, "uint16_t"); + tdep->int8 = init_integer_type (alloc, 8, 0, "int8_t"); + tdep->int16 = init_integer_type (alloc, 16, 0, "int16_t"); + tdep->int32 = init_integer_type (alloc, 32, 0, "int32_t"); + tdep->int64 = init_integer_type (alloc, 64, 0, "int64_t"); } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index ae563f83457..84b513d5783 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1400,36 +1400,36 @@ basic_type (int bt, struct objfile *objfile) break; case btChar: - tp = init_integer_type (objfile, 8, 0, "char"); + tp = init_integer_type (alloc, 8, 0, "char"); tp->set_has_no_signedness (true); break; case btUChar: - tp = init_integer_type (objfile, 8, 1, "unsigned char"); + tp = init_integer_type (alloc, 8, 1, "unsigned char"); break; case btShort: - tp = init_integer_type (objfile, 16, 0, "short"); + tp = init_integer_type (alloc, 16, 0, "short"); break; case btUShort: - tp = init_integer_type (objfile, 16, 1, "unsigned short"); + tp = init_integer_type (alloc, 16, 1, "unsigned short"); break; case btInt: - tp = init_integer_type (objfile, 32, 0, "int"); + tp = init_integer_type (alloc, 32, 0, "int"); break; case btUInt: - tp = init_integer_type (objfile, 32, 1, "unsigned int"); + tp = init_integer_type (alloc, 32, 1, "unsigned int"); break; case btLong: - tp = init_integer_type (objfile, 32, 0, "long"); + tp = init_integer_type (alloc, 32, 0, "long"); break; case btULong: - tp = init_integer_type (objfile, 32, 1, "unsigned long"); + tp = init_integer_type (alloc, 32, 1, "unsigned long"); break; case btFloat: @@ -1454,7 +1454,7 @@ basic_type (int bt, struct objfile *objfile) /* We use TYPE_CODE_INT to print these as integers. Does this do any good? Would we be better off with TYPE_CODE_ERROR? Should TYPE_CODE_ERROR print things in hex if it knows the size? */ - tp = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0, + tp = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "fixed decimal"); break; @@ -1474,19 +1474,19 @@ basic_type (int bt, struct objfile *objfile) break; case btLong64: - tp = init_integer_type (objfile, 64, 0, "long"); + tp = init_integer_type (alloc, 64, 0, "long"); break; case btULong64: - tp = init_integer_type (objfile, 64, 1, "unsigned long"); + tp = init_integer_type (alloc, 64, 1, "unsigned long"); break; case btLongLong64: - tp = init_integer_type (objfile, 64, 0, "long long"); + tp = init_integer_type (alloc, 64, 0, "long long"); break; case btULongLong64: - tp = init_integer_type (objfile, 64, 1, "unsigned long long"); + tp = init_integer_type (alloc, 64, 1, "unsigned long long"); break; case btAdr64: @@ -1495,11 +1495,11 @@ basic_type (int bt, struct objfile *objfile) break; case btInt64: - tp = init_integer_type (objfile, 64, 0, "int"); + tp = init_integer_type (alloc, 64, 0, "int"); break; case btUInt64: - tp = init_integer_type (objfile, 64, 1, "unsigned int"); + tp = init_integer_type (alloc, 64, 1, "unsigned int"); break; default: diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 9b5304f588f..94f865e5ad5 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -909,21 +909,22 @@ class opencl_language : public language_defn struct type *el_type, *char_type, *int_type; - char_type = el_type = add (arch_integer_type (gdbarch, 8, 0, "char")); + type_allocator alloc (gdbarch); + char_type = el_type = add (init_integer_type (alloc, 8, 0, "char")); BUILD_OCL_VTYPES (char, el_type); - el_type = add (arch_integer_type (gdbarch, 8, 1, "uchar")); + el_type = add (init_integer_type (alloc, 8, 1, "uchar")); BUILD_OCL_VTYPES (uchar, el_type); - el_type = add (arch_integer_type (gdbarch, 16, 0, "short")); + el_type = add (init_integer_type (alloc, 16, 0, "short")); BUILD_OCL_VTYPES (short, el_type); - el_type = add (arch_integer_type (gdbarch, 16, 1, "ushort")); + el_type = add (init_integer_type (alloc, 16, 1, "ushort")); BUILD_OCL_VTYPES (ushort, el_type); - int_type = el_type = add (arch_integer_type (gdbarch, 32, 0, "int")); + int_type = el_type = add (init_integer_type (alloc, 32, 0, "int")); BUILD_OCL_VTYPES (int, el_type); - el_type = add (arch_integer_type (gdbarch, 32, 1, "uint")); + el_type = add (init_integer_type (alloc, 32, 1, "uint")); BUILD_OCL_VTYPES (uint, el_type); - el_type = add (arch_integer_type (gdbarch, 64, 0, "long")); + el_type = add (init_integer_type (alloc, 64, 0, "long")); BUILD_OCL_VTYPES (long, el_type); - el_type = add (arch_integer_type (gdbarch, 64, 1, "ulong")); + el_type = add (init_integer_type (alloc, 64, 1, "ulong")); BUILD_OCL_VTYPES (ulong, el_type); el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half)); BUILD_OCL_VTYPES (half, el_type); @@ -933,14 +934,14 @@ class opencl_language : public language_defn BUILD_OCL_VTYPES (double, el_type); add (arch_boolean_type (gdbarch, 8, 1, "bool")); - add (arch_integer_type (gdbarch, 8, 1, "unsigned char")); - add (arch_integer_type (gdbarch, 16, 1, "unsigned short")); - add (arch_integer_type (gdbarch, 32, 1, "unsigned int")); - add (arch_integer_type (gdbarch, 64, 1, "unsigned long")); - add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t")); - add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t")); - add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t")); - add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t")); + add (init_integer_type (alloc, 8, 1, "unsigned char")); + add (init_integer_type (alloc, 16, 1, "unsigned short")); + add (init_integer_type (alloc, 32, 1, "unsigned int")); + add (init_integer_type (alloc, 64, 1, "unsigned long")); + add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "size_t")); + add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t")); + add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 0, "intptr_t")); + add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t")); add (builtin_type (gdbarch)->builtin_void); /* Type of elements of strings. */ diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 1177215490f..ccb031bbfde 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1411,12 +1411,12 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Initialize types. */ type_allocator alloc (gdbarch); tdep->rl78_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->rl78_uint8 = arch_integer_type (gdbarch, 8, 1, "uint8_t"); - tdep->rl78_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t"); - tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t"); - tdep->rl78_int16 = arch_integer_type (gdbarch, 16, 0, "int16_t"); - tdep->rl78_uint32 = arch_integer_type (gdbarch, 32, 1, "uint32_t"); - tdep->rl78_int32 = arch_integer_type (gdbarch, 32, 0, "int32_t"); + tdep->rl78_uint8 = init_integer_type (alloc, 8, 1, "uint8_t"); + tdep->rl78_int8 = init_integer_type (alloc, 8, 0, "int8_t"); + tdep->rl78_uint16 = init_integer_type (alloc, 16, 1, "uint16_t"); + tdep->rl78_int16 = init_integer_type (alloc, 16, 0, "int16_t"); + tdep->rl78_uint32 = init_integer_type (alloc, 32, 1, "uint32_t"); + tdep->rl78_int32 = init_integer_type (alloc, 32, 0, "int32_t"); tdep->rl78_data_pointer = arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 82004da53d4..608799cc662 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1594,27 +1594,28 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, return t; }; + type_allocator alloc (gdbarch); struct type *bool_type = add (arch_boolean_type (gdbarch, 8, 1, "bool")); add (arch_character_type (gdbarch, 32, 1, "char")); - add (arch_integer_type (gdbarch, 8, 0, "i8")); + add (init_integer_type (alloc, 8, 0, "i8")); struct type *u8_type - = add (arch_integer_type (gdbarch, 8, 1, "u8")); - add (arch_integer_type (gdbarch, 16, 0, "i16")); - add (arch_integer_type (gdbarch, 16, 1, "u16")); - add (arch_integer_type (gdbarch, 32, 0, "i32")); - add (arch_integer_type (gdbarch, 32, 1, "u32")); - add (arch_integer_type (gdbarch, 64, 0, "i64")); - add (arch_integer_type (gdbarch, 64, 1, "u64")); + = add (init_integer_type (alloc, 8, 1, "u8")); + add (init_integer_type (alloc, 16, 0, "i16")); + add (init_integer_type (alloc, 16, 1, "u16")); + add (init_integer_type (alloc, 32, 0, "i32")); + add (init_integer_type (alloc, 32, 1, "u32")); + add (init_integer_type (alloc, 64, 0, "i64")); + add (init_integer_type (alloc, 64, 1, "u64")); unsigned int length = 8 * builtin->builtin_data_ptr->length (); - add (arch_integer_type (gdbarch, length, 0, "isize")); + add (init_integer_type (alloc, length, 0, "isize")); struct type *usize_type - = add (arch_integer_type (gdbarch, length, 1, "usize")); + = add (init_integer_type (alloc, length, 1, "usize")); add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single)); add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double)); - add (arch_integer_type (gdbarch, 0, 1, "()")); + add (init_integer_type (alloc, 0, 1, "()")); struct type *tem = make_cv_type (1, 0, u8_type, NULL); add (rust_slice_type ("&str", tem, usize_type)); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7a31d559831..6270f48bebb 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2090,35 +2090,35 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) is other than 32 bits, then it should use a new negative type number (or avoid negative type numbers for that case). See stabs.texinfo. */ - rettype = init_integer_type (objfile, 32, 0, "int"); + rettype = init_integer_type (alloc, 32, 0, "int"); break; case 2: - rettype = init_integer_type (objfile, 8, 0, "char"); + rettype = init_integer_type (alloc, 8, 0, "char"); rettype->set_has_no_signedness (true); break; case 3: - rettype = init_integer_type (objfile, 16, 0, "short"); + rettype = init_integer_type (alloc, 16, 0, "short"); break; case 4: - rettype = init_integer_type (objfile, 32, 0, "long"); + rettype = init_integer_type (alloc, 32, 0, "long"); break; case 5: - rettype = init_integer_type (objfile, 8, 1, "unsigned char"); + rettype = init_integer_type (alloc, 8, 1, "unsigned char"); break; case 6: - rettype = init_integer_type (objfile, 8, 0, "signed char"); + rettype = init_integer_type (alloc, 8, 0, "signed char"); break; case 7: - rettype = init_integer_type (objfile, 16, 1, "unsigned short"); + rettype = init_integer_type (alloc, 16, 1, "unsigned short"); break; case 8: - rettype = init_integer_type (objfile, 32, 1, "unsigned int"); + rettype = init_integer_type (alloc, 32, 1, "unsigned int"); break; case 9: - rettype = init_integer_type (objfile, 32, 1, "unsigned"); + rettype = init_integer_type (alloc, 32, 1, "unsigned"); break; case 10: - rettype = init_integer_type (objfile, 32, 1, "unsigned long"); + rettype = init_integer_type (alloc, 32, 1, "unsigned long"); break; case 11: rettype = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); @@ -2141,7 +2141,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) floatformats_ieee_double); break; case 15: - rettype = init_integer_type (objfile, 32, 0, "integer"); + rettype = init_integer_type (alloc, 32, 0, "integer"); break; case 16: rettype = init_boolean_type (objfile, 32, 1, "boolean"); @@ -2183,28 +2183,28 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rs6000_builtin_type (13, objfile)); break; case 27: - rettype = init_integer_type (objfile, 8, 0, "integer*1"); + rettype = init_integer_type (alloc, 8, 0, "integer*1"); break; case 28: - rettype = init_integer_type (objfile, 16, 0, "integer*2"); + rettype = init_integer_type (alloc, 16, 0, "integer*2"); break; case 29: - rettype = init_integer_type (objfile, 32, 0, "integer*4"); + rettype = init_integer_type (alloc, 32, 0, "integer*4"); break; case 30: rettype = init_character_type (objfile, 16, 0, "wchar"); break; case 31: - rettype = init_integer_type (objfile, 64, 0, "long long"); + rettype = init_integer_type (alloc, 64, 0, "long long"); break; case 32: - rettype = init_integer_type (objfile, 64, 1, "unsigned long long"); + rettype = init_integer_type (alloc, 64, 1, "unsigned long long"); break; case 33: - rettype = init_integer_type (objfile, 64, 1, "logical*8"); + rettype = init_integer_type (alloc, 64, 1, "logical*8"); break; case 34: - rettype = init_integer_type (objfile, 64, 0, "integer*8"); + rettype = init_integer_type (alloc, 64, 0, "integer*8"); break; } negative_types[-typenum] = rettype; @@ -3761,7 +3761,7 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile if (boolean_type) return init_boolean_type (objfile, type_bits, unsigned_type, NULL); else - return init_integer_type (objfile, type_bits, unsigned_type, NULL); + return init_integer_type (alloc, type_bits, unsigned_type, NULL); } static struct type * @@ -4059,7 +4059,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, } if (got_signed || got_unsigned) - return init_integer_type (objfile, nbits, got_unsigned, NULL); + return init_integer_type (alloc, nbits, got_unsigned, NULL); else return error_type (pp, objfile); } @@ -4105,14 +4105,14 @@ read_range_type (const char **pp, int typenums[2], int type_size, bits = gdbarch_int_bit (gdbarch); } - return init_integer_type (objfile, bits, 1, NULL); + return init_integer_type (alloc, bits, 1, NULL); } /* Special case: char is defined (Who knows why) as a subrange of itself with range 0-127. */ else if (self_subrange && n2 == 0 && n3 == 127) { - struct type *type = init_integer_type (objfile, TARGET_CHAR_BIT, + struct type *type = init_integer_type (alloc, TARGET_CHAR_BIT, 0, NULL); type->set_has_no_signedness (true); return type; @@ -4126,7 +4126,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, if (n3 < 0) /* n3 actually gives the size. */ - return init_integer_type (objfile, -n3 * TARGET_CHAR_BIT, 1, NULL); + return init_integer_type (alloc, -n3 * TARGET_CHAR_BIT, 1, NULL); /* Is n3 == 2**(8n)-1 for some integer n? Then it's an unsigned n-byte integer. But do require n to be a power of @@ -4140,7 +4140,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, bits >>= 8; if (bits == 0 && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */ - return init_integer_type (objfile, bytes * TARGET_CHAR_BIT, 1, NULL); + return init_integer_type (alloc, bytes * TARGET_CHAR_BIT, 1, NULL); } } /* I think this is for Convex "long long". Since I don't know whether @@ -4150,15 +4150,15 @@ read_range_type (const char **pp, int typenums[2], int type_size, && (self_subrange || n2 == -gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT)) - return init_integer_type (objfile, -n2 * TARGET_CHAR_BIT, 0, NULL); + return init_integer_type (alloc, -n2 * TARGET_CHAR_BIT, 0, NULL); else if (n2 == -n3 - 1) { if (n3 == 0x7f) - return init_integer_type (objfile, 8, 0, NULL); + return init_integer_type (alloc, 8, 0, NULL); if (n3 == 0x7fff) - return init_integer_type (objfile, 16, 0, NULL); + return init_integer_type (alloc, 16, 0, NULL); if (n3 == 0x7fffffff) - return init_integer_type (objfile, 32, 0, NULL); + return init_integer_type (alloc, 32, 0, NULL); } /* We have a real range type on our hands. Allocate space and diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 5a58aa37953..4a08dd48c65 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -216,13 +216,13 @@ windows_get_tlb_type (struct gdbarch *gdbarch) type_allocator alloc (gdbarch); - dword_ptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), + dword_ptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "DWORD_PTR"); - dword32_type = arch_integer_type (gdbarch, 32, + dword32_type = init_integer_type (alloc, 32, 1, "DWORD32"); - word_type = arch_integer_type (gdbarch, 16, + word_type = init_integer_type (alloc, 16, 1, "WORD"); - wchar_type = arch_integer_type (gdbarch, 16, + wchar_type = init_integer_type (alloc, 16, 1, "wchar_t"); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); wchar_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), @@ -810,11 +810,12 @@ windows_get_siginfo_type (struct gdbarch *gdbarch) if (windows_gdbarch_data->siginfo_type != NULL) return windows_gdbarch_data->siginfo_type; - dword_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + type_allocator alloc (gdbarch); + dword_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "DWORD"); pvoid_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), "PVOID", builtin_type (gdbarch)->builtin_void); - ulongptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), + ulongptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "ULONG_PTR"); /* ExceptionCode value names */ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 092ae088932..a47a2987499 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -312,8 +312,9 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum) tp->next = tdep->type_entries; tdep->type_entries = tp; tp->size = size; + type_allocator alloc (gdbarch); tp->virtual_type - = arch_integer_type (gdbarch, size * 8, 1, name.c_str ()); + = init_integer_type (alloc, size * 8, 1, name.c_str ()); } reg->ctype = tp->virtual_type; From patchwork Mon Mar 13 22:08:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66333 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 A996D3854835 for ; Mon, 13 Mar 2023 22:08:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id A48513858C1F for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A48513858C1F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id F10851004CA62 for ; Mon, 13 Mar 2023 22:08:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKtpXv5iNX2abqKtpEw6r; Mon, 13 Mar 2023 22:08:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=640f9ec7 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=l3IUqKpcTN6FWELoBeEA: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=6FMwhEmL3ZGt6JH7DvEMGnCiJ6lw0YhMHw5Gx5HYLCE=; b=RqkHY6nKwpbBdMwiE74nnkDwBc WxLxumpP/ZdeXfCeyIKY6CFTDdTKsEIznSw2TdhRvzZ+nO3sX+gE8PzL0pDTn3p4Bwjh+RTnnU5bc DVLXoLcAD4BMgcZY9pB9XOYdm; 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 1pbqKt-000u2m-Os for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:09 -0600 Subject: [PATCH 09/20] Unify arch_character_type and init_character_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-9-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: 1pbqKt-000u2m-Os 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: 10 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.2 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 unifies arch_character_type and init_character_type by using a type allocator. --- gdb/ada-lang.c | 6 +++--- gdb/ctfread.c | 2 +- gdb/d-lang.c | 6 +++--- gdb/dwarf2/read.c | 8 ++++---- gdb/gdbtypes.c | 29 +++++------------------------ gdb/gdbtypes.h | 9 ++++++--- gdb/go-lang.c | 2 +- gdb/m2-lang.c | 2 +- gdb/rust-lang.c | 2 +- gdb/stabsread.c | 4 ++-- 10 files changed, 27 insertions(+), 43 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a3ceb3ae838..07995f3d47b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13563,12 +13563,12 @@ class ada_language : public language_defn 0, "long_integer")); add (init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "short_integer")); - struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT, + struct type *char_type = init_character_type (alloc, TARGET_CHAR_BIT, 1, "character"); lai->set_string_char_type (char_type); add (char_type); - add (arch_character_type (gdbarch, 16, 1, "wide_character")); - add (arch_character_type (gdbarch, 32, 1, "wide_wide_character")); + add (init_character_type (alloc, 16, 1, "wide_character")); + add (init_character_type (alloc, 32, 1, "wide_wide_character")); add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch))); add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 879fdeb74d6..3940a4f8c67 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -566,7 +566,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) ischar = cet.cte_format & CTF_INT_CHAR; isbool = cet.cte_format & CTF_INT_BOOL; if (ischar) - type = init_character_type (of, TARGET_CHAR_BIT, !issigned, name); + type = init_character_type (alloc, TARGET_CHAR_BIT, !issigned, name); else if (isbool) type = init_boolean_type (of, gdbarch_int_bit (gdbarch), !issigned, name); diff --git a/gdb/d-lang.c b/gdb/d-lang.c index af9a81d1b1b..8e5262d170a 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -262,11 +262,11 @@ build_d_types (struct gdbarch *gdbarch) /* Character types. */ builtin_d_type->builtin_char - = arch_character_type (gdbarch, 8, 1, "char"); + = init_character_type (alloc, 8, 1, "char"); builtin_d_type->builtin_wchar - = arch_character_type (gdbarch, 16, 1, "wchar"); + = init_character_type (alloc, 16, 1, "wchar"); builtin_d_type->builtin_dchar - = arch_character_type (gdbarch, 32, 1, "dchar"); + = init_character_type (alloc, 32, 1, "dchar"); return builtin_d_type; } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f3cc78ce10b..bb77f75179a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15270,7 +15270,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) if (cu->lang () == language_fortran && name && startswith (name, "character(")) - type = init_character_type (objfile, bits, 1, name); + type = init_character_type (alloc, bits, 1, name); else type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); break; @@ -15279,7 +15279,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) || cu->lang () == language_m2 || cu->lang () == language_pascal || cu->lang () == language_fortran) - type = init_character_type (objfile, bits, 0, name); + type = init_character_type (alloc, bits, 0, name); else type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); break; @@ -15289,13 +15289,13 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) || cu->lang () == language_pascal || cu->lang () == language_fortran || cu->lang () == language_rust) - type = init_character_type (objfile, bits, 1, name); + type = init_character_type (alloc, bits, 1, name); else type = dwarf2_init_integer_type (cu, objfile, bits, 1, name); break; case DW_ATE_UTF: { - type = init_character_type (objfile, bits, 1, name); + type = init_character_type (alloc, bits, 1, name); return set_die_type (die, type, cu); } break; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f5ddc869ebf..49f88ce6026 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3417,17 +3417,15 @@ init_integer_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_CHAR type structure associated with OBJFILE. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_character_type (struct objfile *objfile, +init_character_type (type_allocator &alloc, int bit, int unsigned_p, const char *name) { struct type *t; - t = type_allocator (objfile).new_type (TYPE_CODE_CHAR, bit, name); + t = alloc.new_type (TYPE_CODE_CHAR, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5750,23 +5748,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_CHAR type structure associated with GDBARCH. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ - -struct type * -arch_character_type (struct gdbarch *gdbarch, - int bit, int unsigned_p, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_CHAR, bit, name); - if (unsigned_p) - t->set_is_unsigned (true); - - return t; -} - /* Allocate a TYPE_CODE_BOOL type structure associated with GDBARCH. BIT is the type size in bits. If UNSIGNED_P is non-zero, set the type's TYPE_UNSIGNED flag. NAME is the type name. */ @@ -6135,9 +6116,9 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* "True" character types. */ builtin_type->builtin_true_char - = arch_character_type (gdbarch, TARGET_CHAR_BIT, 0, "true character"); + = init_character_type (alloc, TARGET_CHAR_BIT, 0, "true character"); builtin_type->builtin_true_unsigned_char - = arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "true character"); + = init_character_type (alloc, TARGET_CHAR_BIT, 1, "true character"); /* Fixed-size integer types. */ builtin_type->builtin_int0 diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 7f2da7a6572..178a8b9a663 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2300,7 +2300,12 @@ class type_allocator extern struct type *init_integer_type (type_allocator &, int, int, const char *); -extern struct type *init_character_type (struct objfile *, int, int, + +/* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the + type size in bits. If UNSIGNED_P is non-zero, set the type's + TYPE_UNSIGNED flag. NAME is the type name. */ + +extern struct type *init_character_type (type_allocator &, int, int, const char *); extern struct type *init_boolean_type (struct objfile *, int, int, const char *); @@ -2316,8 +2321,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_character_type (struct gdbarch *, int, int, - const char *); extern struct type *arch_boolean_type (struct gdbarch *, int, int, const char *); extern struct type *arch_float_type (struct gdbarch *, int, const char *, diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 8cdd6b124c4..6d0d43530f8 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -486,7 +486,7 @@ build_go_types (struct gdbarch *gdbarch) type_allocator alloc (gdbarch); builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_go_type->builtin_char - = arch_character_type (gdbarch, 8, 1, "char"); + = init_character_type (alloc, 8, 1, "char"); builtin_go_type->builtin_bool = arch_boolean_type (gdbarch, 8, 0, "bool"); builtin_go_type->builtin_int diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 218867d408e..d2fa1a46364 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -292,7 +292,7 @@ build_m2_types (struct gdbarch *gdbarch) = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", gdbarch_float_format (gdbarch)); builtin_m2_type->builtin_char - = arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "CHAR"); + = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR"); builtin_m2_type->builtin_bool = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN"); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 608799cc662..be0a7100f56 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1597,7 +1597,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, type_allocator alloc (gdbarch); struct type *bool_type = add (arch_boolean_type (gdbarch, 8, 1, "bool")); - add (arch_character_type (gdbarch, 32, 1, "char")); + add (init_character_type (alloc, 32, 1, "char")); add (init_integer_type (alloc, 8, 0, "i8")); struct type *u8_type = add (init_integer_type (alloc, 8, 1, "u8")); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 6270f48bebb..4c7b88f30cd 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2158,7 +2158,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = alloc.new_type (TYPE_CODE_ERROR, 0, "stringptr"); break; case 20: - rettype = init_character_type (objfile, 8, 1, "character"); + rettype = init_character_type (alloc, 8, 1, "character"); break; case 21: rettype = init_boolean_type (objfile, 8, 1, "logical*1"); @@ -2192,7 +2192,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_integer_type (alloc, 32, 0, "integer*4"); break; case 30: - rettype = init_character_type (objfile, 16, 0, "wchar"); + rettype = init_character_type (alloc, 16, 0, "wchar"); break; case 31: rettype = init_integer_type (alloc, 64, 0, "long long"); From patchwork Mon Mar 13 22:08:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66335 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 B29853857BB2 for ; Mon, 13 Mar 2023 22:09:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id B87DF3858C2D for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B87DF3858C2D 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 progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 1523E100423F4 for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupfLHZHIU4bqKupFyBK; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NfUja0P4 c=1 sm=1 tr=0 ts=640f9ec8 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=shZJrdpwEmwBhyjc-I4A: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=pdp9UdLalgLHBGAaKDVUexvDYezsUoC+uoYD6hb/uK8=; b=jVkNrkdYlV9GMWNH/FpNU7rh3L 2MdWK82/hnhYINoPms04KfABe8uFpXyfTtpMMfaspi+RYNh+Y+GgKk8GVyd2HXFRulijgG2MOrxNR 96D3/7NOPsm1TD3qKLbfSpng6; 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 1pbqKt-000u2m-Sy for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:10 -0600 Subject: [PATCH 10/20] Unify arch_boolean_type and init_boolean_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-10-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: 1pbqKt-000u2m-Sy 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: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 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 unifies arch_boolean_type and init_boolean_type by using a type allocator. --- gdb/ctfread.c | 2 +- gdb/d-lang.c | 2 +- gdb/dwarf2/read.c | 2 +- gdb/f-lang.c | 8 ++++---- gdb/gdbtypes.c | 27 ++++----------------------- gdb/gdbtypes.h | 10 +++++++--- gdb/go-lang.c | 2 +- gdb/m2-lang.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/rust-lang.c | 2 +- gdb/stabsread.c | 12 ++++++------ 11 files changed, 28 insertions(+), 43 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 3940a4f8c67..72cd8b7cc5d 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -568,7 +568,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) if (ischar) type = init_character_type (alloc, TARGET_CHAR_BIT, !issigned, name); else if (isbool) - type = init_boolean_type (of, gdbarch_int_bit (gdbarch), + type = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), !issigned, name); else { diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 8e5262d170a..a970281800a 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -204,7 +204,7 @@ build_d_types (struct gdbarch *gdbarch) type_allocator alloc (gdbarch); builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_d_type->builtin_bool - = arch_boolean_type (gdbarch, 8, 1, "bool"); + = init_boolean_type (alloc, 8, 1, "bool"); builtin_d_type->builtin_byte = init_integer_type (alloc, 8, 0, "byte"); builtin_d_type->builtin_ubyte diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bb77f75179a..6cac75b847a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15238,7 +15238,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_pointer_type (objfile, bits, name, type); break; case DW_ATE_boolean: - type = init_boolean_type (objfile, bits, 1, name); + type = init_boolean_type (alloc, bits, 1, name); break; case DW_ATE_complex_float: type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name, diff --git a/gdb/f-lang.c b/gdb/f-lang.c index cb63c3704c1..482ae68c5fa 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1733,16 +1733,16 @@ build_fortran_types (struct gdbarch *gdbarch) = alloc.new_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character"); builtin_f_type->builtin_logical_s1 - = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1"); + = init_boolean_type (alloc, TARGET_CHAR_BIT, 1, "logical*1"); builtin_f_type->builtin_logical_s2 - = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1, "logical*2"); + = init_boolean_type (alloc, gdbarch_short_bit (gdbarch), 1, "logical*2"); builtin_f_type->builtin_logical - = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "logical*4"); + = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), 1, "logical*4"); builtin_f_type->builtin_logical_s8 - = arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1, + = init_boolean_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "logical*8"); builtin_f_type->builtin_integer_s1 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 49f88ce6026..cf2862f514c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3432,17 +3432,15 @@ init_character_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_BOOL type structure associated with OBJFILE. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_boolean_type (struct objfile *objfile, +init_boolean_type (type_allocator &alloc, int bit, int unsigned_p, const char *name) { struct type *t; - t = type_allocator (objfile).new_type (TYPE_CODE_BOOL, bit, name); + t = alloc.new_type (TYPE_CODE_BOOL, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5748,23 +5746,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_BOOL type structure associated with GDBARCH. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ - -struct type * -arch_boolean_type (struct gdbarch *gdbarch, - int bit, int unsigned_p, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_BOOL, bit, name); - if (unsigned_p) - t->set_is_unsigned (true); - - return t; -} - /* Allocate a TYPE_CODE_FLT type structure associated with GDBARCH. BIT is the type size in bits; if BIT equals -1, the size is determined by the floatformat. NAME is the type name. Set the @@ -6103,7 +6084,7 @@ create_gdbtypes_data (struct gdbarch *gdbarch) builtin_type->builtin_string = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); builtin_type->builtin_bool - = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool"); + = init_boolean_type (alloc, TARGET_CHAR_BIT, 1, "bool"); /* The following three are about decimal floating point types, which are 32-bits, 64-bits and 128-bits respectively. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 178a8b9a663..a42054ba585 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2307,8 +2307,14 @@ extern struct type *init_integer_type (type_allocator &, int, int, extern struct type *init_character_type (type_allocator &, int, int, const char *); -extern struct type *init_boolean_type (struct objfile *, int, int, + +/* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the + type size in bits. If UNSIGNED_P is non-zero, set the type's + TYPE_UNSIGNED flag. NAME is the type name. */ + +extern struct type *init_boolean_type (type_allocator &, int, int, const char *); + extern struct type *init_float_type (struct objfile *, int, const char *, const struct floatformat **, enum bfd_endian = BFD_ENDIAN_UNKNOWN); @@ -2321,8 +2327,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_boolean_type (struct gdbarch *, int, int, - const char *); extern struct type *arch_float_type (struct gdbarch *, int, const char *, const struct floatformat **); extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 6d0d43530f8..4b6027da77d 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -488,7 +488,7 @@ build_go_types (struct gdbarch *gdbarch) builtin_go_type->builtin_char = init_character_type (alloc, 8, 1, "char"); builtin_go_type->builtin_bool - = arch_boolean_type (gdbarch, 8, 0, "bool"); + = init_boolean_type (alloc, 8, 0, "bool"); builtin_go_type->builtin_int = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); builtin_go_type->builtin_uint diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index d2fa1a46364..03c57530878 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -294,7 +294,7 @@ build_m2_types (struct gdbarch *gdbarch) builtin_m2_type->builtin_char = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR"); builtin_m2_type->builtin_bool - = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN"); + = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), 1, "BOOLEAN"); return builtin_m2_type; } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 94f865e5ad5..9a3c6d790fc 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -933,7 +933,7 @@ class opencl_language : public language_defn el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double)); BUILD_OCL_VTYPES (double, el_type); - add (arch_boolean_type (gdbarch, 8, 1, "bool")); + add (init_boolean_type (alloc, 8, 1, "bool")); add (init_integer_type (alloc, 8, 1, "unsigned char")); add (init_integer_type (alloc, 16, 1, "unsigned short")); add (init_integer_type (alloc, 32, 1, "unsigned int")); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index be0a7100f56..20292329af2 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1596,7 +1596,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, type_allocator alloc (gdbarch); struct type *bool_type - = add (arch_boolean_type (gdbarch, 8, 1, "bool")); + = add (init_boolean_type (alloc, 8, 1, "bool")); add (init_character_type (alloc, 32, 1, "char")); add (init_integer_type (alloc, 8, 0, "i8")); struct type *u8_type diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 4c7b88f30cd..fc02c98962c 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2144,7 +2144,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_integer_type (alloc, 32, 0, "integer"); break; case 16: - rettype = init_boolean_type (objfile, 32, 1, "boolean"); + rettype = init_boolean_type (alloc, 32, 1, "boolean"); break; case 17: rettype = init_float_type (objfile, 32, "short real", @@ -2161,16 +2161,16 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_character_type (alloc, 8, 1, "character"); break; case 21: - rettype = init_boolean_type (objfile, 8, 1, "logical*1"); + rettype = init_boolean_type (alloc, 8, 1, "logical*1"); break; case 22: - rettype = init_boolean_type (objfile, 16, 1, "logical*2"); + rettype = init_boolean_type (alloc, 16, 1, "logical*2"); break; case 23: - rettype = init_boolean_type (objfile, 32, 1, "logical*4"); + rettype = init_boolean_type (alloc, 32, 1, "logical*4"); break; case 24: - rettype = init_boolean_type (objfile, 32, 1, "logical"); + rettype = init_boolean_type (alloc, 32, 1, "logical"); break; case 25: /* Complex type consisting of two IEEE single precision values. */ @@ -3759,7 +3759,7 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile } if (boolean_type) - return init_boolean_type (objfile, type_bits, unsigned_type, NULL); + return init_boolean_type (alloc, type_bits, unsigned_type, NULL); else return init_integer_type (alloc, type_bits, unsigned_type, NULL); } From patchwork Mon Mar 13 22:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66345 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 33E2B384D17C for ; Mon, 13 Mar 2023 22:10:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from qproxy6-pub.mail.unifiedlayer.com (qproxy6-pub.mail.unifiedlayer.com [69.89.23.12]) by sourceware.org (Postfix) with ESMTPS id 39D78385480C for ; Mon, 13 Mar 2023 22:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39D78385480C 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 gproxy2-pub.mail.unifiedlayer.com (unknown [69.89.18.3]) by qproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 843F68043F6C for ; Mon, 13 Mar 2023 22:08:38 +0000 (UTC) Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 75ADD1004A416 for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupMgFqTdYmbqKupNc80; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=D8CCltdj c=1 sm=1 tr=0 ts=640f9ec8 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=8LoIUUZJbt9RbhIoy_EA: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=Pt8KGpC6ikhO76fAMQdUmZLZKrB8X8qVG2rR4Dd2iAE=; b=F5aaIIPYUCwav+dg4P1UAkV5ty A5EhjuQoabvtJhNIZslAAxLCvDulLfisdq18T02i0+KTtvX+3ie/D4jeti55f3peuBUsFaKYVHopu 4x/lubv4kAQNh0I5l7+7KVco0; 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 1pbqKu-000u2m-0i for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:11 -0600 Subject: [PATCH 11/20] Unify arch_float_type and init_float_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-11-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: 1pbqKu-000u2m-0i 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: 12 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 unifies arch_float_type and init_float_type by using a type allocator. --- gdb/ada-lang.c | 6 +++--- gdb/arm-tdep.c | 9 ++++++--- gdb/csky-tdep.c | 5 ++++- gdb/ctfread.c | 2 +- gdb/d-lang.c | 12 ++++++------ gdb/dwarf2/read.c | 2 +- gdb/f-lang.c | 8 ++++---- gdb/gdbtypes.c | 49 ++++++++++++----------------------------------- gdb/gdbtypes.h | 12 +++++++++--- gdb/go-lang.c | 4 ++-- gdb/ia64-tdep.c | 9 ++++++--- gdb/m2-lang.c | 2 +- gdb/m68k-tdep.c | 9 ++++++--- gdb/mdebugread.c | 4 ++-- gdb/nds32-tdep.c | 7 +++++-- gdb/opencl-lang.c | 6 +++--- gdb/rs6000-tdep.c | 3 ++- gdb/rust-lang.c | 4 ++-- gdb/sh-tdep.c | 9 ++++++--- gdb/stabsread.c | 12 ++++++------ gdb/target-descriptions.c | 13 +++++++------ 21 files changed, 94 insertions(+), 93 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 07995f3d47b..b1c8912b0ea 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13569,13 +13569,13 @@ class ada_language : public language_defn add (char_type); add (init_character_type (alloc, 16, 1, "wide_character")); add (init_character_type (alloc, 32, 1, "wide_wide_character")); - add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), + add (init_float_type (alloc, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch))); - add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), + add (init_float_type (alloc, gdbarch_double_bit (gdbarch), "long_float", gdbarch_double_format (gdbarch))); add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0, "long_long_integer")); - add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + add (init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "long_long_float", gdbarch_long_double_format (gdbarch))); add (init_integer_type (alloc, gdbarch_int_bit (gdbarch), diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 70d77452e93..855a1ca0624 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -4904,9 +4904,12 @@ arm_ext_type (struct gdbarch *gdbarch) arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (!tdep->arm_ext_type) - tdep->arm_ext_type - = arch_float_type (gdbarch, -1, "builtin_type_arm_ext", - floatformats_arm_ext); + { + type_allocator alloc (gdbarch); + tdep->arm_ext_type + = init_float_type (alloc, -1, "builtin_type_arm_ext", + floatformats_arm_ext); + } return tdep->arm_ext_type; } diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index f7047506713..e1bafeaa851 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -737,8 +737,11 @@ csky_register_type (struct gdbarch *gdbarch, int reg_nr) /* Float register has 64 bits, and only in ck810. */ if ((reg_nr >=CSKY_FR0_REGNUM) && (reg_nr <= CSKY_FR0_REGNUM + 15)) - return arch_float_type (gdbarch, 64, "builtin_type_csky_ext", + { + type_allocator alloc (gdbarch); + return init_float_type (alloc, 64, "builtin_type_csky_ext", floatformats_ieee_double); + } /* Profiling general register has 48 bits, we use 64bit. */ if ((reg_nr >= CSKY_PROFGR_REGNUM) && (reg_nr <= CSKY_PROFGR_REGNUM + 44)) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 72cd8b7cc5d..ea557195997 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -375,7 +375,7 @@ ctf_init_float_type (struct objfile *objfile, type_allocator alloc (objfile); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format != nullptr) - type = init_float_type (objfile, bits, name, format); + type = init_float_type (alloc, bits, name, format); else type = alloc.new_type (TYPE_CODE_ERROR, bits, name); diff --git a/gdb/d-lang.c b/gdb/d-lang.c index a970281800a..8d1bdd05677 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -226,13 +226,13 @@ build_d_types (struct gdbarch *gdbarch) builtin_d_type->builtin_ucent = init_integer_type (alloc, 128, 1, "ucent"); builtin_d_type->builtin_float - = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch)); builtin_d_type->builtin_double - = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_double_bit (gdbarch), "double", gdbarch_double_format (gdbarch)); builtin_d_type->builtin_real - = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "real", gdbarch_long_double_format (gdbarch)); builtin_d_type->builtin_byte->set_instance_flags @@ -245,13 +245,13 @@ build_d_types (struct gdbarch *gdbarch) /* Imaginary and complex types. */ builtin_d_type->builtin_ifloat - = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "ifloat", gdbarch_float_format (gdbarch)); builtin_d_type->builtin_idouble - = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_double_bit (gdbarch), "idouble", gdbarch_double_format (gdbarch)); builtin_d_type->builtin_ireal - = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "ireal", gdbarch_long_double_format (gdbarch)); builtin_d_type->builtin_cfloat = init_complex_type ("cfloat", builtin_d_type->builtin_float); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6cac75b847a..857206ae034 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15020,7 +15020,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name, type_allocator alloc (objfile); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format) - type = init_float_type (objfile, bits, name, format, byte_order); + type = init_float_type (alloc, bits, name, format, byte_order); else type = alloc.new_type (TYPE_CODE_ERROR, bits, name); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 482ae68c5fa..3fc43346b05 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1759,20 +1759,20 @@ build_fortran_types (struct gdbarch *gdbarch) "integer*8"); builtin_f_type->builtin_real - = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "real*4", gdbarch_float_format (gdbarch)); builtin_f_type->builtin_real_s8 - = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_double_bit (gdbarch), "real*8", gdbarch_double_format (gdbarch)); auto fmt = gdbarch_floatformat_for_type (gdbarch, "real(kind=16)", 128); if (fmt != nullptr) builtin_f_type->builtin_real_s16 - = arch_float_type (gdbarch, 128, "real*16", fmt); + = init_float_type (alloc, 128, "real*16", fmt); else if (gdbarch_long_double_bit (gdbarch) == 128) builtin_f_type->builtin_real_s16 - = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "real*16", gdbarch_long_double_format (gdbarch)); else builtin_f_type->builtin_real_s16 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index cf2862f514c..02711e0af6a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3451,29 +3451,24 @@ init_boolean_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_FLT type structure associated with OBJFILE. - BIT is the type size in bits; if BIT equals -1, the size is - determined by the floatformat. NAME is the type name. Set the - TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order - to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte - order of the objfile's architecture is used. */ +/* See gdbtypes.h. */ struct type * -init_float_type (struct objfile *objfile, +init_float_type (type_allocator &alloc, int bit, const char *name, const struct floatformat **floatformats, enum bfd_endian byte_order) { if (byte_order == BFD_ENDIAN_UNKNOWN) { - struct gdbarch *gdbarch = objfile->arch (); + struct gdbarch *gdbarch = alloc.arch (); byte_order = gdbarch_byte_order (gdbarch); } const struct floatformat *fmt = floatformats[byte_order]; struct type *t; bit = verify_floatformat (bit, fmt); - t = type_allocator (objfile).new_type (TYPE_CODE_FLT, bit, name); + t = alloc.new_type (TYPE_CODE_FLT, bit, name); TYPE_FLOATFORMAT (t) = fmt; return t; @@ -5746,26 +5741,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_FLT type structure associated with GDBARCH. - BIT is the type size in bits; if BIT equals -1, the size is - determined by the floatformat. NAME is the type name. Set the - TYPE_FLOATFORMAT from FLOATFORMATS. */ - -struct type * -arch_float_type (struct gdbarch *gdbarch, - int bit, const char *name, - const struct floatformat **floatformats) -{ - const struct floatformat *fmt = floatformats[gdbarch_byte_order (gdbarch)]; - struct type *t; - - bit = verify_floatformat (bit, fmt); - t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name); - TYPE_FLOATFORMAT (t) = fmt; - - return t; -} - /* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH. BIT is the type size in bits. NAME is the type name. */ @@ -6063,19 +6038,19 @@ create_gdbtypes_data (struct gdbarch *gdbarch) = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "unsigned long long"); builtin_type->builtin_half - = arch_float_type (gdbarch, gdbarch_half_bit (gdbarch), + = init_float_type (alloc, gdbarch_half_bit (gdbarch), "half", gdbarch_half_format (gdbarch)); builtin_type->builtin_float - = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch)); builtin_type->builtin_bfloat16 - = arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch), + = init_float_type (alloc, gdbarch_bfloat16_bit (gdbarch), "bfloat16", gdbarch_bfloat16_format (gdbarch)); builtin_type->builtin_double - = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_double_bit (gdbarch), "double", gdbarch_double_format (gdbarch)); builtin_type->builtin_long_double - = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "long double", gdbarch_long_double_format (gdbarch)); builtin_type->builtin_complex = init_complex_type ("complex", builtin_type->builtin_float); @@ -6240,13 +6215,13 @@ objfile_type (struct objfile *objfile) = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "unsigned long long"); objfile_type->builtin_float - = init_float_type (objfile, gdbarch_float_bit (gdbarch), + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch)); objfile_type->builtin_double - = init_float_type (objfile, gdbarch_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_double_bit (gdbarch), "double", gdbarch_double_format (gdbarch)); objfile_type->builtin_long_double - = init_float_type (objfile, gdbarch_long_double_bit (gdbarch), + = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), "long double", gdbarch_long_double_format (gdbarch)); /* This type represents a type that was unrecognized in symbol read-in. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index a42054ba585..4613fd4a0fd 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2315,9 +2315,17 @@ extern struct type *init_character_type (type_allocator &, int, int, extern struct type *init_boolean_type (type_allocator &, int, int, const char *); -extern struct type *init_float_type (struct objfile *, int, const char *, +/* Allocate a TYPE_CODE_FLT type structure using ALLOC. + BIT is the type size in bits; if BIT equals -1, the size is + determined by the floatformat. NAME is the type name. Set the + TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order + to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte + order of the objfile's architecture is used. */ + +extern struct type *init_float_type (type_allocator &, int, const char *, const struct floatformat **, enum bfd_endian = BFD_ENDIAN_UNKNOWN); + extern struct type *init_decfloat_type (struct objfile *, int, const char *); extern bool can_create_complex_type (struct type *); extern struct type *init_complex_type (const char *, struct type *); @@ -2327,8 +2335,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_float_type (struct gdbarch *, int, const char *, - const struct floatformat **); extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *); extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, struct type *); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 4b6027da77d..7561450b8e7 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -512,9 +512,9 @@ build_go_types (struct gdbarch *gdbarch) builtin_go_type->builtin_uint64 = init_integer_type (alloc, 64, 1, "uint64"); builtin_go_type->builtin_float32 - = arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single); + = init_float_type (alloc, 32, "float32", floatformats_ieee_single); builtin_go_type->builtin_float64 - = arch_float_type (gdbarch, 64, "float64", floatformats_ieee_double); + = init_float_type (alloc, 64, "float64", floatformats_ieee_double); builtin_go_type->builtin_complex64 = init_complex_type ("complex64", builtin_go_type->builtin_float32); builtin_go_type->builtin_complex128 diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index f714c98d8d4..37e5ce95539 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -313,9 +313,12 @@ ia64_ext_type (struct gdbarch *gdbarch) ia64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (!tdep->ia64_ext_type) - tdep->ia64_ext_type - = arch_float_type (gdbarch, 128, "builtin_type_ia64_ext", - floatformats_ia64_ext); + { + type_allocator alloc (gdbarch); + tdep->ia64_ext_type + = init_float_type (alloc, 128, "builtin_type_ia64_ext", + floatformats_ia64_ext); + } return tdep->ia64_ext_type; } diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 03c57530878..e966fb4c3e8 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -289,7 +289,7 @@ build_m2_types (struct gdbarch *gdbarch) builtin_m2_type->builtin_card = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL"); builtin_m2_type->builtin_real - = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", + = init_float_type (alloc, gdbarch_float_bit (gdbarch), "REAL", gdbarch_float_format (gdbarch)); builtin_m2_type->builtin_char = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR"); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index cbd79765ab9..5b2a29a350e 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -102,9 +102,12 @@ m68881_ext_type (struct gdbarch *gdbarch) m68k_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (!tdep->m68881_ext_type) - tdep->m68881_ext_type - = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext", - floatformats_m68881_ext); + { + type_allocator alloc (gdbarch); + tdep->m68881_ext_type + = init_float_type (alloc, -1, "builtin_type_m68881_ext", + floatformats_m68881_ext); + } return tdep->m68881_ext_type; } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 84b513d5783..c49f24da82b 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1433,12 +1433,12 @@ basic_type (int bt, struct objfile *objfile) break; case btFloat: - tp = init_float_type (objfile, gdbarch_float_bit (gdbarch), + tp = init_float_type (alloc, gdbarch_float_bit (gdbarch), "float", gdbarch_float_format (gdbarch)); break; case btDouble: - tp = init_float_type (objfile, gdbarch_double_bit (gdbarch), + tp = init_float_type (alloc, gdbarch_double_bit (gdbarch), "double", gdbarch_double_format (gdbarch)); break; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index c65bc1a47c5..a81b5fd1fae 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -403,8 +403,11 @@ nds32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) /* Currently, only FSRs could be defined as pseudo registers. */ if (regnum < gdbarch_num_pseudo_regs (gdbarch)) - return arch_float_type (gdbarch, -1, "builtin_type_ieee_single", - floatformats_ieee_single); + { + type_allocator alloc (gdbarch); + return init_float_type (alloc, -1, "builtin_type_ieee_single", + floatformats_ieee_single); + } warning (_("Unknown nds32 pseudo register %d."), regnum); return NULL; diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 9a3c6d790fc..47f65547974 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -926,11 +926,11 @@ class opencl_language : public language_defn BUILD_OCL_VTYPES (long, el_type); el_type = add (init_integer_type (alloc, 64, 1, "ulong")); BUILD_OCL_VTYPES (ulong, el_type); - el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half)); + el_type = add (init_float_type (alloc, 16, "half", floatformats_ieee_half)); BUILD_OCL_VTYPES (half, el_type); - el_type = add (arch_float_type (gdbarch, 32, "float", floatformats_ieee_single)); + el_type = add (init_float_type (alloc, 32, "float", floatformats_ieee_single)); BUILD_OCL_VTYPES (float, el_type); - el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double)); + el_type = add (init_float_type (alloc, 64, "double", floatformats_ieee_double)); BUILD_OCL_VTYPES (double, el_type); add (init_boolean_type (alloc, 8, 1, "bool")); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 6ba56527a22..dc78a79146b 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2431,8 +2431,9 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch) */ /* PPC specific type for IEEE 128-bit float field */ + type_allocator alloc (gdbarch); struct type *t_float128 - = arch_float_type (gdbarch, 128, "float128_t", floatformats_ieee_quad); + = init_float_type (alloc, 128, "float128_t", floatformats_ieee_quad); struct type *t; diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 20292329af2..cb128f13f0e 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1613,8 +1613,8 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, struct type *usize_type = add (init_integer_type (alloc, length, 1, "usize")); - add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single)); - add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double)); + add (init_float_type (alloc, 32, "f32", floatformats_ieee_single)); + add (init_float_type (alloc, 64, "f64", floatformats_ieee_double)); add (init_integer_type (alloc, 0, 1, "()")); struct type *tem = make_cv_type (1, 0, u8_type, NULL); diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 60f15f1b58e..babf85eeb90 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1516,9 +1516,12 @@ sh_littlebyte_bigword_type (struct gdbarch *gdbarch) sh_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->sh_littlebyte_bigword_type == NULL) - tdep->sh_littlebyte_bigword_type - = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword", - floatformats_ieee_double_littlebyte_bigword); + { + type_allocator alloc (gdbarch); + tdep->sh_littlebyte_bigword_type + = init_float_type (alloc, -1, "builtin_type_sh_littlebyte_bigword", + floatformats_ieee_double_littlebyte_bigword); + } return tdep->sh_littlebyte_bigword_type; } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index fc02c98962c..7ed0ebf9b1c 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -374,7 +374,7 @@ dbx_init_float_type (struct objfile *objfile, int bits) format = gdbarch_floatformat_for_type (gdbarch, NULL, bits); type_allocator alloc (objfile); if (format) - type = init_float_type (objfile, bits, NULL, format); + type = init_float_type (alloc, bits, NULL, format); else type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL); @@ -2125,19 +2125,19 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) break; case 12: /* IEEE single precision (32 bit). */ - rettype = init_float_type (objfile, 32, "float", + rettype = init_float_type (alloc, 32, "float", floatformats_ieee_single); break; case 13: /* IEEE double precision (64 bit). */ - rettype = init_float_type (objfile, 64, "double", + rettype = init_float_type (alloc, 64, "double", floatformats_ieee_double); break; case 14: /* This is an IEEE double on the RS/6000, and different machines with different sizes for "long double" should use different negative type numbers. See stabs.texinfo. */ - rettype = init_float_type (objfile, 64, "long double", + rettype = init_float_type (alloc, 64, "long double", floatformats_ieee_double); break; case 15: @@ -2147,11 +2147,11 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_boolean_type (alloc, 32, 1, "boolean"); break; case 17: - rettype = init_float_type (objfile, 32, "short real", + rettype = init_float_type (alloc, 32, "short real", floatformats_ieee_single); break; case 18: - rettype = init_float_type (objfile, 64, "real", + rettype = init_float_type (alloc, 64, "real", floatformats_ieee_double); break; case 19: diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 7af3875b48b..7ae9058b2f2 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -116,34 +116,35 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) if (m_type != NULL) return; + type_allocator alloc (m_gdbarch); switch (e->kind) { case TDESC_TYPE_IEEE_HALF: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_half", + m_type = init_float_type (alloc, -1, "builtin_type_ieee_half", floatformats_ieee_half); return; case TDESC_TYPE_IEEE_SINGLE: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_single", + m_type = init_float_type (alloc, -1, "builtin_type_ieee_single", floatformats_ieee_single); return; case TDESC_TYPE_IEEE_DOUBLE: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_double", + m_type = init_float_type (alloc, -1, "builtin_type_ieee_double", floatformats_ieee_double); return; case TDESC_TYPE_ARM_FPA_EXT: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_arm_ext", + m_type = init_float_type (alloc, -1, "builtin_type_arm_ext", floatformats_arm_ext); return; case TDESC_TYPE_I387_EXT: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext", + m_type = init_float_type (alloc, -1, "builtin_type_i387_ext", floatformats_i387_ext); return; case TDESC_TYPE_BFLOAT16: - m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16", + m_type = init_float_type (alloc, -1, "builtin_type_bfloat16", floatformats_bfloat16); return; } From patchwork Mon Mar 13 22:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66336 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 957EF3858298 for ; Mon, 13 Mar 2023 22:09:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 1ACB93858C2F for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1ACB93858C2F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 6C4641003FCFF for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupXv6BNX2abqKupEw7C; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=640f9ec8 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=OBYFFSvtVDWmvnek53kA: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=EFf3DDQnopDt3BINWPcdvh2g1T5KnYWI0rXJCcJgPps=; b=up6ccxmi0m1pXRdU15ZQQ6kPZ0 yzgAAOIt6KvK5lSFEg7t7L5vohPurn4bB6AvN5wAdN04c6CKcjw9G+OBVGkFruePo5Asi8IZmdA2c a2heyCo2EMYzznbKQkg+pVYPr; 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 1pbqKu-000u2m-5a for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:12 -0600 Subject: [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-12-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: 1pbqKu-000u2m-5a 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: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 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 unifies arch_decfloat_type and init_decfloat_type by using a type allocator. --- gdb/dwarf2/read.c | 2 +- gdb/gdbtypes.c | 25 ++++++------------------- gdb/gdbtypes.h | 7 +++++-- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 857206ae034..21c9fa7c543 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15258,7 +15258,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_complex_type (name, type); break; case DW_ATE_decimal_float: - type = init_decfloat_type (objfile, bits, name); + type = init_decfloat_type (alloc, bits, name); break; case DW_ATE_float: type = dwarf2_init_float_type (objfile, bits, name, name, byte_order); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 02711e0af6a..df10ffea383 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3474,13 +3474,12 @@ init_float_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_DECFLOAT type structure associated with OBJFILE. - BIT is the type size in bits. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_decfloat_type (struct objfile *objfile, int bit, const char *name) +init_decfloat_type (type_allocator &alloc, int bit, const char *name) { - return type_allocator (objfile).new_type (TYPE_CODE_DECFLOAT, bit, name); + return alloc.new_type (TYPE_CODE_DECFLOAT, bit, name); } /* Return true if init_complex_type can be called with TARGET_TYPE. */ @@ -5741,18 +5740,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH. - BIT is the type size in bits. NAME is the type name. */ - -struct type * -arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name); - return t; -} - /* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH. BIT is the pointer type size in bits. NAME is the type name. TARGET_TYPE is the pointer target type. Always sets the pointer type's @@ -6064,11 +6051,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* The following three are about decimal floating point types, which are 32-bits, 64-bits and 128-bits respectively. */ builtin_type->builtin_decfloat - = arch_decfloat_type (gdbarch, 32, "_Decimal32"); + = init_decfloat_type (alloc, 32, "_Decimal32"); builtin_type->builtin_decdouble - = arch_decfloat_type (gdbarch, 64, "_Decimal64"); + = init_decfloat_type (alloc, 64, "_Decimal64"); builtin_type->builtin_declong - = arch_decfloat_type (gdbarch, 128, "_Decimal128"); + = init_decfloat_type (alloc, 128, "_Decimal128"); /* "True" character types. */ builtin_type->builtin_true_char diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 4613fd4a0fd..32662d5cd3f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2326,7 +2326,11 @@ extern struct type *init_float_type (type_allocator &, int, const char *, const struct floatformat **, enum bfd_endian = BFD_ENDIAN_UNKNOWN); -extern struct type *init_decfloat_type (struct objfile *, int, const char *); +/* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC. + BIT is the type size in bits. NAME is the type name. */ + +extern struct type *init_decfloat_type (type_allocator &, int, const char *); + extern bool can_create_complex_type (struct type *); extern struct type *init_complex_type (const char *, struct type *); extern struct type *init_pointer_type (struct objfile *, int, const char *, @@ -2335,7 +2339,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *); extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, struct type *); From patchwork Mon Mar 13 22:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66340 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 327C43850438 for ; Mon, 13 Mar 2023 22:09:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 415323858C30 for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 415323858C30 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 8C91D10047C14 for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupsRsUUIcAbqKupbHO0; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZcHYiuZA c=1 sm=1 tr=0 ts=640f9ec8 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=L9PEnqnzHy0USyoAOmwA: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=LcugrIgd+c45mzUjLnBCT0FNMvPKO/B2ok61HvIV57A=; b=xP9jHjFqo6dyMGgkrXM+7H/VrK hOpIfD4xnXUbnTVDTsT746MvicijvSS/8GQ36cKNIe/O67sKOv9zv4eOHDmZQMUZnNDjzPhOSE3pi niGRjh+dJEr40LFJb7QDkxeqd; 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 1pbqKu-000u2m-9T for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:13 -0600 Subject: [PATCH 13/20] Unify arch_pointer_type and init_pointer_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-13-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: 1pbqKu-000u2m-9T 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: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.4 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 unifies arch_pointer_type and init_pointer_type by using a type allocator. --- gdb/avr-tdep.c | 2 +- gdb/dwarf2/read.c | 2 +- gdb/ft32-tdep.c | 2 +- gdb/gdbtypes.c | 28 ++++------------------------ gdb/gdbtypes.h | 13 ++++++++----- gdb/m32c-tdep.c | 7 ++++--- gdb/mdebugread.c | 4 ++-- gdb/rl78-tdep.c | 4 ++-- gdb/windows-tdep.c | 14 +++++++------- gdb/z80-tdep.c | 2 +- 10 files changed, 31 insertions(+), 47 deletions(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index f9f498bfed2..ce2262c5b1a 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1476,7 +1476,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->func_void_type = make_function_type (tdep->void_type, NULL); - tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, + tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, tdep->func_void_type); set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 21c9fa7c543..73efd295422 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15235,7 +15235,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) case DW_ATE_address: /* Turn DW_ATE_address into a void * pointer. */ type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL); - type = init_pointer_type (objfile, bits, name, type); + type = init_pointer_type (alloc, bits, name, type); break; case DW_ATE_boolean: type = init_boolean_type (alloc, bits, 1, name); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 7182185313f..cac4b9ba6a2 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -576,7 +576,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) type_allocator alloc (gdbarch); void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); func_void_type = make_function_type (void_type, NULL); - tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, + tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, func_void_type); tdep->pc_type->set_instance_flags (tdep->pc_type->instance_flags () | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index df10ffea383..103818fae9b 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3526,18 +3526,15 @@ init_complex_type (const char *name, struct type *target_type) return TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type; } -/* Allocate a TYPE_CODE_PTR type structure associated with OBJFILE. - BIT is the pointer type size in bits. NAME is the type name. - TARGET_TYPE is the pointer target type. Always sets the pointer type's - TYPE_UNSIGNED flag. */ +/* See gdbtypes.h. */ struct type * -init_pointer_type (struct objfile *objfile, +init_pointer_type (type_allocator &alloc, int bit, const char *name, struct type *target_type) { struct type *t; - t = type_allocator (objfile).new_type (TYPE_CODE_PTR, bit, name); + t = alloc.new_type (TYPE_CODE_PTR, bit, name); t->set_target_type (target_type); t->set_is_unsigned (true); return t; @@ -5740,23 +5737,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH. - BIT is the pointer type size in bits. NAME is the type name. - TARGET_TYPE is the pointer target type. Always sets the pointer type's - TYPE_UNSIGNED flag. */ - -struct type * -arch_pointer_type (struct gdbarch *gdbarch, - int bit, const char *name, struct type *target_type) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_PTR, bit, name); - t->set_target_type (target_type); - t->set_is_unsigned (true); - return t; -} - /* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH. NAME is the type name. BIT is the size of the flag word in bits. */ @@ -6227,7 +6207,7 @@ objfile_type (struct objfile *objfile) objfile_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true); objfile_type->nodebug_got_plt_symbol - = init_pointer_type (objfile, gdbarch_addr_bit (gdbarch), + = init_pointer_type (alloc, gdbarch_addr_bit (gdbarch), "", objfile_type->nodebug_text_symbol); objfile_type->nodebug_data_symbol diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 32662d5cd3f..dd9d59d5ae8 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2333,15 +2333,18 @@ extern struct type *init_decfloat_type (type_allocator &, int, const char *); extern bool can_create_complex_type (struct type *); extern struct type *init_complex_type (const char *, struct type *); -extern struct type *init_pointer_type (struct objfile *, int, const char *, + +/* Allocate a TYPE_CODE_PTR type structure using ALLOC. + BIT is the pointer type size in bits. NAME is the type name. + TARGET_TYPE is the pointer target type. Always sets the pointer type's + TYPE_UNSIGNED flag. */ + +extern struct type *init_pointer_type (type_allocator &, int, const char *, struct type *); + extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); -/* Helper functions to construct architecture-owned types. */ -extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, - struct type *); - /* Helper functions to construct a struct or record type. An initially empty type is created using arch_composite_type(). Fields are then added using append_composite_type_field*(). A union diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 65d5df330b1..e06dbbe12bf 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -188,18 +188,19 @@ make_types (struct gdbarch *arch) type_allocator alloc (arch); tdep->voyd = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->ptr_voyd - = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd); + = init_pointer_type (alloc, gdbarch_ptr_bit (arch), NULL, tdep->voyd); tdep->func_voyd = lookup_function_type (tdep->voyd); xsnprintf (type_name, sizeof (type_name), "%s_data_addr_t", gdbarch_bfd_arch_info (arch)->printable_name); tdep->data_addr_reg_type - = arch_pointer_type (arch, data_addr_reg_bits, type_name, tdep->voyd); + = init_pointer_type (alloc, data_addr_reg_bits, type_name, tdep->voyd); xsnprintf (type_name, sizeof (type_name), "%s_code_addr_t", gdbarch_bfd_arch_info (arch)->printable_name); tdep->code_addr_reg_type - = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd); + = init_pointer_type (alloc, code_addr_reg_bits, type_name, + tdep->func_voyd); tdep->uint8 = init_integer_type (alloc, 8, 1, "uint8_t"); tdep->uint16 = init_integer_type (alloc, 16, 1, "uint16_t"); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c49f24da82b..c1ba0d31b00 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1395,7 +1395,7 @@ basic_type (int bt, struct objfile *objfile) break; case btAdr: - tp = init_pointer_type (objfile, 32, "adr_32", + tp = init_pointer_type (alloc, 32, "adr_32", objfile_type (objfile)->builtin_void); break; @@ -1490,7 +1490,7 @@ basic_type (int bt, struct objfile *objfile) break; case btAdr64: - tp = init_pointer_type (objfile, 64, "adr_64", + tp = init_pointer_type (alloc, 64, "adr_64", objfile_type (objfile)->builtin_void); break; diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index ccb031bbfde..d01d1fdf0cd 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1419,9 +1419,9 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->rl78_int32 = init_integer_type (alloc, 32, 0, "int32_t"); tdep->rl78_data_pointer - = arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void); + = init_pointer_type (alloc, 16, "rl78_data_addr_t", tdep->rl78_void); tdep->rl78_code_pointer - = arch_pointer_type (gdbarch, 32, "rl78_code_addr_t", tdep->rl78_void); + = init_pointer_type (alloc, 32, "rl78_code_addr_t", tdep->rl78_void); /* Registers. */ set_gdbarch_num_regs (gdbarch, RL78_NUM_REGS); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 4a08dd48c65..bc1927049d8 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -225,8 +225,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch) wchar_type = init_integer_type (alloc, 16, 1, "wchar_t"); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); - wchar_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), - NULL, wchar_type); + wchar_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), + nullptr, wchar_type); /* list entry */ @@ -319,8 +319,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (rupp_type, "shell_info", uni_str_type); append_composite_type_field (rupp_type, "runtime_data", uni_str_type); - rupp_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), - NULL, rupp_type); + rupp_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), + nullptr, rupp_type); /* struct process environment block */ @@ -813,7 +813,7 @@ windows_get_siginfo_type (struct gdbarch *gdbarch) type_allocator alloc (gdbarch); dword_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "DWORD"); - pvoid_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), "PVOID", + pvoid_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), "PVOID", builtin_type (gdbarch)->builtin_void); ulongptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "ULONG_PTR"); @@ -844,8 +844,8 @@ windows_get_siginfo_type (struct gdbarch *gdbarch) siginfo_type = arch_composite_type (gdbarch, "EXCEPTION_RECORD", TYPE_CODE_STRUCT); - siginfo_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), - NULL, siginfo_type); + siginfo_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), + nullptr, siginfo_type); /* ExceptionCode is documented as type DWORD, but here a helper enum type is used instead to display a human-readable value. */ diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 78b3827b54d..27cdca1c9c7 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -1143,7 +1143,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->func_void_type = make_function_type (tdep->void_type, NULL); - tdep->pc_type = arch_pointer_type (gdbarch, + tdep->pc_type = init_pointer_type (alloc, tdep->addr_length * TARGET_CHAR_BIT, NULL, tdep->func_void_type); From patchwork Mon Mar 13 22:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66348 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 494B23847836 for ; Mon, 13 Mar 2023 22:11:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from qproxy5-pub.mail.unifiedlayer.com (qproxy5-pub.mail.unifiedlayer.com [69.89.21.30]) by sourceware.org (Postfix) with ESMTPS id 65408385B522 for ; Mon, 13 Mar 2023 22:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 65408385B522 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 gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by qproxy5.mail.unifiedlayer.com (Postfix) with ESMTP id ABC01803C0FE for ; Mon, 13 Mar 2023 22:08:38 +0000 (UTC) Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 9B24C1004A41C for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupfLIPHIU4bqKupFyCA; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NfUja0P4 c=1 sm=1 tr=0 ts=640f9ec8 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=sNErSq7xPTn2lsUXLlAA: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=SsPWiHomN9k8ATad6+0mOfCeqttRTFvcaMsbU+HR8R0=; b=TKP1hRfOaK1j7S4djzLSdIbh3/ Iw7eKrP9QyP7VyI2kX+1eWP7XbZH4uq+rzs82ZlTBIzCNKG58YTEt4BhcvLerkGHkHX04Fw1JSLCg Xw3UX2jxfLLy4pri9VWxEwXvo; 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 1pbqKu-000u2m-Db for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:14 -0600 Subject: [PATCH 14/20] Use type allocator for range types MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-14-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: 1pbqKu-000u2m-Db 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: 15 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_H3, RCVD_IN_MSPIKE_WL, 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 changes the range type creation functions to accept a type allocator, and updates all the callers. Note that symbol readers should generally allocate on the relevant objfile, regardless of the underlying type of the range, which is what this patch implements. --- gdb/ada-lang.c | 27 ++++++++++++++++----------- gdb/coffread.c | 3 ++- gdb/ctfread.c | 3 ++- gdb/dwarf2/read.c | 18 +++++++++++------- gdb/f-exp.y | 7 ++++--- gdb/f-lang.c | 12 ++++++++---- gdb/gdbtypes.c | 34 +++++++++++++--------------------- gdb/gdbtypes.h | 13 +++++++++---- gdb/mdebugread.c | 7 +++++-- gdb/stabsread.c | 8 +++++--- gdb/valops.c | 6 ++++-- 11 files changed, 79 insertions(+), 59 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b1c8912b0ea..cfb8d6e1110 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2141,15 +2141,15 @@ ada_type_of_array (struct value *arr, int bounds) while (arity > 0) { type_allocator alloc (arr->type ()); - struct type *range_type = alloc.new_type (); struct type *array_type = alloc.new_type (); struct value *low = desc_one_bound (descriptor, arity, 0); struct value *high = desc_one_bound (descriptor, arity, 1); arity -= 1; - create_static_range_type (range_type, low->type (), - longest_to_int (value_as_long (low)), - longest_to_int (value_as_long (high))); + struct type *range_type + = create_static_range_type (alloc, low->type (), + longest_to_int (value_as_long (low)), + longest_to_int (value_as_long (high))); elt_type = create_array_type (array_type, elt_type, range_type); if (ada_is_unconstrained_packed_array_type (arr->type ())) @@ -3094,8 +3094,9 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, { struct type *type0 = ada_check_typedef (type); struct type *base_index_type = type0->index_type ()->target_type (); + type_allocator alloc (base_index_type); struct type *index_type - = create_static_range_type (NULL, base_index_type, low, high); + = create_static_range_type (alloc, base_index_type, low, high); struct type *slice_type = create_array_type_with_stride (NULL, type0->target_type (), index_type, type0->dyn_prop (DYN_PROP_BYTE_STRIDE), @@ -3128,8 +3129,9 @@ ada_value_slice (struct value *array, int low, int high) { struct type *type = ada_check_typedef (array->type ()); struct type *base_index_type = type->index_type ()->target_type (); + type_allocator alloc (type->index_type ()); struct type *index_type - = create_static_range_type (NULL, type->index_type (), low, high); + = create_static_range_type (alloc, type->index_type (), low, high); struct type *slice_type = create_array_type_with_stride (NULL, type->target_type (), index_type, type->dyn_prop (DYN_PROP_BYTE_STRIDE), @@ -3400,9 +3402,10 @@ static struct value * empty_array (struct type *arr_type, int low, int high) { struct type *arr_type0 = ada_check_typedef (arr_type); + type_allocator alloc (arr_type0->index_type ()->target_type ()); struct type *index_type = create_static_range_type - (NULL, arr_type0->index_type ()->target_type (), low, + (alloc, arr_type0->index_type ()->target_type (), low, high < low ? low - 1 : high); struct type *elt_type = ada_array_element_type (arr_type0, 1); @@ -11515,8 +11518,10 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) if (L < INT_MIN || U > INT_MAX) return raw_type; else - return create_static_range_type (type_allocator (raw_type).new_type (), - raw_type, L, U); + { + type_allocator alloc (raw_type); + return create_static_range_type (alloc, raw_type, L, U); + } } else { @@ -11567,8 +11572,8 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) } } - type = create_static_range_type (type_allocator (raw_type).new_type (), - base_type, L, U); + type_allocator alloc (raw_type); + type = create_static_range_type (alloc, base_type, L, U); /* create_static_range_type alters the resulting type's length to match the size of the base_type, which is not what we want. Set it back to the original range type's length. */ diff --git a/gdb/coffread.c b/gdb/coffread.c index 6b2ba96c997..170f7761444 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1778,8 +1778,9 @@ decode_type (struct coff_symbol *cs, unsigned int c_type, base_type = decode_type (cs, new_c_type, aux, objfile); index_type = objfile_type (objfile)->builtin_int; + type_allocator alloc (objfile); range_type - = create_static_range_type (NULL, index_type, 0, n - 1); + = create_static_range_type (alloc, index_type, 0, n - 1); type = create_array_type (NULL, base_type, range_type); } diff --git a/gdb/ctfread.c b/gdb/ctfread.c index ea557195997..3453800079e 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -831,7 +831,8 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) if (idx_type == nullptr) idx_type = objfile_type (objfile)->builtin_int; - range_type = create_static_range_type (NULL, idx_type, 0, ar.ctr_nelems - 1); + type_allocator alloc (objfile); + range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1); type = create_array_type (NULL, element_type, range_type); if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */ { diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 73efd295422..83be77da3ea 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13547,7 +13547,8 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, range_fields[i + 1].set_name (objfile->intern (name)); } - struct type *bounds = type_allocator (objfile).new_type (); + type_allocator alloc (objfile); + struct type *bounds = alloc.new_type (); bounds->set_code (TYPE_CODE_STRUCT); bounds->set_num_fields (range_fields.size ()); @@ -13571,7 +13572,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, gdb_assert (iter->code () == TYPE_CODE_ARRAY); iter->main_type->dyn_prop_list = nullptr; iter->set_index_type - (create_static_range_type (NULL, bounds->field (i).type (), 1, 0)); + (create_static_range_type (alloc, bounds->field (i).type (), 1, 0)); iter = iter->target_type (); } @@ -13655,7 +13656,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) if (die->child == NULL) { index_type = objfile_type (objfile)->builtin_int; - range_type = create_static_range_type (NULL, index_type, 0, -1); + type_allocator alloc (objfile); + range_type = create_static_range_type (alloc, index_type, 0, -1); type = create_array_type_with_stride (NULL, element_type, range_type, byte_stride_prop, bit_stride); return set_die_type (die, type, cu); @@ -14496,14 +14498,15 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) } index_type = objfile_type (objfile)->builtin_int; + type_allocator alloc (objfile); if (length_is_constant) - range_type = create_static_range_type (NULL, index_type, 1, length); + range_type = create_static_range_type (alloc, index_type, 1, length); else { struct dynamic_prop low_bound; low_bound.set_const_val (1); - range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0); + range_type = create_range_type (alloc, index_type, &low_bound, &prop, 0); } char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); @@ -15713,6 +15716,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) } } + type_allocator alloc (cu->per_objfile->objfile); if (attr_byte_stride != nullptr || attr_bit_stride != nullptr) { @@ -15721,11 +15725,11 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) = byte_stride_p ? &byte_stride_prop : &bit_stride_prop; range_type - = create_range_type_with_stride (NULL, orig_base_type, &low, + = create_range_type_with_stride (alloc, orig_base_type, &low, &high, bias, stride, byte_stride_p); } else - range_type = create_range_type (NULL, orig_base_type, &low, &high, bias); + range_type = create_range_type (alloc, orig_base_type, &low, &high, bias); if (high_bound_is_count) range_type->bounds ()->flag_upper_bound_is_count = 1; diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 30da537ea84..9ff8e1988fc 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -669,10 +669,11 @@ ptype : typebase array_size = type_stack->pop_int (); if (array_size != -1) { + struct type *idx_type + = parse_f_type (pstate)->builtin_integer; + type_allocator alloc (idx_type); range_type = - create_static_range_type ((struct type *) NULL, - parse_f_type (pstate) - ->builtin_integer, + create_static_range_type (alloc, idx_type, 0, array_size - 1); follow_type = create_array_type ((struct type *) NULL, diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 3fc43346b05..2da50b27267 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -131,8 +131,9 @@ fortran_bounds_all_dims (bool lbound_p, int ndimensions = calc_f77_array_dims (array_type); /* Allocate a result value of the correct type. */ + type_allocator alloc (gdbarch); struct type *range - = create_static_range_type (nullptr, + = create_static_range_type (alloc, builtin_f_type (gdbarch)->builtin_integer, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; @@ -714,8 +715,9 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, ndimensions = calc_f77_array_dims (val_type); /* Allocate a result value of the correct type. */ + type_allocator alloc (gdbarch); struct type *range - = create_static_range_type (nullptr, + = create_static_range_type (alloc, builtin_type (gdbarch)->builtin_int, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; @@ -1393,8 +1395,9 @@ fortran_undetermined::value_subarray (value *array, p_high.set_const_val (d.high); p_stride.set_const_val (d.stride); + type_allocator alloc (d.index->target_type ()); struct type *new_range - = create_range_type_with_stride ((struct type *) NULL, + = create_range_type_with_stride (alloc, d.index->target_type (), &p_low, &p_high, 0, &p_stride, true); @@ -1429,8 +1432,9 @@ fortran_undetermined::value_subarray (value *array, p_high.set_const_val (d.high); p_stride.set_const_val (repacked_array_type->length ()); + type_allocator alloc (d.index->target_type ()); struct type *new_range - = create_range_type_with_stride ((struct type *) NULL, + = create_range_type_with_stride (alloc, d.index->target_type (), &p_low, &p_high, 0, &p_stride, true); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 103818fae9b..587f953fa09 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -933,7 +933,7 @@ operator== (const range_bounds &l, const range_bounds &r) HIGH_BOUND, inclusive. See create_range_type for further details. */ struct type * -create_range_type (struct type *result_type, struct type *index_type, +create_range_type (type_allocator &alloc, struct type *index_type, const struct dynamic_prop *low_bound, const struct dynamic_prop *high_bound, LONGEST bias) @@ -943,8 +943,7 @@ create_range_type (struct type *result_type, struct type *index_type, gdb_assert (index_type->code () != TYPE_CODE_VOID); gdb_assert (index_type->length () > 0); - if (result_type == NULL) - result_type = type_allocator (index_type).new_type (); + struct type *result_type = alloc.new_type (); result_type->set_code (TYPE_CODE_RANGE); result_type->set_target_type (index_type); if (index_type->is_stub ()) @@ -996,7 +995,7 @@ create_range_type (struct type *result_type, struct type *index_type, /* See gdbtypes.h. */ struct type * -create_range_type_with_stride (struct type *result_type, +create_range_type_with_stride (type_allocator &alloc, struct type *index_type, const struct dynamic_prop *low_bound, const struct dynamic_prop *high_bound, @@ -1004,8 +1003,8 @@ create_range_type_with_stride (struct type *result_type, const struct dynamic_prop *stride, bool byte_stride_p) { - result_type = create_range_type (result_type, index_type, low_bound, - high_bound, bias); + struct type *result_type = create_range_type (alloc, index_type, low_bound, + high_bound, bias); gdb_assert (stride != nullptr); result_type->bounds ()->stride = *stride; @@ -1014,20 +1013,10 @@ create_range_type_with_stride (struct type *result_type, return result_type; } - - -/* Create a range type using either a blank type supplied in - RESULT_TYPE, or creating a new type, inheriting the objfile from - INDEX_TYPE. - - Indices will be of type INDEX_TYPE, and will range from LOW_BOUND - to HIGH_BOUND, inclusive. - - FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make - sure it is TYPE_CODE_UNDEF before we bash it into a range type? */ +/* See gdbtypes.h. */ struct type * -create_static_range_type (struct type *result_type, struct type *index_type, +create_static_range_type (type_allocator &alloc, struct type *index_type, LONGEST low_bound, LONGEST high_bound) { struct dynamic_prop low, high; @@ -1035,7 +1024,8 @@ create_static_range_type (struct type *result_type, struct type *index_type, low.set_const_val (low_bound); high.set_const_val (high_bound); - result_type = create_range_type (result_type, index_type, &low, &high, 0); + struct type *result_type = create_range_type (alloc, index_type, + &low, &high, 0); return result_type; } @@ -1439,12 +1429,13 @@ lookup_array_range_type (struct type *element_type, struct type *index_type; struct type *range_type; + type_allocator alloc (element_type); if (element_type->is_objfile_owned ()) index_type = objfile_type (element_type->objfile_owner ())->builtin_int; else index_type = builtin_type (element_type->arch_owner ())->builtin_int; - range_type = create_static_range_type (NULL, index_type, + range_type = create_static_range_type (alloc, index_type, low_bound, high_bound); return create_array_type (NULL, element_type, range_type); @@ -2272,8 +2263,9 @@ resolve_dynamic_range (struct type *dyn_range_type, = resolve_dynamic_type_internal (dyn_range_type->target_type (), addr_stack, 0); LONGEST bias = dyn_range_type->bounds ()->bias; + type_allocator alloc (dyn_range_type); static_range_type = create_range_type_with_stride - (copy_type (dyn_range_type), static_target_type, + (alloc, static_target_type, &low_bound, &high_bound, bias, &stride, byte_stride_p); static_range_type->bounds ()->flag_bound_evaluated = 1; return static_range_type; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index dd9d59d5ae8..83fbfdbcee0 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2470,7 +2470,12 @@ extern struct type *lookup_function_type_with_arguments (struct type *, int, struct type **); -extern struct type *create_static_range_type (struct type *, struct type *, +/* Create a range type using ALLOC. + + Indices will be of type INDEX_TYPE, and will range from LOW_BOUND + to HIGH_BOUND, inclusive. */ + +extern struct type *create_static_range_type (type_allocator &, struct type *, LONGEST, LONGEST); @@ -2478,7 +2483,7 @@ extern struct type *create_array_type_with_stride (struct type *, struct type *, struct type *, struct dynamic_prop *, unsigned int); -extern struct type *create_range_type (struct type *, struct type *, +extern struct type *create_range_type (type_allocator &, struct type *, const struct dynamic_prop *, const struct dynamic_prop *, LONGEST); @@ -2487,8 +2492,8 @@ extern struct type *create_range_type (struct type *, struct type *, is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit stride. */ -extern struct type * create_range_type_with_stride - (struct type *result_type, struct type *index_type, +extern struct type *create_range_type_with_stride + (type_allocator &alloc, struct type *index_type, const struct dynamic_prop *low_bound, const struct dynamic_prop *high_bound, LONGEST bias, const struct dynamic_prop *stride, bool byte_stride_p); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c1ba0d31b00..3c299d739fe 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1862,9 +1862,12 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend, ax++; rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */ - range = create_static_range_type (NULL, indx, lower, upper); + { + type_allocator alloc (indx); + range = create_static_range_type (alloc, indx, lower, upper); - t = create_array_type (NULL, *tpp, range); + t = create_array_type (NULL, *tpp, range); + } /* We used to fill in the supplied array element bitsize here if the TYPE_LENGTH of the target type was zero. diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7ed0ebf9b1c..1e96102dfe4 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -877,8 +877,9 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* NULL terminate the string. */ string_local[ind] = 0; + type_allocator alloc (objfile); range_type - = create_static_range_type (NULL, + = create_static_range_type (alloc, objfile_type (objfile)->builtin_int, 0, ind); sym->set_type @@ -3547,8 +3548,9 @@ read_array_type (const char **pp, struct type *type, upper = -1; } + type_allocator alloc (objfile); range_type = - create_static_range_type (NULL, index_type, lower, upper); + create_static_range_type (alloc, index_type, lower, upper); type = create_array_type (type, element_type, range_type); return type; @@ -4180,7 +4182,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, } result_type - = create_static_range_type (NULL, index_type, n2, n3); + = create_static_range_type (alloc, index_type, n2, n3); return (result_type); } diff --git a/gdb/valops.c b/gdb/valops.c index 3a1b14c3d44..6fb393fc2ac 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -490,7 +490,8 @@ value_cast (struct type *type, struct value *arg2) "divide object size in cast")); /* FIXME-type-allocation: need a way to free this type when we are done with it. */ - range_type = create_static_range_type (NULL, + type_allocator alloc (range_type->target_type ()); + range_type = create_static_range_type (alloc, range_type->target_type (), low_bound, new_length + low_bound - 1); @@ -4062,7 +4063,8 @@ value_slice (struct value *array, int lowbound, int length) /* FIXME-type-allocation: need a way to free this type when we are done with it. */ - slice_range_type = create_static_range_type (NULL, + type_allocator alloc (range_type->target_type ()); + slice_range_type = create_static_range_type (alloc, range_type->target_type (), lowbound, lowbound + length - 1); From patchwork Mon Mar 13 22:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66339 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 1C2D23850438 for ; Mon, 13 Mar 2023 22:09:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 86EB63858C33 for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86EB63858C33 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id E4EF81003FCED for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupXv6pNX2abqKupEw80; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=640f9ec8 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=RlE5eaPh2gjUCjMlIBAA: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=8YooYw8jJ7Dic15OT1LPDJREEuIVnNolpGuHi/FGMCY=; b=CvBKe4VwJTqy3uV5uSdaizBwcf 2pjEqMb6yy8nkRdIfyl9HoDVEYx70kT0ogdQk54c+N8GNtm9hlAJHUHQvb/xKwqPWDV8xQ3VN2YUr iK6tifc0vmY4GqvEoiJblhbtN; 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 1pbqKu-000u2m-Ir for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:15 -0600 Subject: [PATCH 15/20] Use type allocator for array types MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-15-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: 1pbqKu-000u2m-Ir 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: 16 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.4 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 changes the array type creation functions to accept a type allocator, and updates all the callers. Note that symbol readers should generally allocate on the relevant objfile, regardless of the placement of the index type of the array, which is what this patch implements. --- gdb/ada-lang.c | 25 ++++++++++++----------- gdb/coffread.c | 3 +-- gdb/ctfread.c | 2 +- gdb/dwarf2/read.c | 9 +++++---- gdb/f-exp.y | 6 +++--- gdb/f-lang.c | 8 ++++---- gdb/gdbtypes.c | 59 +++++++++++++------------------------------------------ gdb/gdbtypes.h | 32 +++++++++++++++++++++++++++--- gdb/mdebugread.c | 2 +- gdb/stabsread.c | 5 +++-- gdb/valops.c | 4 ++-- 11 files changed, 76 insertions(+), 79 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cfb8d6e1110..067816c2708 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2141,7 +2141,6 @@ ada_type_of_array (struct value *arr, int bounds) while (arity > 0) { type_allocator alloc (arr->type ()); - struct type *array_type = alloc.new_type (); struct value *low = desc_one_bound (descriptor, arity, 0); struct value *high = desc_one_bound (descriptor, arity, 1); @@ -2150,7 +2149,7 @@ ada_type_of_array (struct value *arr, int bounds) = create_static_range_type (alloc, low->type (), longest_to_int (value_as_long (low)), longest_to_int (value_as_long (high))); - elt_type = create_array_type (array_type, elt_type, range_type); + elt_type = create_array_type (alloc, elt_type, range_type); if (ada_is_unconstrained_packed_array_type (arr->type ())) { @@ -2169,7 +2168,7 @@ ada_type_of_array (struct value *arr, int bounds) int array_bitsize = (hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0); - array_type->set_length ((array_bitsize + 7) / 8); + elt_type->set_length ((array_bitsize + 7) / 8); } } } @@ -2383,11 +2382,11 @@ constrained_packed_array_type (struct type *type, long *elt_bits) else index_type = type->index_type (); - new_type = type_allocator (type).new_type (); + type_allocator alloc (type); new_elt_type = constrained_packed_array_type (ada_check_typedef (type->target_type ()), elt_bits); - create_array_type (new_type, new_elt_type, index_type); + new_type = create_array_type (alloc, new_elt_type, index_type); TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits; new_type->set_name (ada_type_name (type)); @@ -3098,7 +3097,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, struct type *index_type = create_static_range_type (alloc, base_index_type, low, high); struct type *slice_type = create_array_type_with_stride - (NULL, type0->target_type (), index_type, + (alloc, type0->target_type (), index_type, type0->dyn_prop (DYN_PROP_BYTE_STRIDE), TYPE_FIELD_BITSIZE (type0, 0)); int base_low = ada_discrete_type_low_bound (type0->index_type ()); @@ -3133,7 +3132,7 @@ ada_value_slice (struct value *array, int low, int high) struct type *index_type = create_static_range_type (alloc, type->index_type (), low, high); struct type *slice_type = create_array_type_with_stride - (NULL, type->target_type (), index_type, + (alloc, type->target_type (), index_type, type->dyn_prop (DYN_PROP_BYTE_STRIDE), TYPE_FIELD_BITSIZE (type, 0)); gdb::optional low_pos, high_pos; @@ -3409,7 +3408,7 @@ empty_array (struct type *arr_type, int low, int high) high < low ? low - 1 : high); struct type *elt_type = ada_array_element_type (arr_type0, 1); - return value::allocate (create_array_type (NULL, elt_type, index_type)); + return value::allocate (create_array_type (alloc, elt_type, index_type)); } @@ -8474,8 +8473,10 @@ to_fixed_array_type (struct type *type0, struct value *dval, if (elt_type0 == elt_type && !constrained_packed_array_p) result = type0; else - result = create_array_type (type_allocator (type0).new_type (), - elt_type, type0->index_type ()); + { + type_allocator alloc (type0); + result = create_array_type (alloc, elt_type, type0->index_type ()); + } } else { @@ -8506,8 +8507,8 @@ to_fixed_array_type (struct type *type0, struct value *dval, struct type *range_type = to_fixed_range_type (index_type_desc->field (i).type (), dval); - result = create_array_type (type_allocator (elt_type0).new_type (), - result, range_type); + type_allocator alloc (elt_type0); + result = create_array_type (alloc, result, range_type); elt_type0 = elt_type0->target_type (); } } diff --git a/gdb/coffread.c b/gdb/coffread.c index 170f7761444..365e47cb12c 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1781,8 +1781,7 @@ decode_type (struct coff_symbol *cs, unsigned int c_type, type_allocator alloc (objfile); range_type = create_static_range_type (alloc, index_type, 0, n - 1); - type = - create_array_type (NULL, base_type, range_type); + type = create_array_type (alloc, base_type, range_type); } return type; } diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 3453800079e..d1a57d77a50 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -833,7 +833,7 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) type_allocator alloc (objfile); range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1); - type = create_array_type (NULL, element_type, range_type); + type = create_array_type (alloc, element_type, range_type); if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */ { range_type->bounds ()->high.set_undefined (); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 83be77da3ea..db5606c31cf 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13658,7 +13658,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) index_type = objfile_type (objfile)->builtin_int; type_allocator alloc (objfile); range_type = create_static_range_type (alloc, index_type, 0, -1); - type = create_array_type_with_stride (NULL, element_type, range_type, + type = create_array_type_with_stride (alloc, element_type, range_type, byte_stride_prop, bit_stride); return set_die_type (die, type, cu); } @@ -13695,13 +13695,14 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) type = element_type; + type_allocator alloc (cu->per_objfile->objfile); if (read_array_order (die, cu) == DW_ORD_col_major) { int i = 0; while (i < range_types.size ()) { - type = create_array_type_with_stride (NULL, type, range_types[i++], + type = create_array_type_with_stride (alloc, type, range_types[i++], byte_stride_prop, bit_stride); type->set_is_multi_dimensional (true); bit_stride = 0; @@ -13713,7 +13714,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) size_t ndim = range_types.size (); while (ndim-- > 0) { - type = create_array_type_with_stride (NULL, type, range_types[ndim], + type = create_array_type_with_stride (alloc, type, range_types[ndim], byte_stride_prop, bit_stride); type->set_is_multi_dimensional (true); bit_stride = 0; @@ -14509,7 +14510,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) range_type = create_range_type (alloc, index_type, &low_bound, &prop, 0); } char_type = language_string_char_type (cu->language_defn, gdbarch); - type = create_string_type (NULL, char_type, range_type); + type = create_string_type (alloc, char_type, range_type); return set_die_type (die, type, cu); } diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 9ff8e1988fc..0b4ee48ce01 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -675,9 +675,9 @@ ptype : typebase range_type = create_static_range_type (alloc, idx_type, 0, array_size - 1); - follow_type = - create_array_type ((struct type *) NULL, - follow_type, range_type); + follow_type = create_array_type (alloc, + follow_type, + range_type); } else follow_type = lookup_pointer_type (follow_type); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 2da50b27267..365e0c0489b 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -137,7 +137,7 @@ fortran_bounds_all_dims (bool lbound_p, builtin_f_type (gdbarch)->builtin_integer, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; - struct type *result_type = create_array_type (nullptr, elm_type, range); + struct type *result_type = create_array_type (alloc, elm_type, range); struct value *result = value::allocate (result_type); /* Walk the array dimensions backwards due to the way the array will be @@ -721,7 +721,7 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, builtin_type (gdbarch)->builtin_int, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; - struct type *result_type = create_array_type (nullptr, elm_type, range); + struct type *result_type = create_array_type (alloc, elm_type, range); struct value *result = value::allocate (result_type); LONGEST elm_len = elm_type->length (); @@ -1402,7 +1402,7 @@ fortran_undetermined::value_subarray (value *array, &p_low, &p_high, 0, &p_stride, true); array_slice_type - = create_array_type (nullptr, array_slice_type, new_range); + = create_array_type (alloc, array_slice_type, new_range); } if (fortran_array_slicing_debug) @@ -1439,7 +1439,7 @@ fortran_undetermined::value_subarray (value *array, &p_low, &p_high, 0, &p_stride, true); repacked_array_type - = create_array_type (nullptr, repacked_array_type, new_range); + = create_array_type (alloc, repacked_array_type, new_range); } /* Now copy the elements from the original ARRAY into the packed diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 587f953fa09..026f6492398 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1337,30 +1337,10 @@ update_static_array_size (struct type *type) return false; } -/* Create an array type using either a blank type supplied in - RESULT_TYPE, or creating a new type, inheriting the objfile from - RANGE_TYPE. - - Elements will be of type ELEMENT_TYPE, the indices will be of type - RANGE_TYPE. - - BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride. - This byte stride property is added to the resulting array type - as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP - argument can only be used to create types that are objfile-owned - (see add_dyn_prop), meaning that either this function must be called - with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE. - - BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL. - If BIT_STRIDE is not zero, build a packed array type whose element - size is BIT_STRIDE. Otherwise, ignore this parameter. - - FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make - sure it is TYPE_CODE_UNDEF before we bash it into an array - type? */ +/* See gdbtypes.h. */ struct type * -create_array_type_with_stride (struct type *result_type, +create_array_type_with_stride (type_allocator &alloc, struct type *element_type, struct type *range_type, struct dynamic_prop *byte_stride_prop, @@ -1377,8 +1357,7 @@ create_array_type_with_stride (struct type *result_type, byte_stride_prop = NULL; } - if (result_type == NULL) - result_type = type_allocator (range_type).new_type (); + struct type *result_type = alloc.new_type (); result_type->set_code (TYPE_CODE_ARRAY); result_type->set_target_type (element_type); @@ -1410,15 +1389,14 @@ create_array_type_with_stride (struct type *result_type, return result_type; } -/* Same as create_array_type_with_stride but with no bit_stride - (BIT_STRIDE = 0), thus building an unpacked array. */ +/* See gdbtypes.h. */ struct type * -create_array_type (struct type *result_type, +create_array_type (type_allocator &alloc, struct type *element_type, struct type *range_type) { - return create_array_type_with_stride (result_type, element_type, + return create_array_type_with_stride (alloc, element_type, range_type, NULL, 0); } @@ -1438,29 +1416,19 @@ lookup_array_range_type (struct type *element_type, range_type = create_static_range_type (alloc, index_type, low_bound, high_bound); - return create_array_type (NULL, element_type, range_type); + return create_array_type (alloc, element_type, range_type); } -/* Create a string type using either a blank type supplied in - RESULT_TYPE, or creating a new type. String types are similar - enough to array of char types that we can use create_array_type to - build the basic type and then bash it into a string type. - - For fixed length strings, the range type contains 0 as the lower - bound and the length of the string minus one as the upper bound. - - FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make - sure it is TYPE_CODE_UNDEF before we bash it into a string - type? */ +/* See gdbtypes.h. */ struct type * -create_string_type (struct type *result_type, +create_string_type (type_allocator &alloc, struct type *string_char_type, struct type *range_type) { - result_type = create_array_type (result_type, - string_char_type, - range_type); + struct type *result_type = create_array_type (alloc, + string_char_type, + range_type); result_type->set_code (TYPE_CODE_STRING); return result_type; } @@ -2372,7 +2340,8 @@ resolve_dynamic_array_or_string_1 (struct type *type, else bit_stride = TYPE_FIELD_BITSIZE (type, 0); - return create_array_type_with_stride (type, elt_type, range_type, NULL, + type_allocator alloc (type, type_allocator::SMASH); + return create_array_type_with_stride (alloc, elt_type, range_type, NULL, bit_stride); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 83fbfdbcee0..c1964b42e67 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2478,9 +2478,24 @@ extern struct type *lookup_function_type_with_arguments (struct type *, extern struct type *create_static_range_type (type_allocator &, struct type *, LONGEST, LONGEST); +/* Create an array type using ALLOC. + + Elements will be of type ELEMENT_TYPE, the indices will be of type + RANGE_TYPE. + + BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride. + This byte stride property is added to the resulting array type + as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP + argument can only be used to create types that are objfile-owned + (see add_dyn_prop), meaning that either this function must be called + with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE. + + BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL. + If BIT_STRIDE is not zero, build a packed array type whose element + size is BIT_STRIDE. Otherwise, ignore this parameter. */ extern struct type *create_array_type_with_stride - (struct type *, struct type *, struct type *, + (type_allocator &, struct type *, struct type *, struct dynamic_prop *, unsigned int); extern struct type *create_range_type (type_allocator &, struct type *, @@ -2498,13 +2513,24 @@ extern struct type *create_range_type_with_stride const struct dynamic_prop *high_bound, LONGEST bias, const struct dynamic_prop *stride, bool byte_stride_p); -extern struct type *create_array_type (struct type *, struct type *, +/* Same as create_array_type_with_stride but with no bit_stride + (BIT_STRIDE = 0), thus building an unpacked array. */ + +extern struct type *create_array_type (type_allocator &, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST); -extern struct type *create_string_type (struct type *, struct type *, +/* Create a string type using ALLOC. String types are similar enough + to array of char types that we can use create_array_type to build + the basic type and then bash it into a string type. + + For fixed length strings, the range type contains 0 as the lower + bound and the length of the string minus one as the upper bound. */ + +extern struct type *create_string_type (type_allocator &, struct type *, struct type *); + extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST); extern struct type *create_set_type (struct type *, struct type *); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 3c299d739fe..eb6f593580b 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1866,7 +1866,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend, type_allocator alloc (indx); range = create_static_range_type (alloc, indx, lower, upper); - t = create_array_type (NULL, *tpp, range); + t = create_array_type (alloc, *tpp, range); } /* We used to fill in the supplied array element bitsize diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 1e96102dfe4..c8c49e15403 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -883,7 +883,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, objfile_type (objfile)->builtin_int, 0, ind); sym->set_type - (create_array_type (NULL, objfile_type (objfile)->builtin_char, + (create_array_type (alloc, objfile_type (objfile)->builtin_char, range_type)); string_value = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, ind + 1); @@ -3551,7 +3551,8 @@ read_array_type (const char **pp, struct type *type, type_allocator alloc (objfile); range_type = create_static_range_type (alloc, index_type, lower, upper); - type = create_array_type (type, element_type, range_type); + type_allocator smash_alloc (type, type_allocator::SMASH); + type = create_array_type (smash_alloc, element_type, range_type); return type; } diff --git a/gdb/valops.c b/gdb/valops.c index 6fb393fc2ac..657bc4af4d4 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -495,7 +495,7 @@ value_cast (struct type *type, struct value *arg2) range_type->target_type (), low_bound, new_length + low_bound - 1); - arg2->deprecated_set_type (create_array_type (NULL, + arg2->deprecated_set_type (create_array_type (alloc, element_type, range_type)); return arg2; @@ -4074,7 +4074,7 @@ value_slice (struct value *array, int lowbound, int length) LONGEST offset = (lowbound - lowerbound) * check_typedef (element_type)->length (); - slice_type = create_array_type (NULL, + slice_type = create_array_type (alloc, element_type, slice_range_type); slice_type->set_code (array_type->code ()); From patchwork Mon Mar 13 22:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66338 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 491D13858289 for ; Mon, 13 Mar 2023 22:09:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 828123858D1E for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 828123858D1E 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 progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id DD7D310047C03 for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupFhbjUEmJbqKup3IA1; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=TLSA93pa c=1 sm=1 tr=0 ts=640f9ec8 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=rgGjf8jgLLAb2UjrpEgA: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=Mnzetv3zjWf+k16boWieQJs+GoILVaw3yZz07DDryio=; b=bJIxMY7vy+EtWz7H6aLQSzX5js BALwiCpfkZAcar1HYDb/xSOB1PNa3e0+djKv+zWmXl1VsqV9QShyjBcWlxy8ohwG7gqiXUH9q6vWR /dMFjfKQA3Ioq7NXtEs/CPjXx; 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 1pbqKu-000u2m-Nh for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:16 -0600 Subject: [PATCH 16/20] Use type allocator for set types MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-16-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: 1pbqKu-000u2m-Nh 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: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 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 changes the set type creation function to accept a type allocator, and updates all the callers. Note that symbol readers should generally allocate on the relevant objfile, regardless of the underlying type of the set, which is what this patch implements. --- gdb/dwarf2/read.c | 3 ++- gdb/gdbtypes.c | 5 ++--- gdb/gdbtypes.h | 2 +- gdb/stabsread.c | 11 +++++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index db5606c31cf..b1c895f0576 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13825,7 +13825,8 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu) if (set_type) return set_type; - set_type = create_set_type (NULL, domain_type); + type_allocator alloc (cu->per_objfile->objfile); + set_type = create_set_type (alloc, domain_type); attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr != nullptr && attr->form_is_unsigned ()) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 026f6492398..8093a3911d7 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1446,10 +1446,9 @@ lookup_string_range_type (struct type *string_char_type, } struct type * -create_set_type (struct type *result_type, struct type *domain_type) +create_set_type (type_allocator &alloc, struct type *domain_type) { - if (result_type == NULL) - result_type = type_allocator (domain_type).new_type (); + struct type *result_type = alloc.new_type (); result_type->set_code (TYPE_CODE_SET); result_type->set_num_fields (1); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index c1964b42e67..46261bbe4df 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2533,7 +2533,7 @@ extern struct type *create_string_type (type_allocator &, struct type *, extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST); -extern struct type *create_set_type (struct type *, struct type *); +extern struct type *create_set_type (type_allocator &, struct type *); extern struct type *lookup_unsigned_typename (const struct language_defn *, const char *); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index c8c49e15403..89d778db1c2 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2016,10 +2016,13 @@ read_type (const char **pp, struct objfile *objfile) break; case 'S': /* Set type */ - type1 = read_type (pp, objfile); - type = create_set_type (NULL, type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums, objfile) = type; + { + type1 = read_type (pp, objfile); + type_allocator alloc (objfile); + type = create_set_type (alloc, type1); + if (typenums[0] != -1) + *dbx_lookup_type (typenums, objfile) = type; + } break; default: From patchwork Mon Mar 13 22:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66343 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 D426C383EC54 for ; Mon, 13 Mar 2023 22:10:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id A173C3858407 for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A173C3858407 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 081181004A412 for ; Mon, 13 Mar 2023 22:08:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupMgGwTdYmbqKupNc95; Mon, 13 Mar 2023 22:08:09 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=D8CCltdj c=1 sm=1 tr=0 ts=640f9ec9 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=pmTDNbZtAESQYN41jh4A: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=xcJnEjIi7CA/K3HwWMJ69/YDm7EcucczTLc4tCnH1L4=; b=Zjp+2ZT5U/KE8fpB6NYuRhERsN JvEUKUDnIvm59RJ3HJVKnBXQsHL6tlkbwbv3NG0oHEqbPhSzeKUo2xMs85o3/25h60u6eEKE5ai/z zE2/1f0W+jgrRNxmQ2oNhiyUb; 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 1pbqKu-000u2m-Ri for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:17 -0600 Subject: [PATCH 17/20] Use builtin type when appropriate MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-17-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: 1pbqKu-000u2m-Ri 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: 18 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.4 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" There are a few spots that check whether a type is objfile-owned, and then choose either the objfile- or arch-specific builtin type. I don't think there is a need to do this any more (if there ever was), because it is ok for an objfile-allocated type to refer to an arch-allocated type. --- gdb/compile/compile-c-types.c | 11 ++--------- gdb/compile/compile-cplus-types.c | 5 +---- gdb/gdbtypes.c | 5 +---- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 68903c27a97..f48eca2152a 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -164,10 +164,7 @@ convert_func (compile_c_instance *context, struct type *type) GDB's parser used to do. */ if (target_type == NULL) { - if (type->is_objfile_owned ()) - target_type = objfile_type (type->objfile_owner ())->builtin_int; - else - target_type = builtin_type (type->arch_owner ())->builtin_int; + target_type = builtin_type (type->arch ())->builtin_int; warning (_("function has unknown return type; assuming int")); } @@ -322,11 +319,7 @@ convert_type_basic (compile_c_instance *context, struct type *type) the cast-to type as the variable's type, like GDB's built-in parser does. For now, assume "int" like GDB's built-in parser used to do, but at least warn. */ - struct type *fallback; - if (type->is_objfile_owned ()) - fallback = objfile_type (type->objfile_owner ())->builtin_int; - else - fallback = builtin_type (type->arch_owner ())->builtin_int; + struct type *fallback = builtin_type (type->arch ())->builtin_int; warning (_("variable has unknown type; assuming int")); return convert_int (context, fallback); } diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index d48aa61b4bc..47cb26785fc 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -969,10 +969,7 @@ compile_cplus_convert_func (compile_cplus_instance *instance, GDB's parser used to do. */ if (target_type == nullptr) { - if (type->is_objfile_owned ()) - target_type = objfile_type (type->objfile_owner ())->builtin_int; - else - target_type = builtin_type (type->arch_owner ())->builtin_int; + target_type = builtin_type (type->arch ())->builtin_int; warning (_("function has unknown return type; assuming int")); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 8093a3911d7..a167308dc8f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1408,10 +1408,7 @@ lookup_array_range_type (struct type *element_type, struct type *range_type; type_allocator alloc (element_type); - if (element_type->is_objfile_owned ()) - index_type = objfile_type (element_type->objfile_owner ())->builtin_int; - else - index_type = builtin_type (element_type->arch_owner ())->builtin_int; + index_type = builtin_type (element_type->arch ())->builtin_int; range_type = create_static_range_type (alloc, index_type, low_bound, high_bound); From patchwork Mon Mar 13 22:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66342 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 593CB383F43C for ; Mon, 13 Mar 2023 22:09:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id D99393858409 for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D99393858409 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 476891003FD19 for ; Mon, 13 Mar 2023 22:08:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKvpsRtNUIcAbqKvpbHOt; Mon, 13 Mar 2023 22:08:09 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZcHYiuZA c=1 sm=1 tr=0 ts=640f9ec9 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=sMVAGIIksFwrvRlQ_SwA: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=FB8O1Xz0PtJBQYg0eroyGlw9rABHIvwl8Os3NRij7pw=; b=EzX6bzkpOHDCIId/yCi3SIXydj UJcaqSG+OpNq6+Jy516N1sn37n2chQ/KooixsFWQmfMtqjswBoldg9BWWOMxC4jZRcRpb0Mkqj0b9 5czHG0oqTZodD/2reuk1w7PRy; 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 1pbqKu-000u2m-W0 for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:09 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:18 -0600 Subject: [PATCH 18/20] Rename objfile_type to builtin_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-18-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: 1pbqKu-000u2m-W0 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: 19 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 renames objfile_type to be an overload of builtin_type, in preparation for their unification. --- gdb/coffread.c | 34 +++++++++++++++++----------------- gdb/compile/compile-c-symbols.c | 10 +++++----- gdb/compile/compile-cplus-symbols.c | 10 +++++----- gdb/ctfread.c | 18 +++++++++--------- gdb/dwarf2/cu.c | 2 +- gdb/dwarf2/read.c | 16 ++++++++-------- gdb/gdbtypes.c | 2 +- gdb/gdbtypes.h | 2 +- gdb/mdebugread.c | 24 ++++++++++++------------ gdb/objfiles.c | 4 ++-- gdb/parse.c | 12 ++++++------ gdb/stabsread.c | 26 +++++++++++++------------- gdb/xcoffread.c | 4 ++-- 13 files changed, 82 insertions(+), 82 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 365e47cb12c..268c6122c10 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1777,7 +1777,7 @@ decode_type (struct coff_symbol *cs, unsigned int c_type, *dim = 0; base_type = decode_type (cs, new_c_type, aux, objfile); - index_type = objfile_type (objfile)->builtin_int; + index_type = builtin_type (objfile)->builtin_int; type_allocator alloc (objfile); range_type = create_static_range_type (alloc, index_type, 0, n - 1); @@ -1844,39 +1844,39 @@ decode_base_type (struct coff_symbol *cs, { case T_NULL: /* Shows up with "void (*foo)();" structure members. */ - return objfile_type (objfile)->builtin_void; + return builtin_type (objfile)->builtin_void; #ifdef T_VOID case T_VOID: /* Intel 960 COFF has this symbol and meaning. */ - return objfile_type (objfile)->builtin_void; + return builtin_type (objfile)->builtin_void; #endif case T_CHAR: - return objfile_type (objfile)->builtin_char; + return builtin_type (objfile)->builtin_char; case T_SHORT: - return objfile_type (objfile)->builtin_short; + return builtin_type (objfile)->builtin_short; case T_INT: - return objfile_type (objfile)->builtin_int; + return builtin_type (objfile)->builtin_int; case T_LONG: if (cs->c_sclass == C_FIELD && aux->x_sym.x_misc.x_lnsz.x_size > gdbarch_long_bit (gdbarch)) - return objfile_type (objfile)->builtin_long_long; + return builtin_type (objfile)->builtin_long_long; else - return objfile_type (objfile)->builtin_long; + return builtin_type (objfile)->builtin_long; case T_FLOAT: - return objfile_type (objfile)->builtin_float; + return builtin_type (objfile)->builtin_float; case T_DOUBLE: - return objfile_type (objfile)->builtin_double; + return builtin_type (objfile)->builtin_double; case T_LNGDBL: - return objfile_type (objfile)->builtin_long_double; + return builtin_type (objfile)->builtin_long_double; case T_STRUCT: if (cs->c_naux != 1) @@ -1945,24 +1945,24 @@ decode_base_type (struct coff_symbol *cs, break; case T_UCHAR: - return objfile_type (objfile)->builtin_unsigned_char; + return builtin_type (objfile)->builtin_unsigned_char; case T_USHORT: - return objfile_type (objfile)->builtin_unsigned_short; + return builtin_type (objfile)->builtin_unsigned_short; case T_UINT: - return objfile_type (objfile)->builtin_unsigned_int; + return builtin_type (objfile)->builtin_unsigned_int; case T_ULONG: if (cs->c_sclass == C_FIELD && aux->x_sym.x_misc.x_lnsz.x_size > gdbarch_long_bit (gdbarch)) - return objfile_type (objfile)->builtin_unsigned_long_long; + return builtin_type (objfile)->builtin_unsigned_long_long; else - return objfile_type (objfile)->builtin_unsigned_long; + return builtin_type (objfile)->builtin_unsigned_long; } complaint (_("Unexpected type for symbol %s"), cs->c_name); - return objfile_type (objfile)->builtin_void; + return builtin_type (objfile)->builtin_void; } /* This page contains subroutines of read_type. */ diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index c47af4a3ab0..0449c37099e 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -279,12 +279,12 @@ convert_symbol_bmsym (compile_c_instance *context, case mst_text: case mst_file_text: case mst_solib_trampoline: - type = objfile_type (objfile)->nodebug_text_symbol; + type = builtin_type (objfile)->nodebug_text_symbol; kind = GCC_C_SYMBOL_FUNCTION; break; case mst_text_gnu_ifunc: - type = objfile_type (objfile)->nodebug_text_gnu_ifunc_symbol; + type = builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol; kind = GCC_C_SYMBOL_FUNCTION; addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr); break; @@ -293,17 +293,17 @@ convert_symbol_bmsym (compile_c_instance *context, case mst_file_data: case mst_bss: case mst_file_bss: - type = objfile_type (objfile)->nodebug_data_symbol; + type = builtin_type (objfile)->nodebug_data_symbol; kind = GCC_C_SYMBOL_VARIABLE; break; case mst_slot_got_plt: - type = objfile_type (objfile)->nodebug_got_plt_symbol; + type = builtin_type (objfile)->nodebug_got_plt_symbol; kind = GCC_C_SYMBOL_FUNCTION; break; default: - type = objfile_type (objfile)->nodebug_unknown_symbol; + type = builtin_type (objfile)->nodebug_unknown_symbol; kind = GCC_C_SYMBOL_VARIABLE; break; } diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 02b7b898a64..5e504ac839d 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -291,14 +291,14 @@ convert_symbol_bmsym (compile_cplus_instance *instance, case mst_text: case mst_file_text: case mst_solib_trampoline: - type = objfile_type (objfile)->nodebug_text_symbol; + type = builtin_type (objfile)->nodebug_text_symbol; kind = GCC_CP_SYMBOL_FUNCTION; break; case mst_text_gnu_ifunc: /* nodebug_text_gnu_ifunc_symbol would cause: function return type cannot be function */ - type = objfile_type (objfile)->nodebug_text_symbol; + type = builtin_type (objfile)->nodebug_text_symbol; kind = GCC_CP_SYMBOL_FUNCTION; addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr); break; @@ -307,17 +307,17 @@ convert_symbol_bmsym (compile_cplus_instance *instance, case mst_file_data: case mst_bss: case mst_file_bss: - type = objfile_type (objfile)->nodebug_data_symbol; + type = builtin_type (objfile)->nodebug_data_symbol; kind = GCC_CP_SYMBOL_VARIABLE; break; case mst_slot_got_plt: - type = objfile_type (objfile)->nodebug_got_plt_symbol; + type = builtin_type (objfile)->nodebug_got_plt_symbol; kind = GCC_CP_SYMBOL_FUNCTION; break; default: - type = objfile_type (objfile)->nodebug_unknown_symbol; + type = builtin_type (objfile)->nodebug_unknown_symbol; kind = GCC_CP_SYMBOL_VARIABLE; break; } diff --git a/gdb/ctfread.c b/gdb/ctfread.c index d1a57d77a50..42f2da7a88f 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -410,7 +410,7 @@ ctf_add_member_cb (const char *name, if (t == nullptr) { complaint (_("ctf_add_member_cb: %s has NO type (%ld)"), name, tid); - t = objfile_type (ccp->of)->builtin_error; + t = builtin_type (ccp->of)->builtin_error; set_tid_type (ccp->of, tid, t); } } @@ -501,7 +501,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) break; case CTF_K_CONST: if (sym->type ()->code () == TYPE_CODE_VOID) - sym->set_type (objfile_type (objfile)->builtin_int); + sym->set_type (builtin_type (objfile)->builtin_int); break; case CTF_K_TYPEDEF: case CTF_K_INTEGER: @@ -717,7 +717,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) type->set_fields ((struct field *) TYPE_ZALLOC (type, argc * sizeof (struct field))); - struct type *void_type = objfile_type (of)->builtin_void; + struct type *void_type = builtin_type (of)->builtin_void; /* If failed to find the argument type, fill it with void_type. */ for (int iparam = 0; iparam < argc; iparam++) { @@ -829,7 +829,7 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) idx_type = fetch_tid_type (ccp, ar.ctr_index); if (idx_type == nullptr) - idx_type = objfile_type (objfile)->builtin_int; + idx_type = builtin_type (objfile)->builtin_int; type_allocator alloc (objfile); range_type = create_static_range_type (alloc, idx_type, 0, ar.ctr_nelems - 1); @@ -863,7 +863,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_const_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0); @@ -887,7 +887,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_volatile_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } @@ -913,7 +913,7 @@ read_restrict_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (base_type == nullptr) { complaint (_("read_restrict_type: NULL base type (%ld)"), btid); - base_type = objfile_type (objfile)->builtin_error; + base_type = builtin_type (objfile)->builtin_error; } } cv_type = make_restrict_type (base_type); @@ -959,7 +959,7 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (target_type == nullptr) { complaint (_("read_pointer_type: NULL target type (%ld)"), btid); - target_type = objfile_type (ccp->of)->builtin_error; + target_type = builtin_type (ccp->of)->builtin_error; } } @@ -1167,7 +1167,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) if (type == nullptr) { complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id); - type = objfile_type (ccp->of)->builtin_error; + type = builtin_type (ccp->of)->builtin_error; } sym = new (&ccp->of->objfile_obstack) symbol; OBJSTAT (ccp->of, n_syms++); diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 9c1691c90e9..89de40daab0 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -107,7 +107,7 @@ struct type * dwarf2_cu::addr_type () const { struct objfile *objfile = this->per_objfile->objfile; - struct type *void_type = objfile_type (objfile)->builtin_void; + struct type *void_type = builtin_type (objfile)->builtin_void; struct type *addr_type = lookup_pointer_type (void_type); int addr_size = this->per_cu->addr_size (); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index b1c895f0576..5c7283cd514 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13655,7 +13655,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) arrays with unspecified length. */ if (die->child == NULL) { - index_type = objfile_type (objfile)->builtin_int; + index_type = builtin_type (objfile)->builtin_int; type_allocator alloc (objfile); range_type = create_static_range_type (alloc, index_type, 0, -1); type = create_array_type_with_stride (alloc, element_type, range_type, @@ -14006,7 +14006,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) } } - sym = new_symbol (die, objfile_type (objfile)->builtin_void, cu); + sym = new_symbol (die, builtin_type (objfile)->builtin_void, cu); sym->set_value_common_block (common_block); } } @@ -14499,7 +14499,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) length = 1; } - index_type = objfile_type (objfile)->builtin_int; + index_type = builtin_type (objfile)->builtin_int; type_allocator alloc (objfile); if (length_is_constant) range_type = create_static_range_type (alloc, index_type, 1, length); @@ -14604,7 +14604,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) if (die->child != NULL) { - struct type *void_type = objfile_type (objfile)->builtin_void; + struct type *void_type = builtin_type (objfile)->builtin_void; struct die_info *child_die; int nparams, iparams; @@ -15045,7 +15045,7 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile, at least versions 14, 17, and 18. */ if (bits == 0 && producer_is_icc (cu) && name != nullptr && strcmp (name, "void") == 0) - type = objfile_type (objfile)->builtin_void; + type = builtin_type (objfile)->builtin_void; else { type_allocator alloc (objfile); @@ -18887,7 +18887,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, } else sym->set_aclass_index (LOC_OPTIMIZED_OUT); - sym->set_type (objfile_type (objfile)->builtin_core_addr); + sym->set_type (builtin_type (objfile)->builtin_core_addr); sym->set_domain (LABEL_DOMAIN); add_symbol_to_list (sym, cu->list_in_scope); break; @@ -18930,7 +18930,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, variables with missing type entries. Change the misleading `void' type to something sensible. */ if (sym->type ()->code () == TYPE_CODE_VOID) - sym->set_type (objfile_type (objfile)->builtin_int); + sym->set_type (builtin_type (objfile)->builtin_int); attr = dwarf2_attr (die, DW_AT_const_value, cu); /* In the case of DW_TAG_member, we should only be called for @@ -19397,7 +19397,7 @@ die_type (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_objfile->objfile; /* A missing DW_AT_type represents a void type. */ - return objfile_type (objfile)->builtin_void; + return builtin_type (objfile)->builtin_void; } return lookup_die_type (die, type_attr, cu); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index a167308dc8f..000e210940c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -6085,7 +6085,7 @@ static const registry::keysc) || sh->sc == scNil || sh->index == indexNil) - s->set_type (objfile_type (objfile)->nodebug_data_symbol); + s->set_type (builtin_type (objfile)->nodebug_data_symbol); else s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name)); /* Value of a data symbol is its memory address. */ @@ -715,7 +715,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s->set_aclass_index (LOC_LABEL); /* but not misused. */ s->set_section_index (section_index); s->set_value_address (sh->value); - s->set_type (objfile_type (objfile)->builtin_int); + s->set_type (builtin_type (objfile)->builtin_int); add_symbol (s, top_stack->cur_st, top_stack->cur_block); break; @@ -758,7 +758,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s->set_section_index (section_index); /* Type of the return value. */ if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil) - t = objfile_type (objfile)->builtin_int; + t = builtin_type (objfile)->builtin_int; else { t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name); @@ -1167,7 +1167,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s = new_symbol (MDEBUG_EFI_SYMBOL_NAME); s->set_domain (LABEL_DOMAIN); s->set_aclass_index (LOC_CONST); - s->set_type (objfile_type (mdebugread_objfile)->builtin_void); + s->set_type (builtin_type (mdebugread_objfile)->builtin_void); e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack, mdebug_extra_func_info); s->set_value_bytes ((gdb_byte *) e); @@ -1391,12 +1391,12 @@ basic_type (int bt, struct objfile *objfile) switch (bt) { case btNil: - tp = objfile_type (objfile)->builtin_void; + tp = builtin_type (objfile)->builtin_void; break; case btAdr: tp = init_pointer_type (alloc, 32, "adr_32", - objfile_type (objfile)->builtin_void); + builtin_type (objfile)->builtin_void); break; case btChar: @@ -1470,7 +1470,7 @@ basic_type (int bt, struct objfile *objfile) break; case btVoid: - tp = objfile_type (objfile)->builtin_void; + tp = builtin_type (objfile)->builtin_void; break; case btLong64: @@ -1491,7 +1491,7 @@ basic_type (int bt, struct objfile *objfile) case btAdr64: tp = init_pointer_type (alloc, 64, "adr_64", - objfile_type (objfile)->builtin_void); + builtin_type (objfile)->builtin_void); break; case btInt64: @@ -1851,7 +1851,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend, { complaint (_("illegal array index type for %s, assuming int"), sym_name); - indx = objfile_type (mdebugread_objfile)->builtin_int; + indx = builtin_type (mdebugread_objfile)->builtin_int; } /* Get the bounds, and create the array type. */ @@ -2003,7 +2003,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab, SYMBOL_CLASS (s) = LOC_BLOCK; /* Don't know its type, hope int is ok. */ s->type () - = lookup_function_type (objfile_type (pst->objfile)->builtin_int); + = lookup_function_type (builtin_type (pst->objfile)->builtin_int); add_symbol (s, top_stack->cur_st, top_stack->cur_block); /* Won't have symbols for this one. */ b = new_block (2); @@ -2057,7 +2057,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab, if (processing_gcc_compilation == 0 && found_ecoff_debugging_info == 0 && s->type ()->target_type ()->code () == TYPE_CODE_VOID) - s->set_type (objfile_type (mdebugread_objfile)->nodebug_text_symbol); + s->set_type (builtin_type (mdebugread_objfile)->nodebug_text_symbol); } /* Parse the external symbol ES. Just call parse_symbol() after @@ -3972,7 +3972,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) s->set_domain (LABEL_DOMAIN); s->set_aclass_index (LOC_CONST); - s->set_type (objfile_type (objfile)->builtin_void); + s->set_type (builtin_type (objfile)->builtin_void); s->set_value_bytes ((gdb_byte *) e); e->pdr.framereg = -1; add_symbol_to_list (s, get_local_symbols ()); diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 21ec8c7ad2e..9caebfefd59 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1314,8 +1314,8 @@ objfile_int_type (struct objfile *of, int size_in_bytes, bool unsigned_p) /* Helper macro to examine the various builtin types. */ #define TRY_TYPE(F) \ int_type = (unsigned_p \ - ? objfile_type (of)->builtin_unsigned_ ## F \ - : objfile_type (of)->builtin_ ## F); \ + ? builtin_type (of)->builtin_unsigned_ ## F \ + : builtin_type (of)->builtin_ ## F); \ if (int_type != NULL && int_type->length () == size_in_bytes) \ return int_type diff --git a/gdb/parse.c b/gdb/parse.c index b2cc6c59fb5..24db3ca57d9 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -142,7 +142,7 @@ find_minsym_type_and_address (minimal_symbol *msymbol, /* Skip translation if caller does not need the address. */ if (address_p != NULL) *address_p = target_translate_tls_address (objfile, addr); - return objfile_type (objfile)->nodebug_tls_symbol; + return builtin_type (objfile)->nodebug_tls_symbol; } if (address_p != NULL) @@ -153,22 +153,22 @@ find_minsym_type_and_address (minimal_symbol *msymbol, case mst_text: case mst_file_text: case mst_solib_trampoline: - return objfile_type (objfile)->nodebug_text_symbol; + return builtin_type (objfile)->nodebug_text_symbol; case mst_text_gnu_ifunc: - return objfile_type (objfile)->nodebug_text_gnu_ifunc_symbol; + return builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol; case mst_data: case mst_file_data: case mst_bss: case mst_file_bss: - return objfile_type (objfile)->nodebug_data_symbol; + return builtin_type (objfile)->nodebug_data_symbol; case mst_slot_got_plt: - return objfile_type (objfile)->nodebug_got_plt_symbol; + return builtin_type (objfile)->nodebug_got_plt_symbol; default: - return objfile_type (objfile)->nodebug_unknown_symbol; + return builtin_type (objfile)->nodebug_unknown_symbol; } } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 89d778db1c2..c3d87033f4f 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -311,7 +311,7 @@ dbx_lookup_type (int typenums[2], struct objfile *objfile) warning (_("GDB internal error: bad real_filenum")); error_return: - temp_type = objfile_type (objfile)->builtin_error; + temp_type = builtin_type (objfile)->builtin_error; return &temp_type; } @@ -798,7 +798,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, gdb_byte *dbl_valu; struct type *dbl_type; - dbl_type = objfile_type (objfile)->builtin_double; + dbl_type = builtin_type (objfile)->builtin_double; dbl_valu = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, dbl_type->length ()); @@ -819,7 +819,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, types; other languages probably should have at least unsigned as well as signed constants. */ - sym->set_type (objfile_type (objfile)->builtin_long); + sym->set_type (builtin_type (objfile)->builtin_long); sym->set_value_longest (atoi (p)); sym->set_aclass_index (LOC_CONST); } @@ -827,7 +827,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, case 'c': { - sym->set_type (objfile_type (objfile)->builtin_char); + sym->set_type (builtin_type (objfile)->builtin_char); sym->set_value_longest (atoi (p)); sym->set_aclass_index (LOC_CONST); } @@ -880,10 +880,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, type_allocator alloc (objfile); range_type = create_static_range_type (alloc, - objfile_type (objfile)->builtin_int, + builtin_type (objfile)->builtin_int, 0, ind); sym->set_type - (create_array_type (alloc, objfile_type (objfile)->builtin_char, + (create_array_type (alloc, builtin_type (objfile)->builtin_char, range_type)); string_value = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, ind + 1); @@ -1002,7 +1002,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, it back into builtin_int here. FIXME: Do we need a new builtin_promoted_int_arg ? */ if (ptype->code () == TYPE_CODE_VOID) - ptype = objfile_type (objfile)->builtin_int; + ptype = builtin_type (objfile)->builtin_int; ftype->field (nparams).set_type (ptype); TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0; } @@ -1094,8 +1094,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, { sym->set_type (sym->type ()->is_unsigned () - ? objfile_type (objfile)->builtin_unsigned_int - : objfile_type (objfile)->builtin_int); + ? builtin_type (objfile)->builtin_unsigned_int + : builtin_type (objfile)->builtin_int); } break; } @@ -1462,7 +1462,7 @@ error_type (const char **pp, struct objfile *objfile) break; } } - return objfile_type (objfile)->builtin_error; + return builtin_type (objfile)->builtin_error; } @@ -2063,7 +2063,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED) { complaint (_("Unknown builtin type %d"), typenum); - return objfile_type (objfile)->builtin_error; + return builtin_type (objfile)->builtin_error; } if (!negative_types) @@ -4172,7 +4172,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, handle_true_range: if (self_subrange) - index_type = objfile_type (objfile)->builtin_int; + index_type = builtin_type (objfile)->builtin_int; else index_type = *dbx_lookup_type (rangenums, objfile); if (index_type == NULL) @@ -4182,7 +4182,7 @@ read_range_type (const char **pp, int typenums[2], int type_size, complaint (_("base type %d of range type is not defined"), rangenums[1]); - index_type = objfile_type (objfile)->builtin_int; + index_type = builtin_type (objfile)->builtin_int; } result_type diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 72c0a0db49a..3c2618d93fc 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1485,7 +1485,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile) patch_block_stabs (), unless the file was compiled without -g. */ sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced)); - sym->set_type (objfile_type (objfile)->nodebug_text_symbol); + sym->set_type (builtin_type (objfile)->nodebug_text_symbol); sym->set_aclass_index (LOC_BLOCK); sym2 = new (&objfile->objfile_obstack) symbol (*sym); @@ -1498,7 +1498,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile) else { /* In case we can't figure out the type, provide default. */ - sym->set_type (objfile_type (objfile)->nodebug_data_symbol); + sym->set_type (builtin_type (objfile)->nodebug_data_symbol); switch (cs->c_sclass) { From patchwork Mon Mar 13 22:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66344 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 09569383E6A9 for ; Mon, 13 Mar 2023 22:10:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id E9366385840A for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9366385840A 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 55DE11004CA48 for ; Mon, 13 Mar 2023 22:08:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKvpMgHJTdYmbqKvpNc9P; Mon, 13 Mar 2023 22:08:09 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=D8CCltdj c=1 sm=1 tr=0 ts=640f9ec9 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=1g8rvV1u6asfyHO740cA: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=C4KJk8KBeWst3dPrf8A/71NsohngJWqooQTYz53R12o=; b=WyM8JC1iQNMPQpCywGTulDmnKV XbF54ElM6xnPQot+7KVg9SEkERQd2eb3JIXfM3bO/HJatmhudNXUZGF4owrtHu5Fi5Aqb/dpqLk2h SKTJMGP32mtsOVowl6CTWSOsr; 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 1pbqKv-000u2m-4y for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:09 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:19 -0600 Subject: [PATCH 19/20] Add some types to struct builtin_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-19-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: 1pbqKv-000u2m-4y 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: 20 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.4 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 adds some types to struct builtin_type, ensuring it contains all the types currently used by objfile_type. --- gdb/gdbtypes.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbtypes.h | 15 +++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 000e210940c..8fff30f9409 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -6062,6 +6062,56 @@ create_gdbtypes_data (struct gdbarch *gdbarch) builtin_type->xmethod = alloc.new_type (TYPE_CODE_XMETHOD, 0, ""); + /* This type represents a type that was unrecognized in symbol read-in. */ + builtin_type->builtin_error + = alloc.new_type (TYPE_CODE_ERROR, 0, ""); + + /* The following set of types is used for symbols with no + debug information. */ + builtin_type->nodebug_text_symbol + = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, + ""); + + builtin_type->nodebug_text_gnu_ifunc_symbol + = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, + ""); + builtin_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true); + + builtin_type->nodebug_got_plt_symbol + = init_pointer_type (alloc, gdbarch_addr_bit (gdbarch), + "", + builtin_type->nodebug_text_symbol); + builtin_type->nodebug_data_symbol + = alloc.new_type (TYPE_CODE_ERROR, 0, ""); + builtin_type->nodebug_unknown_symbol + = alloc.new_type (TYPE_CODE_ERROR, 0, + ""); + builtin_type->nodebug_tls_symbol + = alloc.new_type (TYPE_CODE_ERROR, 0, + ""); + + /* NOTE: on some targets, addresses and pointers are not necessarily + the same. + + The upshot is: + - gdb's `struct type' always describes the target's + representation. + - gdb's `struct value' objects should always hold values in + target form. + - gdb's CORE_ADDR values are addresses in the unified virtual + address space that the assembler and linker work with. Thus, + since target_read_memory takes a CORE_ADDR as an argument, it + can access any memory on the target, even if the processor has + separate code and data address spaces. + + In this context, builtin_type->builtin_core_addr is a bit odd: + it's a target type for a value the target will never see. It's + only used to hold the values of (typeless) linker symbols, which + are indeed in the unified virtual address space. */ + + builtin_type->builtin_core_addr + = init_integer_type (alloc, gdbarch_addr_bit (gdbarch), 1, + "__CORE_ADDR"); return builtin_type; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 8a0c57b7a05..34bec887676 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2098,6 +2098,21 @@ struct builtin_type /* * This type is used to represent an xmethod. */ struct type *xmethod = nullptr; + + /* * This type is used to represent symbol addresses. */ + struct type *builtin_core_addr = nullptr; + + /* * This type represents a type that was unrecognized in symbol + read-in. */ + struct type *builtin_error = nullptr; + + /* * Types used for symbols with no debug information. */ + struct type *nodebug_text_symbol = nullptr; + struct type *nodebug_text_gnu_ifunc_symbol = nullptr; + struct type *nodebug_got_plt_symbol = nullptr; + struct type *nodebug_data_symbol = nullptr; + struct type *nodebug_unknown_symbol = nullptr; + struct type *nodebug_tls_symbol = nullptr; }; /* * Return the type table for the specified architecture. */ From patchwork Mon Mar 13 22:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66346 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 E3AD03857026 for ; Mon, 13 Mar 2023 22:10:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 1BE8E385840E for ; Mon, 13 Mar 2023 22:08:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BE8E385840E 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 7AA3F1003BDF9 for ; Mon, 13 Mar 2023 22:08:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKvpMgHTTdYmbqKvpNc9b; Mon, 13 Mar 2023 22:08:09 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=D8CCltdj c=1 sm=1 tr=0 ts=640f9ec9 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=nppUT4mz0vpzdv2uRjEA: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=a1mwEEiadCMssx5BBwcstHaYQudJl9uuoRugLbdcLME=; b=fHRyJ52JdLs+ODHSHOtQPQPa6w /EtHwQsSn30xhvpnQ/+pUkYwFmzFfMFMU4v9wobyfsWUZHb2RkKrv97gUI/NtB7x567D5TT/8BEQI y1OYHWdXkUrMgIEW7PWBKf8Qm; 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 1pbqKv-000u2m-9d for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:09 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:20 -0600 Subject: [PATCH 20/20] Remove objfile_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-20-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: 1pbqKv-000u2m-9d 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: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.4 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 objfile_type, in favor of always using the per-arch builtins. --- gdb/gdbtypes.c | 124 +-------------------------------------------------------- gdb/gdbtypes.h | 40 +------------------ 2 files changed, 3 insertions(+), 161 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 8fff30f9409..e3257aa3c4e 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -6127,130 +6127,10 @@ builtin_type (struct gdbarch *gdbarch) return result; } -/* This set of objfile-based types is intended to be used by symbol - readers as basic types. */ - -static const registry::key> - objfile_type_data; - -const struct objfile_type * +const struct builtin_type * builtin_type (struct objfile *objfile) { - struct gdbarch *gdbarch; - struct objfile_type *objfile_type = objfile_type_data.get (objfile); - - if (objfile_type) - return objfile_type; - - objfile_type = OBSTACK_CALLOC (&objfile->objfile_obstack, - 1, struct objfile_type); - - /* Use the objfile architecture to determine basic type properties. */ - gdbarch = objfile->arch (); - - type_allocator alloc (objfile); - - /* Basic types. */ - objfile_type->builtin_void - = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - objfile_type->builtin_char - = init_integer_type (alloc, TARGET_CHAR_BIT, - !gdbarch_char_signed (gdbarch), "char"); - objfile_type->builtin_char->set_has_no_signedness (true); - objfile_type->builtin_signed_char - = init_integer_type (alloc, TARGET_CHAR_BIT, - 0, "signed char"); - objfile_type->builtin_unsigned_char - = init_integer_type (alloc, TARGET_CHAR_BIT, - 1, "unsigned char"); - objfile_type->builtin_short - = init_integer_type (alloc, gdbarch_short_bit (gdbarch), - 0, "short"); - objfile_type->builtin_unsigned_short - = init_integer_type (alloc, gdbarch_short_bit (gdbarch), - 1, "unsigned short"); - objfile_type->builtin_int - = init_integer_type (alloc, gdbarch_int_bit (gdbarch), - 0, "int"); - objfile_type->builtin_unsigned_int - = init_integer_type (alloc, gdbarch_int_bit (gdbarch), - 1, "unsigned int"); - objfile_type->builtin_long - = init_integer_type (alloc, gdbarch_long_bit (gdbarch), - 0, "long"); - objfile_type->builtin_unsigned_long - = init_integer_type (alloc, gdbarch_long_bit (gdbarch), - 1, "unsigned long"); - objfile_type->builtin_long_long - = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), - 0, "long long"); - objfile_type->builtin_unsigned_long_long - = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), - 1, "unsigned long long"); - objfile_type->builtin_float - = init_float_type (alloc, gdbarch_float_bit (gdbarch), - "float", gdbarch_float_format (gdbarch)); - objfile_type->builtin_double - = init_float_type (alloc, gdbarch_double_bit (gdbarch), - "double", gdbarch_double_format (gdbarch)); - objfile_type->builtin_long_double - = init_float_type (alloc, gdbarch_long_double_bit (gdbarch), - "long double", gdbarch_long_double_format (gdbarch)); - - /* This type represents a type that was unrecognized in symbol read-in. */ - objfile_type->builtin_error - = alloc.new_type (TYPE_CODE_ERROR, 0, ""); - - /* The following set of types is used for symbols with no - debug information. */ - objfile_type->nodebug_text_symbol - = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, - ""); - - objfile_type->nodebug_text_gnu_ifunc_symbol - = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT, - ""); - objfile_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true); - - objfile_type->nodebug_got_plt_symbol - = init_pointer_type (alloc, gdbarch_addr_bit (gdbarch), - "", - objfile_type->nodebug_text_symbol); - objfile_type->nodebug_data_symbol - = alloc.new_type (TYPE_CODE_ERROR, 0, ""); - objfile_type->nodebug_unknown_symbol - = alloc.new_type (TYPE_CODE_ERROR, 0, - ""); - objfile_type->nodebug_tls_symbol - = alloc.new_type (TYPE_CODE_ERROR, 0, - ""); - - /* NOTE: on some targets, addresses and pointers are not necessarily - the same. - - The upshot is: - - gdb's `struct type' always describes the target's - representation. - - gdb's `struct value' objects should always hold values in - target form. - - gdb's CORE_ADDR values are addresses in the unified virtual - address space that the assembler and linker work with. Thus, - since target_read_memory takes a CORE_ADDR as an argument, it - can access any memory on the target, even if the processor has - separate code and data address spaces. - - In this context, objfile_type->builtin_core_addr is a bit odd: - it's a target type for a value the target will never see. It's - only used to hold the values of (typeless) linker symbols, which - are indeed in the unified virtual address space. */ - - objfile_type->builtin_core_addr - = init_integer_type (alloc, gdbarch_addr_bit (gdbarch), 1, - "__CORE_ADDR"); - - objfile_type_data.set (objfile, objfile_type); - return objfile_type; + return builtin_type (objfile->arch ()); } /* See gdbtypes.h. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 34bec887676..261975f2df1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2119,47 +2119,9 @@ struct builtin_type extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch); -/* * Per-objfile types used by symbol readers. */ - -struct objfile_type -{ - /* Basic types based on the objfile architecture. */ - struct type *builtin_void; - struct type *builtin_char; - struct type *builtin_short; - struct type *builtin_int; - struct type *builtin_long; - struct type *builtin_long_long; - struct type *builtin_signed_char; - struct type *builtin_unsigned_char; - struct type *builtin_unsigned_short; - struct type *builtin_unsigned_int; - struct type *builtin_unsigned_long; - struct type *builtin_unsigned_long_long; - struct type *builtin_half; - struct type *builtin_float; - struct type *builtin_double; - struct type *builtin_long_double; - - /* * This type is used to represent symbol addresses. */ - struct type *builtin_core_addr; - - /* * This type represents a type that was unrecognized in symbol - read-in. */ - struct type *builtin_error; - - /* * Types used for symbols with no debug information. */ - struct type *nodebug_text_symbol; - struct type *nodebug_text_gnu_ifunc_symbol; - struct type *nodebug_got_plt_symbol; - struct type *nodebug_data_symbol; - struct type *nodebug_unknown_symbol; - struct type *nodebug_tls_symbol; -}; - /* * Return the type table for the specified objfile. */ -extern const struct objfile_type *builtin_type (struct objfile *objfile); +extern const struct builtin_type *builtin_type (struct objfile *objfile); /* Explicit floating-point formats. See "floatformat.h". */ extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];