From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 List-Id: 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. -- 2.39.1