Unify arch_integer_type and init_integer_type

This unifies arch_integer_type and init_integer_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey 2023-03-13 10:31:06 -06:00
parent 333859402c
commit 2d39ccd3d1
21 changed files with 201 additions and 205 deletions

View file

@ -13557,11 +13557,11 @@ public:
}; };
type_allocator alloc (gdbarch); type_allocator alloc (gdbarch);
add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), add (init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "integer")); 0, "integer"));
add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), add (init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long_integer")); 0, "long_integer"));
add (arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), add (init_integer_type (alloc, gdbarch_short_bit (gdbarch),
0, "short_integer")); 0, "short_integer"));
struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT, struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT,
1, "character"); 1, "character");
@ -13573,14 +13573,14 @@ public:
"float", gdbarch_float_format (gdbarch))); "float", gdbarch_float_format (gdbarch)));
add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
"long_float", gdbarch_double_format (gdbarch))); "long_float", gdbarch_double_format (gdbarch)));
add (arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
0, "long_long_integer")); 0, "long_long_integer"));
add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
"long_long_float", "long_long_float",
gdbarch_long_double_format (gdbarch))); gdbarch_long_double_format (gdbarch)));
add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), add (init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "natural")); 0, "natural"));
add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), add (init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "positive")); 0, "positive"));
add (builtin->builtin_void); add (builtin->builtin_void);
@ -13594,7 +13594,7 @@ public:
type. This is a signed integral type whose size is the same as type. This is a signed integral type whose size is the same as
the size of addresses. */ the size of addresses. */
unsigned int addr_length = system_addr_ptr->length (); unsigned int addr_length = system_addr_ptr->length ();
add (arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0, add (init_integer_type (alloc, addr_length * HOST_CHAR_BIT, 0,
"storage_offset")); "storage_offset"));
lai->set_bool_type (builtin->builtin_bool); lai->set_bool_type (builtin->builtin_bool);

View file

@ -577,7 +577,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid)
bits = cet.cte_bits; bits = cet.cte_bits;
else else
bits = gdbarch_int_bit (gdbarch); bits = gdbarch_int_bit (gdbarch);
type = init_integer_type (of, bits, !issigned, name); type = init_integer_type (alloc, bits, !issigned, name);
} }
} }
else if (kind == CTF_K_FLOAT) else if (kind == CTF_K_FLOAT)

View file

@ -201,29 +201,30 @@ build_d_types (struct gdbarch *gdbarch)
struct builtin_d_type *builtin_d_type = new struct builtin_d_type; struct builtin_d_type *builtin_d_type = new struct builtin_d_type;
/* Basic types. */ /* Basic types. */
type_allocator alloc (gdbarch);
builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void;
builtin_d_type->builtin_bool builtin_d_type->builtin_bool
= arch_boolean_type (gdbarch, 8, 1, "bool"); = arch_boolean_type (gdbarch, 8, 1, "bool");
builtin_d_type->builtin_byte builtin_d_type->builtin_byte
= arch_integer_type (gdbarch, 8, 0, "byte"); = init_integer_type (alloc, 8, 0, "byte");
builtin_d_type->builtin_ubyte builtin_d_type->builtin_ubyte
= arch_integer_type (gdbarch, 8, 1, "ubyte"); = init_integer_type (alloc, 8, 1, "ubyte");
builtin_d_type->builtin_short builtin_d_type->builtin_short
= arch_integer_type (gdbarch, 16, 0, "short"); = init_integer_type (alloc, 16, 0, "short");
builtin_d_type->builtin_ushort builtin_d_type->builtin_ushort
= arch_integer_type (gdbarch, 16, 1, "ushort"); = init_integer_type (alloc, 16, 1, "ushort");
builtin_d_type->builtin_int builtin_d_type->builtin_int
= arch_integer_type (gdbarch, 32, 0, "int"); = init_integer_type (alloc, 32, 0, "int");
builtin_d_type->builtin_uint builtin_d_type->builtin_uint
= arch_integer_type (gdbarch, 32, 1, "uint"); = init_integer_type (alloc, 32, 1, "uint");
builtin_d_type->builtin_long builtin_d_type->builtin_long
= arch_integer_type (gdbarch, 64, 0, "long"); = init_integer_type (alloc, 64, 0, "long");
builtin_d_type->builtin_ulong builtin_d_type->builtin_ulong
= arch_integer_type (gdbarch, 64, 1, "ulong"); = init_integer_type (alloc, 64, 1, "ulong");
builtin_d_type->builtin_cent builtin_d_type->builtin_cent
= arch_integer_type (gdbarch, 128, 0, "cent"); = init_integer_type (alloc, 128, 0, "cent");
builtin_d_type->builtin_ucent builtin_d_type->builtin_ucent
= arch_integer_type (gdbarch, 128, 1, "ucent"); = init_integer_type (alloc, 128, 1, "ucent");
builtin_d_type->builtin_float builtin_d_type->builtin_float
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch)); "float", gdbarch_float_format (gdbarch));

View file

@ -700,9 +700,12 @@ dwarf_expr_context::address_type () const
8 * this->m_addr_size); 8 * this->m_addr_size);
if (types->dw_types[ndx] == NULL) if (types->dw_types[ndx] == NULL)
types->dw_types[ndx] {
= arch_integer_type (arch, 8 * this->m_addr_size, type_allocator alloc (arch);
0, "<signed DWARF address type>"); types->dw_types[ndx]
= init_integer_type (alloc, 8 * this->m_addr_size,
0, "<signed DWARF address type>");
}
return types->dw_types[ndx]; return types->dw_types[ndx];
} }

View file

@ -15036,7 +15036,10 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile,
&& strcmp (name, "void") == 0) && strcmp (name, "void") == 0)
type = objfile_type (objfile)->builtin_void; type = objfile_type (objfile)->builtin_void;
else else
type = init_integer_type (objfile, bits, unsigned_p, name); {
type_allocator alloc (objfile);
type = init_integer_type (alloc, bits, unsigned_p, name);
}
return type; return type;
} }

