lai->add_primitive_type (t);
};
+ type_allocator alloc (gdbarch);
add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
0, "integer"));
add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
add (builtin->builtin_void);
struct type *system_addr_ptr
- = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
- "void"));
+ = lookup_pointer_type (alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT,
+ "void"));
system_addr_ptr->set_name ("system__address");
add (system_addr_ptr);
const auto &enum_type
= static_cast<const amd_dbgapi_register_type_enum &> (type);
struct type *gdb_type
- = arch_type (gdbarch, TYPE_CODE_ENUM, enum_type.bit_size (),
- enum_type.name ().c_str ());
+ = (type_allocator (gdbarch)
+ .new_type (TYPE_CODE_ENUM, enum_type.bit_size (),
+ enum_type.name ().c_str ()));
gdb_type->set_num_fields (enum_type.size ());
gdb_type->set_fields
/* Create a type for PC. We can't use builtin types here, as they may not
be defined. */
- tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
- "void");
+ 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->func_void_type);
builtin_f_type->builtin_void = builtin_type (gdbarch)->builtin_void;
+ type_allocator alloc (gdbarch);
+
builtin_f_type->builtin_character
- = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
+ = alloc.new_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
builtin_f_type->builtin_logical_s1
= arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1");
"real*16", gdbarch_long_double_format (gdbarch));
else
builtin_f_type->builtin_real_s16
- = arch_type (gdbarch, TYPE_CODE_ERROR, 128, "real*16");
+ = alloc.new_type (TYPE_CODE_ERROR, 128, "real*16");
builtin_f_type->builtin_complex
= init_complex_type ("complex*4", builtin_f_type->builtin_real);
if (builtin_f_type->builtin_real_s16->code () == TYPE_CODE_ERROR)
builtin_f_type->builtin_complex_s16
- = arch_type (gdbarch, TYPE_CODE_ERROR, 256, "complex*16");
+ = alloc.new_type (TYPE_CODE_ERROR, 256, "complex*16");
else
builtin_f_type->builtin_complex_s16
= init_complex_type ("complex*16", builtin_f_type->builtin_real_s16);
append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
/* __pid_t */
- pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- int32_type->length () * TARGET_CHAR_BIT, "__pid_t");
+ type_allocator alloc (gdbarch);
+ pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int32_type->length () * TARGET_CHAR_BIT,
+ "__pid_t");
pid_type->set_target_type (int32_type);
pid_type->set_target_is_stub (true);
/* __uid_t */
- uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- uint32_type->length () * TARGET_CHAR_BIT,
- "__uid_t");
+ uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ uint32_type->length () * TARGET_CHAR_BIT,
+ "__uid_t");
uid_type->set_target_type (uint32_type);
pid_type->set_target_is_stub (true);
/* Create a type for PC. We can't use builtin types here, as they may not
be defined. */
- void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+ 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,
func_void_type);
\f
/* Helper functions to initialize architecture-specific types. */
-/* Allocate a type structure associated with GDBARCH and set its
- CODE, LENGTH, and NAME fields. */
-
-struct type *
-arch_type (struct gdbarch *gdbarch,
- enum type_code code, int bit, const char *name)
-{
- struct type *type;
-
- type = type_allocator (gdbarch).new_type ();
- set_type_code (type, code);
- gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
- type->set_length (bit / TARGET_CHAR_BIT);
-
- if (name)
- type->set_name (gdbarch_obstack_strdup (gdbarch, name));
-
- return type;
-}
-
/* 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 *t;
- t = arch_type (gdbarch, TYPE_CODE_INT, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_INT, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
{
struct type *t;
- t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_CHAR, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
{
struct type *t;
- t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_BOOL, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
struct type *t;
bit = verify_floatformat (bit, fmt);
- t = arch_type (gdbarch, TYPE_CODE_FLT, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name);
TYPE_FLOATFORMAT (t) = fmt;
return t;
{
struct type *t;
- t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name);
return t;
}
{
struct type *t;
- t = arch_type (gdbarch, TYPE_CODE_PTR, bit, name);
+ t = type_allocator (gdbarch).new_type (TYPE_CODE_PTR, bit, name);
t->set_target_type (target_type);
t->set_is_unsigned (true);
return t;
{
struct type *type;
- type = arch_type (gdbarch, TYPE_CODE_FLAGS, bit, name);
+ type = type_allocator (gdbarch).new_type (TYPE_CODE_FLAGS, bit, name);
type->set_is_unsigned (true);
type->set_num_fields (0);
/* Pre-allocate enough space assuming every field is one bit. */
struct type *t;
gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION);
- t = arch_type (gdbarch, code, 0, NULL);
+ t = type_allocator (gdbarch).new_type (code, 0, NULL);
t->set_name (name);
INIT_CPLUS_SPECIFIC (t);
return t;
{
struct builtin_type *builtin_type = new struct builtin_type;
+ type_allocator alloc (gdbarch);
+
/* Basic types. */
builtin_type->builtin_void
- = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+ = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
builtin_type->builtin_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char");
builtin_type->builtin_double_complex
= init_complex_type ("double complex", builtin_type->builtin_double);
builtin_type->builtin_string
- = arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
+ = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
builtin_type->builtin_bool
= arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool");
/* This type represents a GDB internal function. */
builtin_type->internal_fn
- = arch_type (gdbarch, TYPE_CODE_INTERNAL_FUNCTION, 0,
- "<internal function>");
+ = alloc.new_type (TYPE_CODE_INTERNAL_FUNCTION, 0,
+ "<internal function>");
/* This type represents an xmethod. */
builtin_type->xmethod
- = arch_type (gdbarch, TYPE_CODE_XMETHOD, 0, "<xmethod>");
+ = alloc.new_type (TYPE_CODE_XMETHOD, 0, "<xmethod>");
return builtin_type;
}
const char *);
/* Helper functions to construct architecture-owned types. */
-extern struct type *arch_type (struct gdbarch *, enum type_code, int,
- const char *);
extern struct type *arch_integer_type (struct gdbarch *, int, int,
const char *);
extern struct type *arch_character_type (struct gdbarch *, int, int,
struct type *ptr_to_void_fn_type
= builtin_type (arch)->builtin_func_ptr;
+ type_allocator alloc (arch);
+
/* ARCH can't give us the true ptrdiff_t type, so we guess. */
struct type *ptrdiff_type
= arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t");
/* We assumed in the allocation above that there were four fields. */
gdb_assert (field == (field_list + 4));
- t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
+ t = alloc.new_type (TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
t->set_num_fields (field - field_list);
t->set_fields (field_list);
t->set_name ("gdb_gnu_v3_abi_vtable");
gdb_assert (field == (field_list + 2));
- t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
+ t = type_allocator (arch).new_type (TYPE_CODE_STRUCT,
+ offset * TARGET_CHAR_BIT, nullptr);
t->set_num_fields (field - field_list);
t->set_fields (field_list);
t->set_name ("gdb_gnu_v3_type_info");
if (linux_gdbarch_data->siginfo_type != NULL)
return linux_gdbarch_data->siginfo_type;
+ type_allocator alloc (gdbarch);
+
int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
0, "int");
uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
/* __pid_t */
- pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- int_type->length () * TARGET_CHAR_BIT, "__pid_t");
+ pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int_type->length () * TARGET_CHAR_BIT,
+ "__pid_t");
pid_type->set_target_type (int_type);
pid_type->set_target_is_stub (true);
/* __uid_t */
- uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- uint_type->length () * TARGET_CHAR_BIT, "__uid_t");
+ uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ uint_type->length () * TARGET_CHAR_BIT,
+ "__uid_t");
uid_type->set_target_type (uint_type);
uid_type->set_target_is_stub (true);
/* __clock_t */
- clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- long_type->length () * TARGET_CHAR_BIT,
- "__clock_t");
+ clock_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ long_type->length () * TARGET_CHAR_BIT,
+ "__clock_t");
clock_type->set_target_type (long_type);
clock_type->set_target_is_stub (true);
/* The builtin_type_mumble variables are sometimes uninitialized when
this is called, so we avoid using them. */
- tdep->voyd = arch_type (arch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+ 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);
tdep->func_voyd = lookup_function_type (tdep->voyd);
size_t char_bits = gdbarch_addressable_memory_unit_size (gdbarch) * 8;
/* pid_t */
- type *pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- int32_type->length () * char_bits, "pid_t");
+ type_allocator alloc (gdbarch);
+ type *pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int32_type->length () * char_bits,
+ "pid_t");
pid_type->set_target_type (int32_type);
/* uid_t */
- type *uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- uint32_type->length () * char_bits, "uid_t");
+ type *uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ uint32_type->length () * char_bits,
+ "uid_t");
uid_type->set_target_type (uint32_type);
/* clock_t */
- type *clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- int_type->length () * char_bits, "clock_t");
+ type *clock_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int_type->length () * char_bits,
+ "clock_t");
clock_type->set_target_type (int_type);
/* lwpid_t */
- type *lwpid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
- int32_type->length () * char_bits,
- "lwpid_t");
+ type *lwpid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+ int32_type->length () * char_bits,
+ "lwpid_t");
lwpid_type->set_target_type (int32_type);
/* union sigval */
tdep->elf_flags = elf_flags;
/* Initialize types. */
- tdep->rl78_void = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
- "void");
+ type_allocator alloc (gdbarch);
+ 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_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t");
tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t");
void make_gdb_type_enum (const tdesc_type_with_fields *e)
{
- m_type = arch_type (m_gdbarch, TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
- e->name.c_str ());
+ m_type = (type_allocator (m_gdbarch)
+ .new_type (TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
+ e->name.c_str ()));
m_type->set_is_unsigned (true);
if (windows_gdbarch_data->tib_ptr_type != nullptr)
return windows_gdbarch_data->tib_ptr_type;
+ type_allocator alloc (gdbarch);
+
dword_ptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
1, "DWORD_PTR");
dword32_type = arch_integer_type (gdbarch, 32,
seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
seh_type->set_name (xstrdup ("seh"));
- seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
- void_ptr_type->length () * TARGET_CHAR_BIT,
- NULL);
+ seh_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+ void_ptr_type->length () * TARGET_CHAR_BIT,
+ NULL);
seh_ptr_type->set_target_type (seh_type);
append_composite_type_field (seh_type, "next_seh", seh_ptr_type);
append_composite_type_field (peb_ldr_type, "in_init_order", list_type);
append_composite_type_field (peb_ldr_type, "entry_in_progress",
void_ptr_type);
- peb_ldr_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
- void_ptr_type->length () * TARGET_CHAR_BIT,
- NULL);
+ peb_ldr_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+ void_ptr_type->length () * TARGET_CHAR_BIT,
+ NULL);
peb_ldr_ptr_type->set_target_type (peb_ldr_type);
/* struct UNICODE_STRING */
append_composite_type_field (peb_type, "sub_system_data", void_ptr_type);
append_composite_type_field (peb_type, "process_heap", void_ptr_type);
append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type);
- peb_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
- void_ptr_type->length () * TARGET_CHAR_BIT,
- NULL);
+ peb_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+ void_ptr_type->length () * TARGET_CHAR_BIT,
+ NULL);
peb_ptr_type->set_target_type (peb_type);
/* uint32_t last_error_number; %fs:0x0034 */
append_composite_type_field (tib_type, "last_error_number", dword_ptr_type);
- tib_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
- void_ptr_type->length () * TARGET_CHAR_BIT,
- NULL);
+ tib_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+ void_ptr_type->length () * TARGET_CHAR_BIT,
+ NULL);
tib_ptr_type->set_target_type (tib_type);
windows_gdbarch_data->tib_ptr_type = tib_ptr_type;
struct type *type;
int i;
- type = arch_type (gdbarch, TYPE_CODE_ENUM, bit, name);
+ type = type_allocator (gdbarch).new_type (TYPE_CODE_ENUM, bit, name);
type->set_num_fields (count);
type->set_fields
((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * count));
/* Create a type for PC. We can't use builtin types here, as they may not
be defined. */
- tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
- "void");
+ 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,
tdep->addr_length * TARGET_CHAR_BIT,