-static void build_gdbtypes (void);
-static void
-build_gdbtypes (void)
-{
- builtin_type_void =
- init_type (TYPE_CODE_VOID, 1,
- 0,
- "void", (struct objfile *) NULL);
- builtin_type_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "char", (struct objfile *) NULL);
- TYPE_FLAGS (builtin_type_char) |= TYPE_FLAG_NOSIGN;
- builtin_type_true_char =
- init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "true character", (struct objfile *) NULL);
- builtin_type_signed_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "signed char", (struct objfile *) NULL);
- builtin_type_unsigned_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned char", (struct objfile *) NULL);
- builtin_type_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- 0,
- "short", (struct objfile *) NULL);
- builtin_type_unsigned_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned short", (struct objfile *) NULL);
- builtin_type_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0,
- "int", (struct objfile *) NULL);
- builtin_type_unsigned_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned int", (struct objfile *) NULL);
- builtin_type_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- 0,
- "long", (struct objfile *) NULL);
- builtin_type_unsigned_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned long", (struct objfile *) NULL);
- builtin_type_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0,
- "long long", (struct objfile *) NULL);
- builtin_type_unsigned_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "unsigned long long", (struct objfile *) NULL);
- builtin_type_float =
- init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
- 0,
- "float", (struct objfile *) NULL);
- builtin_type_double =
- init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
- 0,
- "double", (struct objfile *) NULL);
- builtin_type_long_double =
- init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
- 0,
- "long double", (struct objfile *) NULL);
- builtin_type_complex =
- init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
- 0,
- "complex", (struct objfile *) NULL);
- TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float;
- builtin_type_double_complex =
- init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
- 0,
- "double complex", (struct objfile *) NULL);
- TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double;
- builtin_type_string =
- init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "string", (struct objfile *) NULL);
- builtin_type_int8 =
- init_type (TYPE_CODE_INT, 8 / 8,
- 0,
- "int8_t", (struct objfile *) NULL);
- builtin_type_uint8 =
- init_type (TYPE_CODE_INT, 8 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint8_t", (struct objfile *) NULL);
- builtin_type_int16 =
- init_type (TYPE_CODE_INT, 16 / 8,
- 0,
- "int16_t", (struct objfile *) NULL);
- builtin_type_uint16 =
- init_type (TYPE_CODE_INT, 16 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint16_t", (struct objfile *) NULL);
- builtin_type_int32 =
- init_type (TYPE_CODE_INT, 32 / 8,
- 0,
- "int32_t", (struct objfile *) NULL);
- builtin_type_uint32 =
- init_type (TYPE_CODE_INT, 32 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint32_t", (struct objfile *) NULL);
- builtin_type_int64 =
- init_type (TYPE_CODE_INT, 64 / 8,
- 0,
- "int64_t", (struct objfile *) NULL);
- builtin_type_uint64 =
- init_type (TYPE_CODE_INT, 64 / 8,
- TYPE_FLAG_UNSIGNED,
- "uint64_t", (struct objfile *) NULL);
- builtin_type_bool =
- init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "bool", (struct objfile *) NULL);
-
- /* Add user knob for controlling resolution of opaque types */
- add_show_from_set
- (add_set_cmd ("opaque-type-resolution", class_support, var_boolean, (char *) &opaque_type_resolution,
- "Set resolution of opaque struct/class/union types (if set before loading symbols).",
- &setlist),
- &showlist);
- opaque_type_resolution = 1;
-
-
- /* Build SIMD types. */
- builtin_type_v4sf
- = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4);
- builtin_type_v4si
- = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4);
- builtin_type_v8qi
- = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8);
- builtin_type_v4hi
- = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4);
- builtin_type_v2si
- = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
-
- /* Pointer/Address types. */
- /* NOTE: At present there is no way of differentiating between at
- target address and the target C language pointer type type even
- though the two can be different (cf d10v) */
- builtin_type_ptr = make_pointer_type (builtin_type_void, NULL);
- builtin_type_CORE_ADDR =
- init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8,
- TYPE_FLAG_UNSIGNED,
- "__CORE_ADDR", (struct objfile *) NULL);
- builtin_type_bfd_vma =
- init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8,
- TYPE_FLAG_UNSIGNED,
- "__bfd_vma", (struct objfile *) NULL);
+/* Trivial helpers for the libiberty hash table, for mapping one
+ type to another. */
+
+struct type_pair
+{
+ struct type *old, *new;
+};
+
+static hashval_t
+type_pair_hash (const void *item)
+{
+ const struct type_pair *pair = item;
+ return htab_hash_pointer (pair->old);
+}
+
+static int
+type_pair_eq (const void *item_lhs, const void *item_rhs)
+{
+ const struct type_pair *lhs = item_lhs, *rhs = item_rhs;
+ return lhs->old == rhs->old;
+}
+
+/* Allocate the hash table used by copy_type_recursive to walk
+ types without duplicates. We use OBJFILE's obstack, because
+ OBJFILE is about to be deleted. */
+
+htab_t
+create_copied_types_hash (struct objfile *objfile)
+{
+ return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
+ NULL, &objfile->objfile_obstack,
+ hashtab_obstack_allocate,
+ dummy_obstack_deallocate);
+}
+
+/* Recursively copy (deep copy) TYPE, if it is associated with
+ OBJFILE. Return a new type allocated using malloc, a saved type if
+ we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
+ not associated with OBJFILE. */
+
+struct type *
+copy_type_recursive (struct objfile *objfile,
+ struct type *type,
+ htab_t copied_types)
+{
+ struct type_pair *stored, pair;
+ void **slot;
+ struct type *new_type;
+
+ if (! TYPE_OBJFILE_OWNED (type))
+ return type;
+
+ /* This type shouldn't be pointing to any types in other objfiles;
+ if it did, the type might disappear unexpectedly. */
+ gdb_assert (TYPE_OBJFILE (type) == objfile);
+
+ pair.old = type;
+ slot = htab_find_slot (copied_types, &pair, INSERT);
+ if (*slot != NULL)
+ return ((struct type_pair *) *slot)->new;
+
+ new_type = alloc_type_arch (get_type_arch (type));
+
+ /* We must add the new type to the hash table immediately, in case
+ we encounter this type again during a recursive call below. */
+ stored = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
+ stored->old = type;
+ stored->new = new_type;
+ *slot = stored;
+
+ /* Copy the common fields of types. For the main type, we simply
+ copy the entire thing and then update specific fields as needed. */
+ *TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type);
+ TYPE_OBJFILE_OWNED (new_type) = 0;
+ TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
+
+ if (TYPE_NAME (type))
+ TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
+ if (TYPE_TAG_NAME (type))
+ TYPE_TAG_NAME (new_type) = xstrdup (TYPE_TAG_NAME (type));
+
+ TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
+ TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+
+ /* Copy the fields. */
+ if (TYPE_NFIELDS (type))
+ {
+ int i, nfields;
+
+ nfields = TYPE_NFIELDS (type);
+ TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
+ for (i = 0; i < nfields; i++)
+ {
+ TYPE_FIELD_ARTIFICIAL (new_type, i) =
+ TYPE_FIELD_ARTIFICIAL (type, i);
+ TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
+ if (TYPE_FIELD_TYPE (type, i))
+ TYPE_FIELD_TYPE (new_type, i)
+ = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
+ copied_types);
+ if (TYPE_FIELD_NAME (type, i))
+ TYPE_FIELD_NAME (new_type, i) =
+ xstrdup (TYPE_FIELD_NAME (type, i));
+ switch (TYPE_FIELD_LOC_KIND (type, i))
+ {
+ case FIELD_LOC_KIND_BITPOS:
+ SET_FIELD_BITPOS (TYPE_FIELD (new_type, i),
+ TYPE_FIELD_BITPOS (type, i));
+ break;
+ case FIELD_LOC_KIND_PHYSADDR:
+ SET_FIELD_PHYSADDR (TYPE_FIELD (new_type, i),
+ TYPE_FIELD_STATIC_PHYSADDR (type, i));
+ break;
+ case FIELD_LOC_KIND_PHYSNAME:
+ SET_FIELD_PHYSNAME (TYPE_FIELD (new_type, i),
+ xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
+ i)));
+ break;
+ default:
+ internal_error (__FILE__, __LINE__,
+ _("Unexpected type field location kind: %d"),
+ TYPE_FIELD_LOC_KIND (type, i));
+ }
+ }
+ }
+
+ /* For range types, copy the bounds information. */
+ if (TYPE_CODE (type) == TYPE_CODE_RANGE)
+ {
+ TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+ *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
+ }
+
+ /* Copy pointers to other types. */
+ if (TYPE_TARGET_TYPE (type))
+ TYPE_TARGET_TYPE (new_type) =
+ copy_type_recursive (objfile,
+ TYPE_TARGET_TYPE (type),
+ copied_types);
+ if (TYPE_VPTR_BASETYPE (type))
+ TYPE_VPTR_BASETYPE (new_type) =
+ copy_type_recursive (objfile,
+ TYPE_VPTR_BASETYPE (type),
+ copied_types);
+ /* Maybe copy the type_specific bits.
+
+ NOTE drow/2005-12-09: We do not copy the C++-specific bits like
+ base classes and methods. There's no fundamental reason why we
+ can't, but at the moment it is not needed. */
+
+ if (TYPE_CODE (type) == TYPE_CODE_FLT)
+ TYPE_FLOATFORMAT (new_type) = TYPE_FLOATFORMAT (type);
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_TEMPLATE
+ || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
+ INIT_CPLUS_SPECIFIC (new_type);
+
+ return new_type;
+}
+
+/* Make a copy of the given TYPE, except that the pointer & reference
+ types are not preserved.
+
+ This function assumes that the given type has an associated objfile.
+ This objfile is used to allocate the new type. */
+
+struct type *
+copy_type (const struct type *type)
+{
+ struct type *new_type;
+
+ gdb_assert (TYPE_OBJFILE_OWNED (type));
+
+ new_type = alloc_type_copy (type);
+ TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
+ TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+ memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
+ sizeof (struct main_type));
+
+ return new_type;
+}
+
+
+/* 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 length, char *name)
+{
+ struct type *type;
+
+ type = alloc_type_arch (gdbarch);
+ TYPE_CODE (type) = code;
+ TYPE_LENGTH (type) = length;
+
+ if (name)
+ TYPE_NAME (type) = xstrdup (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 *
+arch_integer_type (struct gdbarch *gdbarch,
+ int bit, int unsigned_p, char *name)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
+ if (unsigned_p)
+ TYPE_UNSIGNED (t) = 1;
+ if (name && strcmp (name, "char") == 0)
+ TYPE_NOSIGN (t) = 1;
+
+ return t;
+}
+
+/* Allocate a TYPE_CODE_CHAR 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_character_type (struct gdbarch *gdbarch,
+ int bit, int unsigned_p, char *name)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_CHAR, bit / TARGET_CHAR_BIT, name);
+ if (unsigned_p)
+ TYPE_UNSIGNED (t) = 1;
+
+ return t;
+}
+
+/* Allocate a TYPE_CODE_BOOL 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_boolean_type (struct gdbarch *gdbarch,
+ int bit, int unsigned_p, char *name)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_BOOL, bit / TARGET_CHAR_BIT, name);
+ if (unsigned_p)
+ TYPE_UNSIGNED (t) = 1;
+
+ return t;
+}
+
+/* Allocate a TYPE_CODE_FLT type structure associated with GDBARCH.
+ BIT is the type size in bits; if BIT equals -1, the size is
+ determined by the floatformat. NAME is the type name. Set the
+ TYPE_FLOATFORMAT from FLOATFORMATS. */
+struct type *
+arch_float_type (struct gdbarch *gdbarch,
+ int bit, char *name, const struct floatformat **floatformats)
+{
+ struct type *t;
+
+ if (bit == -1)
+ {
+ gdb_assert (floatformats != NULL);
+ gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
+ bit = floatformats[0]->totalsize;
+ }
+ gdb_assert (bit >= 0);
+
+ t = arch_type (gdbarch, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
+ TYPE_FLOATFORMAT (t) = floatformats;
+ return t;
+}
+
+/* Allocate a TYPE_CODE_COMPLEX type structure associated with GDBARCH.
+ NAME is the type name. TARGET_TYPE is the component float type. */
+struct type *
+arch_complex_type (struct gdbarch *gdbarch,
+ char *name, struct type *target_type)
+{
+ struct type *t;
+ t = arch_type (gdbarch, TYPE_CODE_COMPLEX,
+ 2 * TYPE_LENGTH (target_type), name);
+ TYPE_TARGET_TYPE (t) = target_type;
+ return t;
+}
+
+/* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
+ NAME is the type name. LENGTH is the number of flag bits. */
+struct type *
+arch_flags_type (struct gdbarch *gdbarch, char *name, int length)
+{
+ int nfields = length * TARGET_CHAR_BIT;
+ struct type *type;
+
+ type = arch_type (gdbarch, TYPE_CODE_FLAGS, length, name);
+ TYPE_UNSIGNED (type) = 1;
+ TYPE_NFIELDS (type) = nfields;
+ TYPE_FIELDS (type) = TYPE_ZALLOC (type, nfields * sizeof (struct field));
+
+ return type;
+}
+
+/* Add field to TYPE_CODE_FLAGS type TYPE to indicate the bit at
+ position BITPOS is called NAME. */
+void
+append_flags_type_flag (struct type *type, int bitpos, char *name)
+{
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLAGS);
+ gdb_assert (bitpos < TYPE_NFIELDS (type));
+ gdb_assert (bitpos >= 0);
+
+ if (name)
+ {
+ TYPE_FIELD_NAME (type, bitpos) = xstrdup (name);
+ TYPE_FIELD_BITPOS (type, bitpos) = bitpos;
+ }
+ else
+ {
+ /* Don't show this field to the user. */
+ TYPE_FIELD_BITPOS (type, bitpos) = -1;
+ }
+}
+
+/* Allocate a TYPE_CODE_STRUCT or TYPE_CODE_UNION type structure (as
+ specified by CODE) associated with GDBARCH. NAME is the type name. */
+struct type *
+arch_composite_type (struct gdbarch *gdbarch, char *name, enum type_code code)
+{
+ struct type *t;
+ gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION);
+ t = arch_type (gdbarch, code, 0, NULL);
+ TYPE_TAG_NAME (t) = name;
+ INIT_CPLUS_SPECIFIC (t);
+ return t;
+}
+
+/* Add new field with name NAME and type FIELD to composite type T.
+ ALIGNMENT (if non-zero) specifies the minimum field alignment. */
+void
+append_composite_type_field_aligned (struct type *t, char *name,
+ struct type *field, int alignment)
+{
+ struct field *f;
+ TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
+ TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t),
+ sizeof (struct field) * TYPE_NFIELDS (t));
+ f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
+ memset (f, 0, sizeof f[0]);
+ FIELD_TYPE (f[0]) = field;
+ FIELD_NAME (f[0]) = name;
+ if (TYPE_CODE (t) == TYPE_CODE_UNION)
+ {
+ if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
+ TYPE_LENGTH (t) = TYPE_LENGTH (field);
+ }
+ else if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
+ {
+ TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
+ if (TYPE_NFIELDS (t) > 1)
+ {
+ FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
+ + (TYPE_LENGTH (FIELD_TYPE (f[-1]))
+ * TARGET_CHAR_BIT));
+
+ if (alignment)
+ {
+ int left = FIELD_BITPOS (f[0]) % (alignment * TARGET_CHAR_BIT);
+ if (left)
+ {
+ FIELD_BITPOS (f[0]) += left;
+ TYPE_LENGTH (t) += left / TARGET_CHAR_BIT;
+ }
+ }
+ }
+ }
+}
+
+/* Add new field with name NAME and type FIELD to composite type T. */
+void
+append_composite_type_field (struct type *t, char *name,
+ struct type *field)
+{
+ append_composite_type_field_aligned (t, name, field, 0);
+}
+
+
+static struct gdbarch_data *gdbtypes_data;
+
+const struct builtin_type *
+builtin_type (struct gdbarch *gdbarch)
+{
+ return gdbarch_data (gdbarch, gdbtypes_data);
+}
+
+static void *
+gdbtypes_post_init (struct gdbarch *gdbarch)
+{
+ struct builtin_type *builtin_type
+ = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_type);
+
+ /* Basic types. */
+ builtin_type->builtin_void
+ = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+ builtin_type->builtin_char
+ = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
+ !gdbarch_char_signed (gdbarch), "char");
+ builtin_type->builtin_signed_char
+ = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
+ 0, "signed char");
+ builtin_type->builtin_unsigned_char
+ = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
+ 1, "unsigned char");
+ builtin_type->builtin_short
+ = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch),
+ 0, "short");
+ builtin_type->builtin_unsigned_short
+ = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch),
+ 1, "unsigned short");
+ builtin_type->builtin_int
+ = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 0, "int");
+ builtin_type->builtin_unsigned_int
+ = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 1, "unsigned int");
+ builtin_type->builtin_long
+ = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ 0, "long");
+ builtin_type->builtin_unsigned_long
+ = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ 1, "unsigned long");
+ builtin_type->builtin_long_long
+ = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch),
+ 0, "long long");
+ builtin_type->builtin_unsigned_long_long
+ = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch),
+ 1, "unsigned long long");
+ builtin_type->builtin_float
+ = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+ "float", gdbarch_float_format (gdbarch));
+ builtin_type->builtin_double
+ = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+ "double", gdbarch_double_format (gdbarch));
+ builtin_type->builtin_long_double
+ = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+ "long double", gdbarch_long_double_format (gdbarch));
+ builtin_type->builtin_complex
+ = arch_complex_type (gdbarch, "complex",
+ builtin_type->builtin_float);
+ builtin_type->builtin_double_complex
+ = arch_complex_type (gdbarch, "double complex",
+ builtin_type->builtin_double);
+ builtin_type->builtin_string
+ = arch_type (gdbarch, TYPE_CODE_STRING, 1, "string");
+ builtin_type->builtin_bool
+ = arch_type (gdbarch, TYPE_CODE_BOOL, 1, "bool");
+
+ /* The following three are about decimal floating point types, which
+ are 32-bits, 64-bits and 128-bits respectively. */
+ builtin_type->builtin_decfloat
+ = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 32 / 8, "_Decimal32");
+ builtin_type->builtin_decdouble
+ = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 64 / 8, "_Decimal64");
+ builtin_type->builtin_declong
+ = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 128 / 8, "_Decimal128");
+
+ /* "True" character types. */
+ builtin_type->builtin_true_char
+ = arch_character_type (gdbarch, TARGET_CHAR_BIT, 0, "true character");
+ builtin_type->builtin_true_unsigned_char
+ = arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "true character");
+
+ /* Fixed-size integer types. */
+ builtin_type->builtin_int0
+ = arch_integer_type (gdbarch, 0, 0, "int0_t");
+ builtin_type->builtin_int8
+ = arch_integer_type (gdbarch, 8, 0, "int8_t");
+ builtin_type->builtin_uint8
+ = arch_integer_type (gdbarch, 8, 1, "uint8_t");
+ builtin_type->builtin_int16
+ = arch_integer_type (gdbarch, 16, 0, "int16_t");
+ builtin_type->builtin_uint16
+ = arch_integer_type (gdbarch, 16, 1, "uint16_t");
+ builtin_type->builtin_int32
+ = arch_integer_type (gdbarch, 32, 0, "int32_t");
+ builtin_type->builtin_uint32
+ = arch_integer_type (gdbarch, 32, 1, "uint32_t");
+ builtin_type->builtin_int64
+ = arch_integer_type (gdbarch, 64, 0, "int64_t");
+ builtin_type->builtin_uint64
+ = arch_integer_type (gdbarch, 64, 1, "uint64_t");
+ builtin_type->builtin_int128
+ = arch_integer_type (gdbarch, 128, 0, "int128_t");
+ builtin_type->builtin_uint128
+ = arch_integer_type (gdbarch, 128, 1, "uint128_t");
+ TYPE_NOTTEXT (builtin_type->builtin_int8) = 1;
+ TYPE_NOTTEXT (builtin_type->builtin_uint8) = 1;
+
+ /* Default data/code pointer types. */
+ builtin_type->builtin_data_ptr
+ = lookup_pointer_type (builtin_type->builtin_void);
+ builtin_type->builtin_func_ptr
+ = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
+
+ /* This type represents a GDB internal function. */
+ builtin_type->internal_fn
+ = arch_type (gdbarch, TYPE_CODE_INTERNAL_FUNCTION, 0,
+ "<internal function>");
+
+ return builtin_type;
+}
+
+
+/* This set of objfile-based types is intended to be used by symbol
+ readers as basic types. */
+
+static const struct objfile_data *objfile_type_data;
+
+const struct objfile_type *
+objfile_type (struct objfile *objfile)
+{
+ struct gdbarch *gdbarch;
+ struct objfile_type *objfile_type
+ = objfile_data (objfile, objfile_type_data);
+
+ if (objfile_type)
+ return objfile_type;
+
+ objfile_type = OBSTACK_CALLOC (&objfile->objfile_obstack,
+ 1, struct objfile_type);
+
+ /* Use the objfile architecture to determine basic type properties. */
+ gdbarch = get_objfile_arch (objfile);
+
+ /* Basic types. */
+ objfile_type->builtin_void
+ = init_type (TYPE_CODE_VOID, 1,
+ 0,
+ "void", objfile);
+
+ objfile_type->builtin_char
+ = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ (TYPE_FLAG_NOSIGN
+ | (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
+ "char", objfile);
+ objfile_type->builtin_signed_char
+ = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0,
+ "signed char", objfile);
+ objfile_type->builtin_unsigned_char
+ = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned char", objfile);
+ objfile_type->builtin_short
+ = init_type (TYPE_CODE_INT,
+ gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "short", objfile);
+ objfile_type->builtin_unsigned_short
+ = init_type (TYPE_CODE_INT,
+ gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
+ objfile_type->builtin_int
+ = init_type (TYPE_CODE_INT,
+ gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "int", objfile);
+ objfile_type->builtin_unsigned_int
+ = init_type (TYPE_CODE_INT,
+ gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
+ objfile_type->builtin_long
+ = init_type (TYPE_CODE_INT,
+ gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "long", objfile);
+ objfile_type->builtin_unsigned_long
+ = init_type (TYPE_CODE_INT,
+ gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
+ objfile_type->builtin_long_long
+ = init_type (TYPE_CODE_INT,
+ gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "long long", objfile);
+ objfile_type->builtin_unsigned_long_long
+ = init_type (TYPE_CODE_INT,
+ gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
+
+ objfile_type->builtin_float
+ = init_type (TYPE_CODE_FLT,
+ gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "float", objfile);
+ TYPE_FLOATFORMAT (objfile_type->builtin_float)
+ = gdbarch_float_format (gdbarch);
+ objfile_type->builtin_double
+ = init_type (TYPE_CODE_FLT,
+ gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "double", objfile);
+ TYPE_FLOATFORMAT (objfile_type->builtin_double)
+ = gdbarch_double_format (gdbarch);
+ objfile_type->builtin_long_double
+ = init_type (TYPE_CODE_FLT,
+ gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
+ 0, "long double", objfile);
+ TYPE_FLOATFORMAT (objfile_type->builtin_long_double)
+ = gdbarch_long_double_format (gdbarch);
+
+ /* This type represents a type that was unrecognized in symbol read-in. */
+ objfile_type->builtin_error
+ = init_type (TYPE_CODE_ERROR, 0, 0, "<unknown type>", objfile);
+
+ /* The following set of types is used for symbols with no
+ debug information. */
+ objfile_type->nodebug_text_symbol
+ = init_type (TYPE_CODE_FUNC, 1, 0,
+ "<text variable, no debug info>", objfile);
+ TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol)
+ = objfile_type->builtin_int;
+ objfile_type->nodebug_data_symbol
+ = init_type (TYPE_CODE_INT,
+ gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
+ "<data variable, no debug info>", objfile);
+ objfile_type->nodebug_unknown_symbol
+ = init_type (TYPE_CODE_INT, 1, 0,
+ "<variable (not text or data), no debug info>", objfile);
+ objfile_type->nodebug_tls_symbol
+ = init_type (TYPE_CODE_INT,
+ gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
+ "<thread local variable, no debug info>", objfile);
+
+ /* NOTE: on some targets, addresses and pointers are not necessarily
+ the same --- for example, on the D10V, pointers are 16 bits long,
+ but addresses are 32 bits long. See doc/gdbint.texinfo,
+ ``Pointers Are Not Always Addresses''.
+
+ The upshot is:
+ - gdb's `struct type' always describes the target's
+ representation.
+ - gdb's `struct value' objects should always hold values in
+ target form.
+ - gdb's CORE_ADDR values are addresses in the unified virtual
+ address space that the assembler and linker work with. Thus,
+ since target_read_memory takes a CORE_ADDR as an argument, it
+ can access any memory on the target, even if the processor has
+ separate code and data address spaces.
+
+ So, for example:
+ - If v is a value holding a D10V code pointer, its contents are
+ in target form: a big-endian address left-shifted two bits.
+ - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
+ sizeof (void *) == 2 on the target.
+
+ In this context, objfile_type->builtin_core_addr is a bit odd:
+ it's a target type for a value the target will never see. It's
+ only used to hold the values of (typeless) linker symbols, which
+ are indeed in the unified virtual address space. */
+
+ objfile_type->builtin_core_addr
+ = init_type (TYPE_CODE_INT,
+ gdbarch_addr_bit (gdbarch) / 8,
+ TYPE_FLAG_UNSIGNED, "__CORE_ADDR", objfile);
+
+ set_objfile_data (objfile, objfile_type_data, objfile_type);
+ return objfile_type;