View file

@ -1746,16 +1746,16 @@ build_fortran_types (struct gdbarch *gdbarch)
"logical*8"); "logical*8");
builtin_f_type->builtin_integer_s1 builtin_f_type->builtin_integer_s1
= arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "integer*1"); = init_integer_type (alloc, TARGET_CHAR_BIT, 0, "integer*1");
builtin_f_type->builtin_integer_s2 builtin_f_type->builtin_integer_s2
= arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0, "integer*2"); = init_integer_type (alloc, gdbarch_short_bit (gdbarch), 0, "integer*2");
builtin_f_type->builtin_integer builtin_f_type->builtin_integer
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "integer*4"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "integer*4");
builtin_f_type->builtin_integer_s8 builtin_f_type->builtin_integer_s8
= arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), 0, = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), 0,
"integer*8"); "integer*8");
builtin_f_type->builtin_real builtin_f_type->builtin_real

View file

@ -1594,11 +1594,12 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch)
if (fbsd_gdbarch_data->siginfo_type != NULL) if (fbsd_gdbarch_data->siginfo_type != NULL)
return fbsd_gdbarch_data->siginfo_type; return fbsd_gdbarch_data->siginfo_type;
int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), type_allocator alloc (gdbarch);
int_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "int"); 0, "int");
int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t"); int32_type = init_integer_type (alloc, 32, 0, "int32_t");
uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t"); uint32_type = init_integer_type (alloc, 32, 1, "uint32_t");
long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), long_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long"); 0, "long");
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
@ -1609,7 +1610,6 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch)
append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
/* __pid_t */ /* __pid_t */
type_allocator alloc (gdbarch);
pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
int32_type->length () * TARGET_CHAR_BIT, int32_type->length () * TARGET_CHAR_BIT,
"__pid_t"); "__pid_t");

View file

