]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Unify arch_pointer_type and init_pointer_type
authorTom Tromey <tom@tromey.com>
Mon, 13 Mar 2023 18:25:27 +0000 (12:25 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 18 Mar 2023 17:12:38 +0000 (11:12 -0600)
This unifies arch_pointer_type and init_pointer_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
gdb/avr-tdep.c
gdb/dwarf2/read.c
gdb/ft32-tdep.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/m32c-tdep.c
gdb/mdebugread.c
gdb/rl78-tdep.c
gdb/windows-tdep.c
gdb/z80-tdep.c

index f9f498bfed2e59581142b126e47f4cf719f0e7c5..ce2262c5b1a0a702aee2068f60fd2cc466f1ff6a 100644 (file)
@@ -1476,7 +1476,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   type_allocator alloc (gdbarch);
   tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->func_void_type = make_function_type (tdep->void_type, NULL);
-  tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
+  tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL,
                                     tdep->func_void_type);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
index c68247557977e1d3ed90fe80813b975634290a25..4279f392a0703b87057c5885fe8acad55889e64d 100644 (file)
@@ -15229,7 +15229,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
       case DW_ATE_address:
        /* Turn DW_ATE_address into a void * pointer.  */
        type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
-       type = init_pointer_type (objfile, bits, name, type);
+       type = init_pointer_type (alloc, bits, name, type);
        break;
       case DW_ATE_boolean:
        type = init_boolean_type (alloc, bits, 1, name);
index 7182185313f9807ea588e048ee96de1bd7285412..cac4b9ba6a298561c6d314ba859a42bf3c67bd14 100644 (file)
@@ -576,7 +576,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   type_allocator alloc (gdbarch);
   void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   func_void_type = make_function_type (void_type, NULL);
-  tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
+  tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL,
                                     func_void_type);
   tdep->pc_type->set_instance_flags (tdep->pc_type->instance_flags ()
                                     | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1);
index df10ffea38301d8da0c61a638876589a5a376ca0..103818fae9beccf1f7f7018ece7718b911ba07bd 100644 (file)
@@ -3526,18 +3526,15 @@ init_complex_type (const char *name, struct type *target_type)
   return TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type;
 }
 
-/* Allocate a TYPE_CODE_PTR type structure associated with OBJFILE.
-   BIT is the pointer type size in bits.  NAME is the type name.
-   TARGET_TYPE is the pointer target type.  Always sets the pointer type's
-   TYPE_UNSIGNED flag.  */
+/* See gdbtypes.h.  */
 
 struct type *
