aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-03-13 08:56:13 -0600
committerTom Tromey <tom@tromey.com>2023-03-18 11:12:37 -0600
commitc9eb9f185472eef2e87684bed63424947f77b386 (patch)
tree8a9ca9f62faae6eb2bdc03af669663334e61f42a
parent6a4d297c62ce68a833814b9cf84626c42fc0cf78 (diff)
downloadgdb-c9eb9f185472eef2e87684bed63424947f77b386.zip
gdb-c9eb9f185472eef2e87684bed63424947f77b386.tar.gz
gdb-c9eb9f185472eef2e87684bed63424947f77b386.tar.bz2
Remove alloc_type_arch
This removes alloc_type_arch, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r--gdb/gdbtypes.c37
-rw-r--r--gdb/gdbtypes.h2
2 files changed, 4 insertions, 35 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 5bb4906..1e880ed 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 613c22d..861d002 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