@ -3398,17 +3398,15 @@ floatformat_from_type (const struct type *type)
return TYPE_FLOATFORMAT (type); return TYPE_FLOATFORMAT (type);
} }
/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE. /* See gdbtypes.h. */
BIT is the type size in bits. If UNSIGNED_P is non-zero, set
the type's TYPE_UNSIGNED flag. NAME is the type name. */
struct type * struct type *
init_integer_type (struct objfile *objfile, init_integer_type (type_allocator &alloc,
int bit, int unsigned_p, const char *name) int bit, int unsigned_p, const char *name)
{ {
struct type *t; struct type *t;
t = type_allocator (objfile).new_type (TYPE_CODE_INT, bit, name); t = alloc.new_type (TYPE_CODE_INT, bit, name);
if (unsigned_p) if (unsigned_p)
t->set_is_unsigned (true); t->set_is_unsigned (true);
@ -5752,23 +5750,6 @@ copy_type (const struct type *type)
/* Helper functions to initialize architecture-specific types. */ /* Helper functions to initialize architecture-specific types. */
/* Allocate a TYPE_CODE_INT type structure associated with GDBARCH.
BIT is the type size in bits. If UNSIGNED_P is non-zero, set
the type's TYPE_UNSIGNED flag. NAME is the type name. */
struct type *
arch_integer_type (struct gdbarch *gdbarch,
int bit, int unsigned_p, const char *name)
{
struct type *t;
t = type_allocator (gdbarch).new_type (TYPE_CODE_INT, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
return t;
}
/* Allocate a TYPE_CODE_CHAR type structure associated with GDBARCH. /* Allocate a TYPE_CODE_CHAR type structure associated with GDBARCH.
BIT is the type size in bits. If UNSIGNED_P is non-zero, set BIT is the type size in bits. If UNSIGNED_P is non-zero, set
the type's TYPE_UNSIGNED flag. NAME is the type name. */ the type's TYPE_UNSIGNED flag. NAME is the type name. */
@ -6086,38 +6067,38 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
builtin_type->builtin_void builtin_type->builtin_void
= alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
builtin_type->builtin_char builtin_type->builtin_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char"); !gdbarch_char_signed (gdbarch), "char");
builtin_type->builtin_char->set_has_no_signedness (true); builtin_type->builtin_char->set_has_no_signedness (true);
builtin_type->builtin_signed_char builtin_type->builtin_signed_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
0, "signed char"); 0, "signed char");
builtin_type->builtin_unsigned_char builtin_type->builtin_unsigned_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
1, "unsigned char"); 1, "unsigned char");
builtin_type->builtin_short builtin_type->builtin_short
= arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), = init_integer_type (alloc, gdbarch_short_bit (gdbarch),
0, "short"); 0, "short");
builtin_type->builtin_unsigned_short builtin_type->builtin_unsigned_short
= arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), = init_integer_type (alloc, gdbarch_short_bit (gdbarch),
1, "unsigned short"); 1, "unsigned short");
builtin_type->builtin_int builtin_type->builtin_int
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "int"); 0, "int");
builtin_type->builtin_unsigned_int builtin_type->builtin_unsigned_int
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
1, "unsigned int"); 1, "unsigned int");
builtin_type->builtin_long builtin_type->builtin_long
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long"); 0, "long");
builtin_type->builtin_unsigned_long builtin_type->builtin_unsigned_long
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
1, "unsigned long"); 1, "unsigned long");
builtin_type->builtin_long_long builtin_type->builtin_long_long
= arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
0, "long long"); 0, "long long");
builtin_type->builtin_unsigned_long_long builtin_type->builtin_unsigned_long_long
= arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
1, "unsigned long long"); 1, "unsigned long long");
builtin_type->builtin_half builtin_type->builtin_half
= arch_float_type (gdbarch, gdbarch_half_bit (gdbarch), = arch_float_type (gdbarch, gdbarch_half_bit (gdbarch),
@ -6160,31 +6141,31 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
/* Fixed-size integer types. */ /* Fixed-size integer types. */
builtin_type->builtin_int0 builtin_type->builtin_int0
= arch_integer_type (gdbarch, 0, 0, "int0_t"); = init_integer_type (alloc, 0, 0, "int0_t");
builtin_type->builtin_int8 builtin_type->builtin_int8
= arch_integer_type (gdbarch, 8, 0, "int8_t"); = init_integer_type (alloc, 8, 0, "int8_t");
builtin_type->builtin_uint8 builtin_type->builtin_uint8
= arch_integer_type (gdbarch, 8, 1, "uint8_t"); = init_integer_type (alloc, 8, 1, "uint8_t");
builtin_type->builtin_int16 builtin_type->builtin_int16
= arch_integer_type (gdbarch, 16, 0, "int16_t"); = init_integer_type (alloc, 16, 0, "int16_t");
builtin_type->builtin_uint16 builtin_type->builtin_uint16
= arch_integer_type (gdbarch, 16, 1, "uint16_t"); = init_integer_type (alloc, 16, 1, "uint16_t");
builtin_type->builtin_int24 builtin_type->builtin_int24
= arch_integer_type (gdbarch, 24, 0, "int24_t"); = init_integer_type (alloc, 24, 0, "int24_t");
builtin_type->builtin_uint24 builtin_type->builtin_uint24
= arch_integer_type (gdbarch, 24, 1, "uint24_t"); = init_integer_type (alloc, 24, 1, "uint24_t");
builtin_type->builtin_int32 builtin_type->builtin_int32
= arch_integer_type (gdbarch, 32, 0, "int32_t"); = init_integer_type (alloc, 32, 0, "int32_t");
builtin_type->builtin_uint32 builtin_type->builtin_uint32
= arch_integer_type (gdbarch, 32, 1, "uint32_t"); = init_integer_type (alloc, 32, 1, "uint32_t");
builtin_type->builtin_int64 builtin_type->builtin_int64
= arch_integer_type (gdbarch, 64, 0, "int64_t"); = init_integer_type (alloc, 64, 0, "int64_t");
builtin_type->builtin_uint64 builtin_type->builtin_uint64
= arch_integer_type (gdbarch, 64, 1, "uint64_t"); = init_integer_type (alloc, 64, 1, "uint64_t");
builtin_type->builtin_int128 builtin_type->builtin_int128
= arch_integer_type (gdbarch, 128, 0, "int128_t"); = init_integer_type (alloc, 128, 0, "int128_t");
builtin_type->builtin_uint128 builtin_type->builtin_uint128
= arch_integer_type (gdbarch, 128, 1, "uint128_t"); = init_integer_type (alloc, 128, 1, "uint128_t");
builtin_type->builtin_int8->set_instance_flags builtin_type->builtin_int8->set_instance_flags
(builtin_type->builtin_int8->instance_flags () (builtin_type->builtin_int8->instance_flags ()
@ -6196,11 +6177,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
/* Wide character types. */ /* Wide character types. */
builtin_type->builtin_char16 builtin_type->builtin_char16
= arch_integer_type (gdbarch, 16, 1, "char16_t"); = init_integer_type (alloc, 16, 1, "char16_t");
builtin_type->builtin_char32 builtin_type->builtin_char32
= arch_integer_type (gdbarch, 32, 1, "char32_t"); = init_integer_type (alloc, 32, 1, "char32_t");
builtin_type->builtin_wchar builtin_type->builtin_wchar
= arch_integer_type (gdbarch, gdbarch_wchar_bit (gdbarch), = init_integer_type (alloc, gdbarch_wchar_bit (gdbarch),
!gdbarch_wchar_signed (gdbarch), "wchar_t"); !gdbarch_wchar_signed (gdbarch), "wchar_t");
/* Default data/code pointer types. */ /* Default data/code pointer types. */
@ -6263,38 +6244,38 @@ objfile_type (struct objfile *objfile)
objfile_type->builtin_void objfile_type->builtin_void
= alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
objfile_type->builtin_char objfile_type->builtin_char
= init_integer_type (objfile, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char"); !gdbarch_char_signed (gdbarch), "char");
objfile_type->builtin_char->set_has_no_signedness (true); objfile_type->builtin_char->set_has_no_signedness (true);
objfile_type->builtin_signed_char objfile_type->builtin_signed_char
= init_integer_type (objfile, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
0, "signed char"); 0, "signed char");
objfile_type->builtin_unsigned_char objfile_type->builtin_unsigned_char
= init_integer_type (objfile, TARGET_CHAR_BIT, = init_integer_type (alloc, TARGET_CHAR_BIT,
1, "unsigned char"); 1, "unsigned char");
objfile_type->builtin_short objfile_type->builtin_short
= init_integer_type (objfile, gdbarch_short_bit (gdbarch), = init_integer_type (alloc, gdbarch_short_bit (gdbarch),
0, "short"); 0, "short");
objfile_type->builtin_unsigned_short objfile_type->builtin_unsigned_short
= init_integer_type (objfile, gdbarch_short_bit (gdbarch), = init_integer_type (alloc, gdbarch_short_bit (gdbarch),
1, "unsigned short"); 1, "unsigned short");
objfile_type->builtin_int objfile_type->builtin_int
= init_integer_type (objfile, gdbarch_int_bit (gdbarch), = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "int"); 0, "int");
objfile_type->builtin_unsigned_int objfile_type->builtin_unsigned_int
= init_integer_type (objfile, gdbarch_int_bit (gdbarch), = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
1, "unsigned int"); 1, "unsigned int");
objfile_type->builtin_long objfile_type->builtin_long
= init_integer_type (objfile, gdbarch_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long"); 0, "long");
objfile_type->builtin_unsigned_long objfile_type->builtin_unsigned_long
= init_integer_type (objfile, gdbarch_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
1, "unsigned long"); 1, "unsigned long");
objfile_type->builtin_long_long objfile_type->builtin_long_long
= init_integer_type (objfile, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
0, "long long"); 0, "long long");
objfile_type->builtin_unsigned_long_long objfile_type->builtin_unsigned_long_long
= init_integer_type (objfile, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
1, "unsigned long long"); 1, "unsigned long long");
objfile_type->builtin_float objfile_type->builtin_float
= init_float_type (objfile, gdbarch_float_bit (gdbarch), = init_float_type (objfile, gdbarch_float_bit (gdbarch),
@ -6354,7 +6335,7 @@ objfile_type (struct objfile *objfile)
are indeed in the unified virtual address space. */ are indeed in the unified virtual address space. */
objfile_type->builtin_core_addr objfile_type->builtin_core_addr
= init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1, = init_integer_type (alloc, gdbarch_addr_bit (gdbarch), 1,
"__CORE_ADDR"); "__CORE_ADDR");
objfile_type_data.set (objfile, objfile_type); objfile_type_data.set (objfile, objfile_type);

View file

@ -2294,10 +2294,12 @@ private:
bool m_smash = false; bool m_smash = false;
}; };
/* * Helper function to construct objfile-owned types. */ /* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
type size in bits. If UNSIGNED_P is non-zero, set the type's
TYPE_UNSIGNED flag. NAME is the type name. */
extern struct type *init_integer_type (struct objfile *, int, int, extern struct type *init_integer_type (type_allocator &alloc, int bit,
const char *); int unsigned_p, const char *name);
extern struct type *init_character_type (struct objfile *, int, int, extern struct type *init_character_type (struct objfile *, int, int,
const char *); const char *);
extern struct type *init_boolean_type (struct objfile *, int, int, extern struct type *init_boolean_type (struct objfile *, int, int,
@ -2314,8 +2316,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int,
const char *); const char *);
/* Helper functions to construct architecture-owned types. */ /* Helper functions to construct architecture-owned types. */
extern struct type *arch_integer_type (struct gdbarch *, int, int,
const char *);
extern struct type *arch_character_type (struct gdbarch *, int, int, extern struct type *arch_character_type (struct gdbarch *, int, int,
const char *); const char *);
extern struct type *arch_boolean_type (struct gdbarch *, int, int, extern struct type *arch_boolean_type (struct gdbarch *, int, int,

View file

@ -129,7 +129,7 @@ get_gdb_vtable_type (struct gdbarch *arch)
/* ARCH can't give us the true ptrdiff_t type, so we guess. */ /* ARCH can't give us the true ptrdiff_t type, so we guess. */
struct type *ptrdiff_type struct type *ptrdiff_type
= arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t"); = init_integer_type (alloc, gdbarch_ptr_bit (arch), 0, "ptrdiff_t");
/* We assume no padding is necessary, since GDB doesn't know /* We assume no padding is necessary, since GDB doesn't know
anything about alignment at the moment. If this assumption bites anything about alignment at the moment. If this assumption bites

View file

@ -483,33 +483,34 @@ build_go_types (struct gdbarch *gdbarch)
{ {
struct builtin_go_type *builtin_go_type = new struct builtin_go_type; struct builtin_go_type *builtin_go_type = new struct builtin_go_type;
type_allocator alloc (gdbarch);
builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void;
builtin_go_type->builtin_char builtin_go_type->builtin_char
= arch_character_type (gdbarch, 8, 1, "char"); = arch_character_type (gdbarch, 8, 1, "char");
builtin_go_type->builtin_bool builtin_go_type->builtin_bool
= arch_boolean_type (gdbarch, 8, 0, "bool"); = arch_boolean_type (gdbarch, 8, 0, "bool");
builtin_go_type->builtin_int builtin_go_type->builtin_int
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "int"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int");
builtin_go_type->builtin_uint builtin_go_type->builtin_uint
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "uint"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "uint");
builtin_go_type->builtin_uintptr builtin_go_type->builtin_uintptr
= arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr"); = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "uintptr");
builtin_go_type->builtin_int8 builtin_go_type->builtin_int8
= arch_integer_type (gdbarch, 8, 0, "int8"); = init_integer_type (alloc, 8, 0, "int8");
builtin_go_type->builtin_int16 builtin_go_type->builtin_int16
= arch_integer_type (gdbarch, 16, 0, "int16"); = init_integer_type (alloc, 16, 0, "int16");
builtin_go_type->builtin_int32 builtin_go_type->builtin_int32
= arch_integer_type (gdbarch, 32, 0, "int32"); = init_integer_type (alloc, 32, 0, "int32");
builtin_go_type->builtin_int64 builtin_go_type->builtin_int64
= arch_integer_type (gdbarch, 64, 0, "int64"); = init_integer_type (alloc, 64, 0, "int64");
builtin_go_type->builtin_uint8 builtin_go_type->builtin_uint8
= arch_integer_type (gdbarch, 8, 1, "uint8"); = init_integer_type (alloc, 8, 1, "uint8");
builtin_go_type->builtin_uint16 builtin_go_type->builtin_uint16
= arch_integer_type (gdbarch, 16, 1, "uint16"); = init_integer_type (alloc, 16, 1, "uint16");
builtin_go_type->builtin_uint32 builtin_go_type->builtin_uint32
= arch_integer_type (gdbarch, 32, 1, "uint32"); = init_integer_type (alloc, 32, 1, "uint32");
builtin_go_type->builtin_uint64 builtin_go_type->builtin_uint64
= arch_integer_type (gdbarch, 64, 1, "uint64"); = init_integer_type (alloc, 64, 1, "uint64");
builtin_go_type->builtin_float32 builtin_go_type->builtin_float32
= arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single); = arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single);
builtin_go_type->builtin_float64 builtin_go_type->builtin_float64

View file

@ -277,13 +277,13 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
type_allocator alloc (gdbarch); type_allocator alloc (gdbarch);
int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), int_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
0, "int"); 0, "int");
uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), uint_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
1, "unsigned int"); 1, "unsigned int");
long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), long_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "long"); 0, "long");
short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), short_type = init_integer_type (alloc, gdbarch_long_bit (gdbarch),
0, "short"); 0, "short");
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
@ -1742,8 +1742,9 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
int *note_size) int *note_size)
{ {
struct linux_make_mappings_data mapping_data; struct linux_make_mappings_data mapping_data;
type_allocator alloc (gdbarch);
struct type *long_type struct type *long_type
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), 0, "long"); = init_integer_type (alloc, gdbarch_long_bit (gdbarch), 0, "long");
gdb_byte buf[sizeof (ULONGEST)]; gdb_byte buf[sizeof (ULONGEST)];
auto_obstack data_obstack, filename_obstack; auto_obstack data_obstack, filename_obstack;

View file

@ -281,11 +281,13 @@ build_m2_types (struct gdbarch *gdbarch)
{ {
struct builtin_m2_type *builtin_m2_type = new struct builtin_m2_type; struct builtin_m2_type *builtin_m2_type = new struct builtin_m2_type;
type_allocator alloc (gdbarch);
/* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */ /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
builtin_m2_type->builtin_int builtin_m2_type->builtin_int
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "INTEGER"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "INTEGER");
builtin_m2_type->builtin_card builtin_m2_type->builtin_card
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "CARDINAL"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL");
builtin_m2_type->builtin_real builtin_m2_type->builtin_real
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL",
gdbarch_float_format (gdbarch)); gdbarch_float_format (gdbarch));

