[binutils-gdb] Use type allocator for set types
Tom Tromey
tromey@sourceware.org
Sat Mar 18 17:20:32 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=526648585ca87251acdda0a271f7c4b4591231ae
commit 526648585ca87251acdda0a271f7c4b4591231ae
Author: Tom Tromey <tom@tromey.com>
Date: Mon Mar 13 13:25:41 2023 -0600
Use type allocator for set types
This changes the set type creation function to accept a type
allocator, and updates all the callers. Note that symbol readers
should generally allocate on the relevant objfile, regardless of the
underlying type of the set, which is what this patch implements.
Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
Diff:
---
gdb/dwarf2/read.c | 3 ++-
gdb/gdbtypes.c | 5 ++---
gdb/gdbtypes.h | 3 ++-
gdb/stabsread.c | 11 +++++++----
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3019bbd78b0..e1ae98fe910 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13825,7 +13825,8 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu)
if (set_type)
return set_type;
- set_type = create_set_type (NULL, domain_type);
+ type_allocator alloc (cu->per_objfile->objfile);
+ set_type = create_set_type (alloc, domain_type);
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr != nullptr && attr->form_is_unsigned ())
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 3c2fdc625e4..1b0adbdbe05 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1445,10 +1445,9 @@ lookup_string_range_type (struct type *string_char_type,
}
struct type *
-create_set_type (struct type *result_type, struct type *domain_type)
+create_set_type (type_allocator &alloc, struct type *domain_type)
{
- if (result_type == NULL)
- result_type = type_allocator (domain_type).new_type ();
+ struct type *result_type = alloc.new_type ();
result_type->set_code (TYPE_CODE_SET);
result_type->set_num_fields (1);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index e664c2c35ef..f26eff4770e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2547,7 +2547,8 @@ extern struct type *create_string_type (type_allocator &alloc,
extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
-extern struct type *create_set_type (struct type *, struct type *);
+extern struct type *create_set_type (type_allocator &alloc,
+ struct type *domain_type);
extern struct type *lookup_unsigned_typename (const struct language_defn *,
const char *);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index c8c49e15403..89d778db1c2 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2016,10 +2016,13 @@ again:
break;
case 'S': /* Set type */
- type1 = read_type (pp, objfile);
- type = create_set_type (NULL, type1);
- if (typenums[0] != -1)
- *dbx_lookup_type (typenums, objfile) = type;
+ {
+ type1 = read_type (pp, objfile);
+ type_allocator alloc (objfile);
+ type = create_set_type (alloc, type1);
+ if (typenums[0] != -1)
+ *dbx_lookup_type (typenums, objfile) = type;
+ }
break;
default:
More information about the Gdb-cvs
mailing list