From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 02/20] Remove alloc_type_arch
Date: Mon, 13 Mar 2023 16:08:02 -0600 [thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-2-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>
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
--
2.39.1
next prev parent reply other threads:[~2023-03-13 22:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 22:08 [PATCH 00/20] Remove objfile_type Tom Tromey
2023-03-13 22:08 ` [PATCH 01/20] Introduce type_allocator Tom Tromey
2023-03-13 22:08 ` Tom Tromey [this message]
2023-03-13 22:08 ` [PATCH 03/20] Remove alloc_type_copy Tom Tromey
2023-03-13 22:08 ` [PATCH 04/20] Remove alloc_type Tom Tromey
2023-03-13 22:08 ` [PATCH 05/20] Reuse existing builtin types Tom Tromey
2023-03-13 22:08 ` [PATCH 06/20] Remove arch_type Tom Tromey
2023-03-13 22:08 ` [PATCH 07/20] Remove init_type Tom Tromey
2023-03-13 22:08 ` [PATCH 08/20] Unify arch_integer_type and init_integer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 09/20] Unify arch_character_type and init_character_type Tom Tromey
2023-03-13 22:08 ` [PATCH 10/20] Unify arch_boolean_type and init_boolean_type Tom Tromey
2023-03-13 22:08 ` [PATCH 11/20] Unify arch_float_type and init_float_type Tom Tromey
2023-03-13 22:08 ` [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type Tom Tromey
2023-03-13 22:08 ` [PATCH 13/20] Unify arch_pointer_type and init_pointer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 14/20] Use type allocator for range types Tom Tromey
2023-03-14 14:41 ` Simon Marchi
2023-03-18 15:56 ` Tom Tromey
2023-03-13 22:08 ` [PATCH 15/20] Use type allocator for array types Tom Tromey
2023-03-13 22:08 ` [PATCH 16/20] Use type allocator for set types Tom Tromey
2023-03-13 22:08 ` [PATCH 17/20] Use builtin type when appropriate Tom Tromey
2023-03-13 22:08 ` [PATCH 18/20] Rename objfile_type to builtin_type Tom Tromey
2023-03-13 22:08 ` [PATCH 19/20] Add some types to struct builtin_type Tom Tromey
2023-03-13 22:08 ` [PATCH 20/20] Remove objfile_type Tom Tromey
2023-03-14 14:48 ` [PATCH 00/20] " Simon Marchi
2023-03-18 15:57 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230313-split-objfile-type-allocator-2-v1-2-69ba773ac17b@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).