View file

@ -201,12 +201,12 @@ make_types (struct gdbarch *arch)
tdep->code_addr_reg_type tdep->code_addr_reg_type
= arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd); = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd);
tdep->uint8 = arch_integer_type (arch, 8, 1, "uint8_t"); tdep->uint8 = init_integer_type (alloc, 8, 1, "uint8_t");
tdep->uint16 = arch_integer_type (arch, 16, 1, "uint16_t"); tdep->uint16 = init_integer_type (alloc, 16, 1, "uint16_t");
tdep->int8 = arch_integer_type (arch, 8, 0, "int8_t"); tdep->int8 = init_integer_type (alloc, 8, 0, "int8_t");
tdep->int16 = arch_integer_type (arch, 16, 0, "int16_t"); tdep->int16 = init_integer_type (alloc, 16, 0, "int16_t");
tdep->int32 = arch_integer_type (arch, 32, 0, "int32_t"); tdep->int32 = init_integer_type (alloc, 32, 0, "int32_t");
tdep->int64 = arch_integer_type (arch, 64, 0, "int64_t"); tdep->int64 = init_integer_type (alloc, 64, 0, "int64_t");
} }

View file

@ -1400,36 +1400,36 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btChar: case btChar:
tp = init_integer_type (objfile, 8, 0, "char"); tp = init_integer_type (alloc, 8, 0, "char");
tp->set_has_no_signedness (true); tp->set_has_no_signedness (true);
break; break;
case btUChar: case btUChar:
tp = init_integer_type (objfile, 8, 1, "unsigned char"); tp = init_integer_type (alloc, 8, 1, "unsigned char");
break; break;
case btShort: case btShort:
tp = init_integer_type (objfile, 16, 0, "short"); tp = init_integer_type (alloc, 16, 0, "short");
break; break;
case btUShort: case btUShort:
tp = init_integer_type (objfile, 16, 1, "unsigned short"); tp = init_integer_type (alloc, 16, 1, "unsigned short");
break; break;
case btInt: case btInt:
tp = init_integer_type (objfile, 32, 0, "int"); tp = init_integer_type (alloc, 32, 0, "int");
break; break;
case btUInt: case btUInt:
tp = init_integer_type (objfile, 32, 1, "unsigned int"); tp = init_integer_type (alloc, 32, 1, "unsigned int");
break; break;
case btLong: case btLong:
tp = init_integer_type (objfile, 32, 0, "long"); tp = init_integer_type (alloc, 32, 0, "long");
break; break;
case btULong: case btULong:
tp = init_integer_type (objfile, 32, 1, "unsigned long"); tp = init_integer_type (alloc, 32, 1, "unsigned long");
break; break;
case btFloat: case btFloat:
@ -1454,7 +1454,7 @@ basic_type (int bt, struct objfile *objfile)
/* We use TYPE_CODE_INT to print these as integers. Does this do any /* We use TYPE_CODE_INT to print these as integers. Does this do any
good? Would we be better off with TYPE_CODE_ERROR? Should good? Would we be better off with TYPE_CODE_ERROR? Should
TYPE_CODE_ERROR print things in hex if it knows the size? */ TYPE_CODE_ERROR print things in hex if it knows the size? */
tp = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0, tp = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0,
"fixed decimal"); "fixed decimal");
break; break;
@ -1474,19 +1474,19 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btLong64: case btLong64:
tp = init_integer_type (objfile, 64, 0, "long"); tp = init_integer_type (alloc, 64, 0, "long");
break; break;
case btULong64: case btULong64:
tp = init_integer_type (objfile, 64, 1, "unsigned long"); tp = init_integer_type (alloc, 64, 1, "unsigned long");
break; break;
case btLongLong64: case btLongLong64:
tp = init_integer_type (objfile, 64, 0, "long long"); tp = init_integer_type (alloc, 64, 0, "long long");
break; break;
case btULongLong64: case btULongLong64:
tp = init_integer_type (objfile, 64, 1, "unsigned long long"); tp = init_integer_type (alloc, 64, 1, "unsigned long long");
break; break;
case btAdr64: case btAdr64:
@ -1495,11 +1495,11 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btInt64: case btInt64:
tp = init_integer_type (objfile, 64, 0, "int"); tp = init_integer_type (alloc, 64, 0, "int");
break; break;
case btUInt64: case btUInt64:
tp = init_integer_type (objfile, 64, 1, "unsigned int"); tp = init_integer_type (alloc, 64, 1, "unsigned int");
break; break;
default: default:

