From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 04/20] Remove alloc_type
Date: Mon, 13 Mar 2023 16:08:04 -0600 [thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-4-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>
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
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 ` [PATCH 02/20] Remove alloc_type_arch Tom Tromey
2023-03-13 22:08 ` [PATCH 03/20] Remove alloc_type_copy Tom Tromey
2023-03-13 22:08 ` Tom Tromey [this message]
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-4-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).