From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 List-Id: 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); -- 2.39.1