View file

@ -909,21 +909,22 @@ public:
struct type *el_type, *char_type, *int_type; struct type *el_type, *char_type, *int_type;
char_type = el_type = add (arch_integer_type (gdbarch, 8, 0, "char")); type_allocator alloc (gdbarch);
char_type = el_type = add (init_integer_type (alloc, 8, 0, "char"));
BUILD_OCL_VTYPES (char, el_type); BUILD_OCL_VTYPES (char, el_type);
el_type = add (arch_integer_type (gdbarch, 8, 1, "uchar")); el_type = add (init_integer_type (alloc, 8, 1, "uchar"));
BUILD_OCL_VTYPES (uchar, el_type); BUILD_OCL_VTYPES (uchar, el_type);
el_type = add (arch_integer_type (gdbarch, 16, 0, "short")); el_type = add (init_integer_type (alloc, 16, 0, "short"));
BUILD_OCL_VTYPES (short, el_type); BUILD_OCL_VTYPES (short, el_type);
el_type = add (arch_integer_type (gdbarch, 16, 1, "ushort")); el_type = add (init_integer_type (alloc, 16, 1, "ushort"));
BUILD_OCL_VTYPES (ushort, el_type); BUILD_OCL_VTYPES (ushort, el_type);
int_type = el_type = add (arch_integer_type (gdbarch, 32, 0, "int")); int_type = el_type = add (init_integer_type (alloc, 32, 0, "int"));
BUILD_OCL_VTYPES (int, el_type); BUILD_OCL_VTYPES (int, el_type);
el_type = add (arch_integer_type (gdbarch, 32, 1, "uint")); el_type = add (init_integer_type (alloc, 32, 1, "uint"));
BUILD_OCL_VTYPES (uint, el_type); BUILD_OCL_VTYPES (uint, el_type);
el_type = add (arch_integer_type (gdbarch, 64, 0, "long")); el_type = add (init_integer_type (alloc, 64, 0, "long"));
BUILD_OCL_VTYPES (long, el_type); BUILD_OCL_VTYPES (long, el_type);
el_type = add (arch_integer_type (gdbarch, 64, 1, "ulong")); el_type = add (init_integer_type (alloc, 64, 1, "ulong"));
BUILD_OCL_VTYPES (ulong, el_type); BUILD_OCL_VTYPES (ulong, el_type);
el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half)); el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half));
BUILD_OCL_VTYPES (half, el_type); BUILD_OCL_VTYPES (half, el_type);
@ -933,14 +934,14 @@ public:
BUILD_OCL_VTYPES (double, el_type); BUILD_OCL_VTYPES (double, el_type);
add (arch_boolean_type (gdbarch, 8, 1, "bool")); add (arch_boolean_type (gdbarch, 8, 1, "bool"));
add (arch_integer_type (gdbarch, 8, 1, "unsigned char")); add (init_integer_type (alloc, 8, 1, "unsigned char"));
add (arch_integer_type (gdbarch, 16, 1, "unsigned short")); add (init_integer_type (alloc, 16, 1, "unsigned short"));
add (arch_integer_type (gdbarch, 32, 1, "unsigned int")); add (init_integer_type (alloc, 32, 1, "unsigned int"));
add (arch_integer_type (gdbarch, 64, 1, "unsigned long")); add (init_integer_type (alloc, 64, 1, "unsigned long"));
add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t")); add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "size_t"));
add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t")); add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t"));
add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t")); add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 0, "intptr_t"));
add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t")); add (init_integer_type (alloc, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t"));
add (builtin_type (gdbarch)->builtin_void); add (builtin_type (gdbarch)->builtin_void);
/* Type of elements of strings. */ /* Type of elements of strings. */