-init_pointer_type (struct objfile *objfile,
+init_pointer_type (type_allocator &alloc,
                   int bit, const char *name, struct type *target_type)
 {
   struct type *t;
 
-  t = type_allocator (objfile).new_type (TYPE_CODE_PTR, bit, name);
+  t = alloc.new_type (TYPE_CODE_PTR, bit, name);
   t->set_target_type (target_type);
   t->set_is_unsigned (true);
   return t;
@@ -5740,23 +5737,6 @@ copy_type (const struct type *type)
 \f
 /* Helper functions to initialize architecture-specific types.  */
 
-/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH.
-   BIT is the pointer type size in bits.  NAME is the type name.
-   TARGET_TYPE is the pointer target type.  Always sets the pointer type's
-   TYPE_UNSIGNED flag.  */
-
-struct type *
-arch_pointer_type (struct gdbarch *gdbarch,
-                  int bit, const char *name, struct type *target_type)
-{
-  struct type *t;
-
-  t = type_allocator (gdbarch).new_type (TYPE_CODE_PTR, bit, name);
-  t->set_target_type (target_type);
-  t->set_is_unsigned (true);
-  return t;
-}
-
 /* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
    NAME is the type name.  BIT is the size of the flag word in bits.  */
 
@@ -6227,7 +6207,7 @@ objfile_type (struct objfile *objfile)
   objfile_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true);
 
   objfile_type->nodebug_got_plt_symbol
-    = init_pointer_type (objfile, gdbarch_addr_bit (gdbarch),
+    = init_pointer_type (alloc, gdbarch_addr_bit (gdbarch),
                         "<text from jump slot in .got.plt, no debug info>",
                         objfile_type->nodebug_text_symbol);
   objfile_type->nodebug_data_symbol
index 88a2270b234ba6f97c7753b894e154f64acc5be7..33937dd0fd66d89271b066108546b372a33a1d96 100644 (file)
@@ -2335,15 +2335,19 @@ extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
 
 extern bool can_create_complex_type (struct type *);
 extern struct type *init_complex_type (const char *, struct type *);
-extern struct type *init_pointer_type (struct objfile *, int, const char *,
-                                      struct type *);
+
+/* Allocate a TYPE_CODE_PTR type structure using ALLOC.
+   BIT is the pointer type size in bits.  NAME is the type name.
+   TARGET_TYPE is the pointer target type.  Always sets the pointer type's
+   TYPE_UNSIGNED flag.  */
+
+extern struct type *init_pointer_type (type_allocator &alloc, int bit,
+                                      const char *name,
+                                      struct type *target_type);
+
 extern struct type *init_fixed_point_type (struct objfile *, int, int,
                                           const char *);
 
-/* Helper functions to construct architecture-owned types.  */
-extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
-                                      struct type *);
-
 /* Helper functions to construct a struct or record type.  An
    initially empty type is created using arch_composite_type().
    Fields are then added using append_composite_type_field*().  A union
index 65d5df330b174e55bbe4cd5ae7fe04f2f6a74c96..e06dbbe12bfffa63026b6f6ae07bbeb8b68a505d 100644 (file)
@@ -188,18 +188,19 @@ make_types (struct gdbarch *arch)
   type_allocator alloc (arch);
   tdep->voyd = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->ptr_voyd
-    = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd);
+    = init_pointer_type (alloc, gdbarch_ptr_bit (arch), NULL, tdep->voyd);
   tdep->func_voyd = lookup_function_type (tdep->voyd);
 
   xsnprintf (type_name, sizeof (type_name), "%s_data_addr_t",
             gdbarch_bfd_arch_info (arch)->printable_name);
   tdep->data_addr_reg_type
-    = arch_pointer_type (arch, data_addr_reg_bits, type_name, tdep->voyd);
+    = init_pointer_type (alloc, data_addr_reg_bits, type_name, tdep->voyd);
 
   xsnprintf (type_name, sizeof (type_name), "%s_code_addr_t",
             gdbarch_bfd_arch_info (arch)->printable_name);
   tdep->code_addr_reg_type
-    = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd);
+    = init_pointer_type (alloc, code_addr_reg_bits, type_name,
+                        tdep->func_voyd);
 
   tdep->uint8  = init_integer_type (alloc,  8, 1, "uint8_t");
   tdep->uint16 = init_integer_type (alloc, 16, 1, "uint16_t");
index 64884ac08f9ff8201c50ceb01a7b8c8f9c22817d..0c663cb344695eba23bb362718793ce34436de60 100644 (file)
@@ -1395,7 +1395,7 @@ basic_type (int bt, struct objfile *objfile)
       break;
 
     case btAdr:
-      tp = init_pointer_type (objfile, 32, "adr_32",
+      tp = init_pointer_type (alloc, 32, "adr_32",
                              objfile_type (objfile)->builtin_void);
       break;
 
@@ -1490,7 +1490,7 @@ basic_type (int bt, struct objfile *objfile)
       break;
 
     case btAdr64:
-      tp = init_pointer_type (objfile, 64, "adr_64",
+      tp = init_pointer_type (alloc, 64, "adr_64",
                              objfile_type (objfile)->builtin_void);
       break;
 
index ccb031bbfde09e21acc5d942b1ca767f3883f1a1..d01d1fdf0cd0b39d06755dd70d370030790d6da2 100644 (file)
@@ -1419,9 +1419,9 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->rl78_int32 = init_integer_type (alloc, 32, 0, "int32_t");
 
   tdep->rl78_data_pointer
-    = arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void);
+    = init_pointer_type (alloc, 16, "rl78_data_addr_t", tdep->rl78_void);
   tdep->rl78_code_pointer
-    = arch_pointer_type (gdbarch, 32, "rl78_code_addr_t", tdep->rl78_void);
+    = init_pointer_type (alloc, 32, "rl78_code_addr_t", tdep->rl78_void);
 
   /* Registers.  */
   set_gdbarch_num_regs (gdbarch, RL78_NUM_REGS);
index 4a08dd48c653ef561182ba0e518655f499386c67..bc1927049d811f0765b09cfb23d87a87211e2b35 100644 (file)
@@ -225,8 +225,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch)
   wchar_type = init_integer_type (alloc, 16,
                                  1, "wchar_t");
   void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
-  wchar_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
-                                     NULL, wchar_type);
+  wchar_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
+                                     nullptr, wchar_type);
 
   /* list entry */
 
@@ -319,8 +319,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch)
   append_composite_type_field (rupp_type, "shell_info", uni_str_type);
   append_composite_type_field (rupp_type, "runtime_data", uni_str_type);
 
-  rupp_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
-                                    NULL, rupp_type);
+  rupp_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
+                                    nullptr, rupp_type);
 
 
   /* struct process environment block */
@@ -813,7 +813,7 @@ windows_get_siginfo_type (struct gdbarch *gdbarch)
   type_allocator alloc (gdbarch);
   dword_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
                                  1, "DWORD");
-  pvoid_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), "PVOID",
+  pvoid_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), "PVOID",
                                  builtin_type (gdbarch)->builtin_void);
   ulongptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch),
                                     1, "ULONG_PTR");
@@ -844,8 +844,8 @@ windows_get_siginfo_type (struct gdbarch *gdbarch)
 
   siginfo_type = arch_composite_type (gdbarch, "EXCEPTION_RECORD",
                                      TYPE_CODE_STRUCT);
-  siginfo_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
-                                       NULL, siginfo_type);
+  siginfo_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
+                                       nullptr, siginfo_type);
 
   /* ExceptionCode is documented as type DWORD, but here a helper
      enum type is used instead to display a human-readable value.  */
index 78b3827b54d29900dc4c1790cb9a07f9f95ece40..27cdca1c9c70a4012b41e695d95d41083f87a302 100644 (file)
@@ -1143,7 +1143,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT,
                                    "void");
   tdep->func_void_type = make_function_type (tdep->void_type, NULL);
-  tdep->pc_type = arch_pointer_type (gdbarch,
+  tdep->pc_type = init_pointer_type (alloc,
                                     tdep->addr_length * TARGET_CHAR_BIT,
                                     NULL, tdep->func_void_type);