From 8a17bdd9ccc26a7a0a2a208a9b870512b2490324 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 13 Mar 2023 09:01:08 -0600 Subject: Remove alloc_type This removes alloc_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi --- 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(-) (limited to 'gdb') diff --git a/gdb/coffread.c b/gdb/coffread.c index fe1ee50..1b0442a 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 69906c9..94597af 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 a1c7565..d5e8bfe 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 6ad6aad..3d1d923 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 03f9470..c052b74 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 bc46609..9e55999 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4727,7 +4727,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 cfe2453..8eac7ab 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); -- cgit v1.1