View file

@ -1411,12 +1411,12 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Initialize types. */ /* Initialize types. */
type_allocator alloc (gdbarch); type_allocator alloc (gdbarch);
tdep->rl78_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); tdep->rl78_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
tdep->rl78_uint8 = arch_integer_type (gdbarch, 8, 1, "uint8_t"); tdep->rl78_uint8 = init_integer_type (alloc, 8, 1, "uint8_t");
tdep->rl78_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t"); tdep->rl78_int8 = init_integer_type (alloc, 8, 0, "int8_t");
tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t"); tdep->rl78_uint16 = init_integer_type (alloc, 16, 1, "uint16_t");
tdep->rl78_int16 = arch_integer_type (gdbarch, 16, 0, "int16_t"); tdep->rl78_int16 = init_integer_type (alloc, 16, 0, "int16_t");
tdep->rl78_uint32 = arch_integer_type (gdbarch, 32, 1, "uint32_t"); tdep->rl78_uint32 = init_integer_type (alloc, 32, 1, "uint32_t");
tdep->rl78_int32 = arch_integer_type (gdbarch, 32, 0, "int32_t"); tdep->rl78_int32 = init_integer_type (alloc, 32, 0, "int32_t");
tdep->rl78_data_pointer tdep->rl78_data_pointer
= arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void); = arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void);

View file

