public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 16/20] Use type allocator for set types
Date: Mon, 13 Mar 2023 16:08:16 -0600	[thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-16-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>

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.
---
 gdb/dwarf2/read.c |  3 ++-
 gdb/gdbtypes.c    |  5 ++---
 gdb/gdbtypes.h    |  2 +-
 gdb/stabsread.c   | 11 +++++++----
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index db5606c31cf..b1c895f0576 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 026f6492398..8093a3911d7 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1446,10 +1446,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 c1964b42e67..46261bbe4df 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2533,7 +2533,7 @@ extern struct type *create_string_type (type_allocator &, struct type *,
 
 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 &, struct 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 @@ read_type (const char **pp, struct objfile *objfile)
       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:

-- 
2.39.1


  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 ` [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 ` Tom Tromey [this message]
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-16-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).