@ -1594,27 +1594,28 @@ rust_language::language_arch_info (struct gdbarch *gdbarch,
return t; return t;
}; };
type_allocator alloc (gdbarch);
struct type *bool_type struct type *bool_type
= add (arch_boolean_type (gdbarch, 8, 1, "bool")); = add (arch_boolean_type (gdbarch, 8, 1, "bool"));
add (arch_character_type (gdbarch, 32, 1, "char")); add (arch_character_type (gdbarch, 32, 1, "char"));
add (arch_integer_type (gdbarch, 8, 0, "i8")); add (init_integer_type (alloc, 8, 0, "i8"));
struct type *u8_type struct type *u8_type
= add (arch_integer_type (gdbarch, 8, 1, "u8")); = add (init_integer_type (alloc, 8, 1, "u8"));
add (arch_integer_type (gdbarch, 16, 0, "i16")); add (init_integer_type (alloc, 16, 0, "i16"));
add (arch_integer_type (gdbarch, 16, 1, "u16")); add (init_integer_type (alloc, 16, 1, "u16"));
add (arch_integer_type (gdbarch, 32, 0, "i32")); add (init_integer_type (alloc, 32, 0, "i32"));
add (arch_integer_type (gdbarch, 32, 1, "u32")); add (init_integer_type (alloc, 32, 1, "u32"));
add (arch_integer_type (gdbarch, 64, 0, "i64")); add (init_integer_type (alloc, 64, 0, "i64"));
add (arch_integer_type (gdbarch, 64, 1, "u64")); add (init_integer_type (alloc, 64, 1, "u64"));
unsigned int length = 8 * builtin->builtin_data_ptr->length (); unsigned int length = 8 * builtin->builtin_data_ptr->length ();
add (arch_integer_type (gdbarch, length, 0, "isize")); add (init_integer_type (alloc, length, 0, "isize"));
struct type *usize_type struct type *usize_type
= add (arch_integer_type (gdbarch, length, 1, "usize")); = add (init_integer_type (alloc, length, 1, "usize"));
add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single)); add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single));
add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double)); add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double));
add (arch_integer_type (gdbarch, 0, 1, "()")); add (init_integer_type (alloc, 0, 1, "()"));
struct type *tem = make_cv_type (1, 0, u8_type, NULL); struct type *tem = make_cv_type (1, 0, u8_type, NULL);
add (rust_slice_type ("&str", tem, usize_type)); add (rust_slice_type ("&str", tem, usize_type));

View file

@ -2090,35 +2090,35 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
is other than 32 bits, then it should use a new negative type is other than 32 bits, then it should use a new negative type
number (or avoid negative type numbers for that case). number (or avoid negative type numbers for that case).
See stabs.texinfo. */ See stabs.texinfo. */
rettype = init_integer_type (objfile, 32, 0, "int"); rettype = init_integer_type (alloc, 32, 0, "int");
break; break;
case 2: case 2:
rettype = init_integer_type (objfile, 8, 0, "char"); rettype = init_integer_type (alloc, 8, 0, "char");
rettype->set_has_no_signedness (true); rettype->set_has_no_signedness (true);
break; break;
case 3: case 3:
rettype = init_integer_type (objfile, 16, 0, "short"); rettype = init_integer_type (alloc, 16, 0, "short");
break; break;
case 4: case 4:
rettype = init_integer_type (objfile, 32, 0, "long"); rettype = init_integer_type (alloc, 32, 0, "long");
break; break;
case 5: case 5:
rettype = init_integer_type (objfile, 8, 1, "unsigned char"); rettype = init_integer_type (alloc, 8, 1, "unsigned char");
break; break;
case 6: case 6:
rettype = init_integer_type (objfile, 8, 0, "signed char"); rettype = init_integer_type (alloc, 8, 0, "signed char");
break; break;
case 7: case 7:
rettype = init_integer_type (objfile, 16, 1, "unsigned short"); rettype = init_integer_type (alloc, 16, 1, "unsigned short");
break; break;
case 8: case 8:
rettype = init_integer_type (objfile, 32, 1, "unsigned int"); rettype = init_integer_type (alloc, 32, 1, "unsigned int");
break; break;
case 9: case 9:
rettype = init_integer_type (objfile, 32, 1, "unsigned"); rettype = init_integer_type (alloc, 32, 1, "unsigned");
break; break;
case 10: case 10:
rettype = init_integer_type (objfile, 32, 1, "unsigned long"); rettype = init_integer_type (alloc, 32, 1, "unsigned long");
break; break;
case 11: case 11:
rettype = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); rettype = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
@ -2141,7 +2141,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
floatformats_ieee_double); floatformats_ieee_double);
break; break;
case 15: case 15:
rettype = init_integer_type (objfile, 32, 0, "integer"); rettype = init_integer_type (alloc, 32, 0, "integer");
break; break;
case 16: case 16:
rettype = init_boolean_type (objfile, 32, 1, "boolean"); rettype = init_boolean_type (objfile, 32, 1, "boolean");
@ -2183,28 +2183,28 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
rs6000_builtin_type (13, objfile)); rs6000_builtin_type (13, objfile));
break; break;
case 27: case 27:
rettype = init_integer_type (objfile, 8, 0, "integer*1"); rettype = init_integer_type (alloc, 8, 0, "integer*1");
break; break;
case 28: case 28:
rettype = init_integer_type (objfile, 16, 0, "integer*2"); rettype = init_integer_type (alloc, 16, 0, "integer*2");
break; break;
case 29: case 29:
rettype = init_integer_type (objfile, 32, 0, "integer*4"); rettype = init_integer_type (alloc, 32, 0, "integer*4");
break; break;
case 30: case 30:
rettype = init_character_type (objfile, 16, 0, "wchar"); rettype = init_character_type (objfile, 16, 0, "wchar");
break; break;
case 31: case 31:
rettype = init_integer_type (objfile, 64, 0, "long long"); rettype = init_integer_type (alloc, 64, 0, "long long");
break; break;
case 32: case 32:
rettype = init_integer_type (objfile, 64, 1, "unsigned long long"); rettype = init_integer_type (alloc, 64, 1, "unsigned long long");
break; break;
case 33: case 33:
rettype = init_integer_type (objfile, 64, 1, "logical*8"); rettype = init_integer_type (alloc, 64, 1, "logical*8");
break; break;
case 34: case 34:
rettype = init_integer_type (objfile, 64, 0, "integer*8"); rettype = init_integer_type (alloc, 64, 0, "integer*8");
break; break;
} }
negative_types[-typenum] = rettype; negative_types[-typenum] = rettype;
@ -3761,7 +3761,7 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile
if (boolean_type) if (boolean_type)
return init_boolean_type (objfile, type_bits, unsigned_type, NULL); return init_boolean_type (objfile, type_bits, unsigned_type, NULL);
else else
return init_integer_type (objfile, type_bits, unsigned_type, NULL); return init_integer_type (alloc, type_bits, unsigned_type, NULL);
} }
static struct type * static struct type *
@ -4059,7 +4059,7 @@ read_range_type (const char **pp, int typenums[2], int type_size,
} }
if (got_signed || got_unsigned) if (got_signed || got_unsigned)
return init_integer_type (objfile, nbits, got_unsigned, NULL); return init_integer_type (alloc, nbits, got_unsigned, NULL);
else else
return error_type (pp, objfile); return error_type (pp, objfile);
} }
@ -4105,14 +4105,14 @@ read_range_type (const char **pp, int typenums[2], int type_size,
bits = gdbarch_int_bit (gdbarch); bits = gdbarch_int_bit (gdbarch);
} }
return init_integer_type (objfile, bits, 1, NULL); return init_integer_type (alloc, bits, 1, NULL);
} }
/* Special case: char is defined (Who knows why) as a subrange of /* Special case: char is defined (Who knows why) as a subrange of
itself with range 0-127. */ itself with range 0-127. */
else if (self_subrange && n2 == 0 && n3 == 127) else if (self_subrange && n2 == 0 && n3 == 127)
{ {
struct type *type = init_integer_type (objfile, TARGET_CHAR_BIT, struct type *type = init_integer_type (alloc, TARGET_CHAR_BIT,
0, NULL); 0, NULL);
type->set_has_no_signedness (true); type->set_has_no_signedness (true);
return type; return type;
@ -4126,7 +4126,7 @@ read_range_type (const char **pp, int typenums[2], int type_size,
if (n3 < 0) if (n3 < 0)
/* n3 actually gives the size. */ /* n3 actually gives the size. */
return init_integer_type (objfile, -n3 * TARGET_CHAR_BIT, 1, NULL); return init_integer_type (alloc, -n3 * TARGET_CHAR_BIT, 1, NULL);
/* Is n3 == 2**(8n)-1 for some integer n? Then it's an /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
unsigned n-byte integer. But do require n to be a power of unsigned n-byte integer. But do require n to be a power of
@ -4140,7 +4140,7 @@ read_range_type (const char **pp, int typenums[2], int type_size,
bits >>= 8; bits >>= 8;
if (bits == 0 if (bits == 0
&& ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */ && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
return init_integer_type (objfile, bytes * TARGET_CHAR_BIT, 1, NULL); return init_integer_type (alloc, bytes * TARGET_CHAR_BIT, 1, NULL);
} }
} }
/* I think this is for Convex "long long". Since I don't know whether /* I think this is for Convex "long long". Since I don't know whether
@ -4150,15 +4150,15 @@ read_range_type (const char **pp, int typenums[2], int type_size,
&& (self_subrange && (self_subrange
|| n2 == -gdbarch_long_long_bit || n2 == -gdbarch_long_long_bit
(gdbarch) / TARGET_CHAR_BIT)) (gdbarch) / TARGET_CHAR_BIT))
return init_integer_type (objfile, -n2 * TARGET_CHAR_BIT, 0, NULL); return init_integer_type (alloc, -n2 * TARGET_CHAR_BIT, 0, NULL);
else if (n2 == -n3 - 1) else if (n2 == -n3 - 1)
{ {
if (n3 == 0x7f) if (n3 == 0x7f)
return init_integer_type (objfile, 8, 0, NULL); return init_integer_type (alloc, 8, 0, NULL);
if (n3 == 0x7fff) if (n3 == 0x7fff)
return init_integer_type (objfile, 16, 0, NULL); return init_integer_type (alloc, 16, 0, NULL);
if (n3 == 0x7fffffff) if (n3 == 0x7fffffff)
return init_integer_type (objfile, 32, 0, NULL); return init_integer_type (alloc, 32, 0, NULL);
} }
/* We have a real range type on our hands. Allocate space and /* We have a real range type on our hands. Allocate space and

View file

@ -216,13 +216,13 @@ windows_get_tlb_type (struct gdbarch *gdbarch)
type_allocator alloc (gdbarch); type_allocator alloc (gdbarch);
dword_ptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), dword_ptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch),
1, "DWORD_PTR"); 1, "DWORD_PTR");
dword32_type = arch_integer_type (gdbarch, 32, dword32_type = init_integer_type (alloc, 32,
1, "DWORD32"); 1, "DWORD32");
word_type = arch_integer_type (gdbarch, 16, word_type = init_integer_type (alloc, 16,
1, "WORD"); 1, "WORD");
wchar_type = arch_integer_type (gdbarch, 16, wchar_type = init_integer_type (alloc, 16,
1, "wchar_t"); 1, "wchar_t");
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
wchar_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), wchar_ptr_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
@ -810,11 +810,12 @@ windows_get_siginfo_type (struct gdbarch *gdbarch)
if (windows_gdbarch_data->siginfo_type != NULL) if (windows_gdbarch_data->siginfo_type != NULL)
return windows_gdbarch_data->siginfo_type; return windows_gdbarch_data->siginfo_type;
dword_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), type_allocator alloc (gdbarch);
dword_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
1, "DWORD"); 1, "DWORD");
pvoid_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), "PVOID", pvoid_type = arch_pointer_type (gdbarch, gdbarch_ptr_bit (gdbarch), "PVOID",
builtin_type (gdbarch)->builtin_void); builtin_type (gdbarch)->builtin_void);
ulongptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), ulongptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch),
1, "ULONG_PTR"); 1, "ULONG_PTR");
/* ExceptionCode value names */ /* ExceptionCode value names */

View file

@ -312,8 +312,9 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum)
tp->next = tdep->type_entries; tp->next = tdep->type_entries;
tdep->type_entries = tp; tdep->type_entries = tp;
tp->size = size; tp->size = size;
type_allocator alloc (gdbarch);
tp->virtual_type tp->virtual_type
= arch_integer_type (gdbarch, size * 8, 1, name.c_str ()); = init_integer_type (alloc, size * 8, 1, name.c_str ());
} }
reg->ctype = tp->virtual_type; reg->ctype = tp->virtual_type;