Unify init_type and arch_type interface and helpers

This adds a number of helper routines for creating objfile-owned types;
these correspond 1:1 to the already existing helper routines for creating
gdbarch-owned types, and are intended to be used instead of init_type.
A shared fragment of init_float_type and arch_float_type is extracted into
a separate subroutine verify_subroutine.

The commit also brings the interface of init_type in line with the one for
arch_type.  In particular, this means removing the FLAGS argument; callers
now set the required flags directly.  (Since most callers use the new
helper routines, very few callers actually need to set any additional
flags directly any more.)

Note that this means all the TYPE_FLAGS_... defined are no longer needed
anywhere; they will be removed by a follow-on commit.

All users of init_type are changed to use on of the new helpers where
possible.  No functional change intended.

gdb/ChangeLog:

	* gdbtypes.h (init_type): Remove FLAGS argument.  Move OBJFILE
	argument to first position.
	(init_integer_type): New prototype.
	(init_character_type): Likewise.
	(init_boolean_type): Likewise.
	(init_float_type): Likewise.
	(init_decfloat_type): Likewise.
	(init_complex_type): Likewise.
	(init_pointer_type): Likewise.
	* gdbtypes.c (verify_floatflormat): New function.
	(init_type): Remove FLAGS argument and processing.  Move OBJFILE
	argument to first position.
	(init_integer_type): New function.
	(init_character_type): Likewise.
	(init_boolean_type): Likewise.
	(init_float_type): Likewise.
	(init_decfloat_type): Likewise.
	(init_complex_type): Likewise.
	(init_pointer_type): Likewise.
	(arch_float_type): Use verify_floatflormat.
	(objfile_type): Use init_..._type helpers instead of calling
	init_type directly.
	* dwarf2read.c (fixup_go_packaging): Update to changed init_type
	prototype.
	(read_namespace_type): Likewise.
	(read_module_type): Likewise.
	(read_typedef): Likewise.
	(read_unspecified_type): Likewise.
	(build_error_marker_type): Likewise.
	(read_base_type): Use init_..._type helpers.
	* mdebugread.c (basic_type): Use init_..._type helpers.
	(parse_type): Update to changed init_type prototype.
	(cross_ref): Likewise.
	* stabsread.c (rs6000_builtin_type): Use init_..._type helpers.
	(read_sun_builtin_type): Likewise.
	(read_sun_floating_type): Likewise.
	(read_range_type): Likewise.  Also update to changed init_type
	prototype.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
This commit is contained in:
Ulrich Weigand 2016-09-06 17:27:55 +02:00
parent 88dfca6c43
commit 19f392bc2a
6 changed files with 388 additions and 317 deletions

View File

@ -1,3 +1,44 @@
2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.h (init_type): Remove FLAGS argument. Move OBJFILE
argument to first position.
(init_integer_type): New prototype.
(init_character_type): Likewise.
(init_boolean_type): Likewise.
(init_float_type): Likewise.
(init_decfloat_type): Likewise.
(init_complex_type): Likewise.
(init_pointer_type): Likewise.
* gdbtypes.c (verify_floatflormat): New function.
(init_type): Remove FLAGS argument and processing. Move OBJFILE
argument to first position.
(init_integer_type): New function.
(init_character_type): Likewise.
(init_boolean_type): Likewise.
(init_float_type): Likewise.
(init_decfloat_type): Likewise.
(init_complex_type): Likewise.
(init_pointer_type): Likewise.
(arch_float_type): Use verify_floatflormat.
(objfile_type): Use init_..._type helpers instead of calling
init_type directly.
* dwarf2read.c (fixup_go_packaging): Update to changed init_type
prototype.
(read_namespace_type): Likewise.
(read_module_type): Likewise.
(read_typedef): Likewise.
(read_unspecified_type): Likewise.
(build_error_marker_type): Likewise.
(read_base_type): Use init_..._type helpers.
* mdebugread.c (basic_type): Use init_..._type helpers.
(parse_type): Update to changed init_type prototype.
(cross_ref): Likewise.
* stabsread.c (rs6000_builtin_type): Use init_..._type helpers.
(read_sun_builtin_type): Likewise.
(read_sun_floating_type): Likewise.
(read_range_type): Likewise. Also update to changed init_type
prototype.
2016-09-05 Ulrich Weigand <uweigand@de.ibm.com> 2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.h (arch_decfloat_type): New prototype. * gdbtypes.h (arch_decfloat_type): New prototype.

View File

@ -7865,8 +7865,8 @@ fixup_go_packaging (struct dwarf2_cu *cu)
= (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack, = (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
package_name, package_name,
strlen (package_name)); strlen (package_name));
struct type *type = init_type (TYPE_CODE_MODULE, 0, 0, struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
saved_package_name, objfile); saved_package_name);
struct symbol *sym; struct symbol *sym;
TYPE_TAG_NAME (type) = TYPE_NAME (type); TYPE_TAG_NAME (type) = TYPE_NAME (type);
@ -14136,9 +14136,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
previous_prefix, name, 0, cu); previous_prefix, name, 0, cu);
/* Create the type. */ /* Create the type. */
type = init_type (TYPE_CODE_NAMESPACE, 0, 0, NULL, type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name);
objfile);
TYPE_NAME (type) = name;
TYPE_TAG_NAME (type) = TYPE_NAME (type); TYPE_TAG_NAME (type) = TYPE_NAME (type);
return set_die_type (die, type, cu); return set_die_type (die, type, cu);
@ -14202,7 +14200,7 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
complaint (&symfile_complaints, complaint (&symfile_complaints,
_("DW_TAG_module has no name, offset 0x%x"), _("DW_TAG_module has no name, offset 0x%x"),
die->offset.sect_off); die->offset.sect_off);
type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile); type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
/* determine_prefix uses TYPE_TAG_NAME. */ /* determine_prefix uses TYPE_TAG_NAME. */
TYPE_TAG_NAME (type) = TYPE_NAME (type); TYPE_TAG_NAME (type) = TYPE_NAME (type);
@ -14740,9 +14738,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
struct type *this_type, *target_type; struct type *this_type, *target_type;
name = dwarf2_full_name (NULL, die, cu); name = dwarf2_full_name (NULL, die, cu);
this_type = init_type (TYPE_CODE_TYPEDEF, 0, this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
TYPE_FLAG_TARGET_STUB, NULL, objfile); TYPE_TARGET_STUB (this_type) = 1;
TYPE_NAME (this_type) = name;
set_die_type (die, this_type, cu); set_die_type (die, this_type, cu);
target_type = die_type (die, cu); target_type = die_type (die, cu);
if (target_type != this_type) if (target_type != this_type)
@ -14769,11 +14766,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
struct objfile *objfile = cu->objfile; struct objfile *objfile = cu->objfile;
struct type *type; struct type *type;
struct attribute *attr; struct attribute *attr;
int encoding = 0, size = 0; int encoding = 0, bits = 0;
const char *name; const char *name;
enum type_code code = TYPE_CODE_INT;
int type_flags = 0;
struct type *target_type = NULL;
attr = dwarf2_attr (die, DW_AT_encoding, cu); attr = dwarf2_attr (die, DW_AT_encoding, cu);
if (attr) if (attr)
@ -14783,7 +14777,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_byte_size, cu); attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr) if (attr)
{ {
size = DW_UNSND (attr); bits = DW_UNSND (attr) * TARGET_CHAR_BIT;
} }
name = dwarf2_name (die, cu); name = dwarf2_name (die, cu);
if (!name) if (!name)
@ -14796,62 +14790,64 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
{ {
case DW_ATE_address: case DW_ATE_address:
/* Turn DW_ATE_address into a void * pointer. */ /* Turn DW_ATE_address into a void * pointer. */
code = TYPE_CODE_PTR; type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
type_flags |= TYPE_FLAG_UNSIGNED; type = init_pointer_type (objfile, bits, name, type);
target_type = init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
break; break;
case DW_ATE_boolean: case DW_ATE_boolean:
code = TYPE_CODE_BOOL; type = init_boolean_type (objfile, bits, 1, name);
type_flags |= TYPE_FLAG_UNSIGNED;
break; break;
case DW_ATE_complex_float: case DW_ATE_complex_float:
code = TYPE_CODE_COMPLEX; type = init_float_type (objfile, bits / 2, NULL, NULL);
target_type = init_type (TYPE_CODE_FLT, size / 2, 0, NULL, objfile); type = init_complex_type (objfile, name, type);
break; break;
case DW_ATE_decimal_float: case DW_ATE_decimal_float:
code = TYPE_CODE_DECFLOAT; type = init_decfloat_type (objfile, bits, name);
break; break;
case DW_ATE_float: case DW_ATE_float:
code = TYPE_CODE_FLT; type = init_float_type (objfile, bits, name, NULL);
break; break;
case DW_ATE_signed: case DW_ATE_signed:
type = init_integer_type (objfile, bits, 0, name);
break; break;
case DW_ATE_unsigned: case DW_ATE_unsigned:
type_flags |= TYPE_FLAG_UNSIGNED;
if (cu->language == language_fortran if (cu->language == language_fortran
&& name && name
&& startswith (name, "character(")) && startswith (name, "character("))
code = TYPE_CODE_CHAR; type = init_character_type (objfile, bits, 1, name);
else
type = init_integer_type (objfile, bits, 1, name);
break; break;
case DW_ATE_signed_char: case DW_ATE_signed_char:
if (cu->language == language_ada || cu->language == language_m2 if (cu->language == language_ada || cu->language == language_m2
|| cu->language == language_pascal || cu->language == language_pascal
|| cu->language == language_fortran) || cu->language == language_fortran)
code = TYPE_CODE_CHAR; type = init_character_type (objfile, bits, 0, name);
else
type = init_integer_type (objfile, bits, 0, name);
break; break;
case DW_ATE_unsigned_char: case DW_ATE_unsigned_char:
if (cu->language == language_ada || cu->language == language_m2 if (cu->language == language_ada || cu->language == language_m2
|| cu->language == language_pascal || cu->language == language_pascal
|| cu->language == language_fortran || cu->language == language_fortran
|| cu->language == language_rust) || cu->language == language_rust)
code = TYPE_CODE_CHAR; type = init_character_type (objfile, bits, 1, name);
type_flags |= TYPE_FLAG_UNSIGNED; else
type = init_integer_type (objfile, bits, 1, name);
break; break;
case DW_ATE_UTF: case DW_ATE_UTF:
/* We just treat this as an integer and then recognize the /* We just treat this as an integer and then recognize the
type by name elsewhere. */ type by name elsewhere. */
type = init_integer_type (objfile, bits, 0, name);
break; break;
default: default:
complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"), complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
dwarf_type_encoding_name (encoding)); dwarf_type_encoding_name (encoding));
type = init_type (objfile, TYPE_CODE_ERROR,
bits / TARGET_CHAR_BIT, name);
break; break;
} }
type = init_type (code, size, type_flags, NULL, objfile);
TYPE_NAME (type) = name;
TYPE_TARGET_TYPE (type) = target_type;
if (name && strcmp (name, "char") == 0) if (name && strcmp (name, "char") == 0)
TYPE_NOSIGN (type) = 1; TYPE_NOSIGN (type) = 1;
@ -15131,7 +15127,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
/* For now, we only support the C meaning of an unspecified type: void. */ /* For now, we only support the C meaning of an unspecified type: void. */
type = init_type (TYPE_CODE_VOID, 0, 0, NULL, cu->objfile); type = init_type (cu->objfile, TYPE_CODE_VOID, 0, NULL);
TYPE_NAME (type) = dwarf2_name (die, cu); TYPE_NAME (type) = dwarf2_name (die, cu);
return set_die_type (die, type, cu); return set_die_type (die, type, cu);
@ -19027,7 +19023,7 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
message, strlen (message)); message, strlen (message));
xfree (message); xfree (message);
return init_type (TYPE_CODE_ERROR, 0, 0, saved, objfile); return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
} }
/* Look up the type of DIE in CU using its type attribute ATTR. /* Look up the type of DIE in CU using its type attribute ATTR.

View File

@ -2705,6 +2705,32 @@ set_type_code (struct type *type, enum type_code code)
} }
} }
/* Helper function to verify floating-point format and size.
BIT is the type size in bits; if BIT equals -1, the size is
determined by the floatformat. Returns size to be used. */
static int
verify_floatformat (int bit, const struct floatformat **floatformats)
{
if (bit == -1)
{
gdb_assert (floatformats != NULL);
gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
bit = floatformats[0]->totalsize;
}
gdb_assert (bit >= 0);
if (floatformats != NULL)
{
size_t len = bit / TARGET_CHAR_BIT;
gdb_assert (len >= floatformat_totalsize_bytes (floatformats[0]));
gdb_assert (len >= floatformat_totalsize_bytes (floatformats[1]));
}
return bit;
}
/* Helper function to initialize the standard scalar types. /* Helper function to initialize the standard scalar types.
If NAME is non-NULL, then it is used to initialize the type name. If NAME is non-NULL, then it is used to initialize the type name.
@ -2712,41 +2738,14 @@ set_type_code (struct type *type, enum type_code code)
least as long as OBJFILE. */ least as long as OBJFILE. */
struct type * struct type *
init_type (enum type_code code, int length, int flags, init_type (struct objfile *objfile, enum type_code code, int length,
const char *name, struct objfile *objfile) const char *name)
{ {
struct type *type; struct type *type;
type = alloc_type (objfile); type = alloc_type (objfile);
set_type_code (type, code); set_type_code (type, code);
TYPE_LENGTH (type) = length; TYPE_LENGTH (type) = length;
gdb_assert (!(flags & (TYPE_FLAG_MIN - 1)));
if (flags & TYPE_FLAG_UNSIGNED)
TYPE_UNSIGNED (type) = 1;
if (flags & TYPE_FLAG_NOSIGN)
TYPE_NOSIGN (type) = 1;
if (flags & TYPE_FLAG_STUB)
TYPE_STUB (type) = 1;
if (flags & TYPE_FLAG_TARGET_STUB)
TYPE_TARGET_STUB (type) = 1;
if (flags & TYPE_FLAG_STATIC)
TYPE_STATIC (type) = 1;
if (flags & TYPE_FLAG_PROTOTYPED)
TYPE_PROTOTYPED (type) = 1;
if (flags & TYPE_FLAG_INCOMPLETE)
TYPE_INCOMPLETE (type) = 1;
if (flags & TYPE_FLAG_VARARGS)
TYPE_VARARGS (type) = 1;
if (flags & TYPE_FLAG_VECTOR)
TYPE_VECTOR (type) = 1;
if (flags & TYPE_FLAG_STUB_SUPPORTED)
TYPE_STUB_SUPPORTED (type) = 1;
if (flags & TYPE_FLAG_FIXED_INSTANCE)
TYPE_FIXED_INSTANCE (type) = 1;
if (flags & TYPE_FLAG_GNU_IFUNC)
TYPE_GNU_IFUNC (type) = 1;
TYPE_NAME (type) = name; TYPE_NAME (type) = name;
/* C++ fancies. */ /* C++ fancies. */
@ -2756,6 +2755,121 @@ init_type (enum type_code code, int length, int flags,
return type; return type;
} }
/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE.
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 *
init_integer_type (struct objfile *objfile,
int bit, int unsigned_p, const char *name)
{
struct type *t;
t = init_type (objfile, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
if (unsigned_p)
TYPE_UNSIGNED (t) = 1;
return t;
}
/* Allocate a TYPE_CODE_CHAR type structure associated with OBJFILE.
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 *
init_character_type (struct objfile *objfile,
int bit, int unsigned_p, const char *name)
{
struct type *t;
t = init_type (objfile, 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 OBJFILE.
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 *
init_boolean_type (struct objfile *objfile,
int bit, int unsigned_p, const char *name)
{
struct type *t;
t = init_type (objfile, 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 OBJFILE.
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 *
init_float_type (struct objfile *objfile,
int bit, const char *name,
const struct floatformat **floatformats)
{
struct type *t;
bit = verify_floatformat (bit, floatformats);
t = init_type (objfile, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
TYPE_FLOATFORMAT (t) = floatformats;
return t;
}
/* Allocate a TYPE_CODE_DECFLOAT type structure associated with OBJFILE.
BIT is the type size in bits. NAME is the type name. */
struct type *
init_decfloat_type (struct objfile *objfile, int bit, const char *name)
{
struct type *t;
t = init_type (objfile, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
return t;
}
/* Allocate a TYPE_CODE_COMPLEX type structure associated with OBJFILE.
NAME is the type name. TARGET_TYPE is the component float type. */
struct type *
init_complex_type (struct objfile *objfile,
const char *name, struct type *target_type)
{
struct type *t;
t = init_type (objfile, TYPE_CODE_COMPLEX,
2 * TYPE_LENGTH (target_type), name);
TYPE_TARGET_TYPE (t) = target_type;
return t;
}
/* 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. */
struct type *
init_pointer_type (struct objfile *objfile,
int bit, const char *name, struct type *target_type)
{
struct type *t;
t = init_type (objfile, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
TYPE_TARGET_TYPE (t) = target_type;
TYPE_UNSIGNED (t) = 1;
return t;
}
/* Queries on types. */ /* Queries on types. */
@ -4718,25 +4832,10 @@ arch_float_type (struct gdbarch *gdbarch,
{ {
struct type *t; struct type *t;
if (bit == -1) bit = verify_floatformat (bit, floatformats);
{
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); t = arch_type (gdbarch, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
TYPE_FLOATFORMAT (t) = floatformats; TYPE_FLOATFORMAT (t) = floatformats;
if (floatformats != NULL)
{
size_t len = TYPE_LENGTH (t);
gdb_assert (len >= floatformat_totalsize_bytes (floatformats[0]));
gdb_assert (len >= floatformat_totalsize_bytes (floatformats[1]));
}
return t; return t;
} }
@ -5090,109 +5189,80 @@ objfile_type (struct objfile *objfile)
/* Basic types. */ /* Basic types. */
objfile_type->builtin_void objfile_type->builtin_void
= init_type (TYPE_CODE_VOID, 1, = init_type (objfile, TYPE_CODE_VOID, 1, "void");
0,
"void", objfile);
objfile_type->builtin_char objfile_type->builtin_char
= init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, = init_integer_type (objfile, TARGET_CHAR_BIT,
(TYPE_FLAG_NOSIGN !gdbarch_char_signed (gdbarch), "char");
| (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
"char", objfile);
objfile_type->builtin_signed_char objfile_type->builtin_signed_char
= init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, = init_integer_type (objfile, TARGET_CHAR_BIT,
0, 0, "signed char");
"signed char", objfile);
objfile_type->builtin_unsigned_char objfile_type->builtin_unsigned_char
= init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, = init_integer_type (objfile, TARGET_CHAR_BIT,
TYPE_FLAG_UNSIGNED, 1, "unsigned char");
"unsigned char", objfile);
objfile_type->builtin_short objfile_type->builtin_short
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_short_bit (gdbarch),
gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT, 0, "short");
0, "short", objfile);
objfile_type->builtin_unsigned_short objfile_type->builtin_unsigned_short
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_short_bit (gdbarch),
gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT, 1, "unsigned short");
TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
objfile_type->builtin_int objfile_type->builtin_int
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_int_bit (gdbarch),
gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT, 0, "int");
0, "int", objfile);
objfile_type->builtin_unsigned_int objfile_type->builtin_unsigned_int
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_int_bit (gdbarch),
gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT, 1, "unsigned int");
TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
objfile_type->builtin_long objfile_type->builtin_long
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_long_bit (gdbarch),
gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT, 0, "long");
0, "long", objfile);
objfile_type->builtin_unsigned_long objfile_type->builtin_unsigned_long
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_long_bit (gdbarch),
gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT, 1, "unsigned long");
TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
objfile_type->builtin_long_long objfile_type->builtin_long_long
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch),
gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT, 0, "long long");
0, "long long", objfile);
objfile_type->builtin_unsigned_long_long objfile_type->builtin_unsigned_long_long
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch),
gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT, 1, "unsigned long long");
TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
objfile_type->builtin_float objfile_type->builtin_float
= init_type (TYPE_CODE_FLT, = init_float_type (objfile, gdbarch_float_bit (gdbarch),
gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT, "float", gdbarch_float_format (gdbarch));
0, "float", objfile);
TYPE_FLOATFORMAT (objfile_type->builtin_float)
= gdbarch_float_format (gdbarch);
objfile_type->builtin_double objfile_type->builtin_double
= init_type (TYPE_CODE_FLT, = init_float_type (objfile, gdbarch_double_bit (gdbarch),
gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, "double", gdbarch_double_format (gdbarch));
0, "double", objfile);
TYPE_FLOATFORMAT (objfile_type->builtin_double)
= gdbarch_double_format (gdbarch);
objfile_type->builtin_long_double objfile_type->builtin_long_double
= init_type (TYPE_CODE_FLT, = init_float_type (objfile, gdbarch_long_double_bit (gdbarch),
gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT, "long double", gdbarch_long_double_format (gdbarch));
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. */ /* This type represents a type that was unrecognized in symbol read-in. */
objfile_type->builtin_error objfile_type->builtin_error
= init_type (TYPE_CODE_ERROR, 0, 0, "<unknown type>", objfile); = init_type (objfile, TYPE_CODE_ERROR, 0, "<unknown type>");
/* The following set of types is used for symbols with no /* The following set of types is used for symbols with no
debug information. */ debug information. */
objfile_type->nodebug_text_symbol objfile_type->nodebug_text_symbol
= init_type (TYPE_CODE_FUNC, 1, 0, = init_type (objfile, TYPE_CODE_FUNC, 1,
"<text variable, no debug info>", objfile); "<text variable, no debug info>");
TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol)
= objfile_type->builtin_int; = objfile_type->builtin_int;
objfile_type->nodebug_text_gnu_ifunc_symbol objfile_type->nodebug_text_gnu_ifunc_symbol
= init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC, = init_type (objfile, TYPE_CODE_FUNC, 1,
"<text gnu-indirect-function variable, no debug info>", "<text gnu-indirect-function variable, no debug info>");
objfile);
TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol) TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol)
= objfile_type->nodebug_text_symbol; = objfile_type->nodebug_text_symbol;
TYPE_GNU_IFUNC (objfile_type->nodebug_text_gnu_ifunc_symbol) = 1;
objfile_type->nodebug_got_plt_symbol objfile_type->nodebug_got_plt_symbol
= init_type (TYPE_CODE_PTR, gdbarch_addr_bit (gdbarch) / 8, 0, = init_pointer_type (objfile, gdbarch_addr_bit (gdbarch),
"<text from jump slot in .got.plt, no debug info>", "<text from jump slot in .got.plt, no debug info>",
objfile); objfile_type->nodebug_text_symbol);
TYPE_TARGET_TYPE (objfile_type->nodebug_got_plt_symbol)
= objfile_type->nodebug_text_symbol;
objfile_type->nodebug_data_symbol objfile_type->nodebug_data_symbol
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, "<data variable, no debug info>");
"<data variable, no debug info>", objfile);
objfile_type->nodebug_unknown_symbol objfile_type->nodebug_unknown_symbol
= init_type (TYPE_CODE_INT, 1, 0, = init_integer_type (objfile, TARGET_CHAR_BIT, 0,
"<variable (not text or data), no debug info>", objfile); "<variable (not text or data), no debug info>");
objfile_type->nodebug_tls_symbol objfile_type->nodebug_tls_symbol
= init_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, "<thread local variable, no debug info>");
"<thread local variable, no debug info>", objfile);
/* NOTE: on some targets, addresses and pointers are not necessarily /* NOTE: on some targets, addresses and pointers are not necessarily
the same. the same.
@ -5214,9 +5284,8 @@ 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_type (TYPE_CODE_INT, = init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1,
gdbarch_addr_bit (gdbarch) / 8, "__CORE_ADDR");
TYPE_FLAG_UNSIGNED, "__CORE_ADDR", objfile);
set_objfile_data (objfile, objfile_type_data, objfile_type); set_objfile_data (objfile, objfile_type_data, objfile_type);
return objfile_type; return objfile_type;

View File

@ -1672,8 +1672,21 @@ extern unsigned int type_length_units (struct type *type);
/* * Helper function to construct objfile-owned types. */ /* * Helper function to construct objfile-owned types. */
extern struct type *init_type (enum type_code, int, int, const char *, extern struct type *init_type (struct objfile *, enum type_code, int,
struct objfile *); const char *);
extern struct type *init_integer_type (struct objfile *, int, int,
const char *);
extern struct type *init_character_type (struct objfile *, int, int,
const char *);
extern struct type *init_boolean_type (struct objfile *, int, int,
const char *);
extern struct type *init_float_type (struct objfile *, int, const char *,
const struct floatformat **);
extern struct type *init_decfloat_type (struct objfile *, int, const char *);
extern struct type *init_complex_type (struct objfile *, const char *,
struct type *);
extern struct type *init_pointer_type (struct objfile *, int, const char *,
struct type *);
/* Helper functions to construct architecture-owned types. */ /* Helper functions to construct architecture-owned types. */
extern struct type *arch_type (struct gdbarch *, enum type_code, int, extern struct type *arch_type (struct gdbarch *, enum type_code, int,

View File

@ -1402,97 +1402,80 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btAdr: case btAdr:
tp = init_type (TYPE_CODE_PTR, 4, TYPE_FLAG_UNSIGNED, tp = init_pointer_type (objfile, 32, "adr_32",
"adr_32", objfile); objfile_type (objfile)->builtin_void);
TYPE_TARGET_TYPE (tp) = objfile_type (objfile)->builtin_void;
break; break;
case btChar: case btChar:
tp = init_type (TYPE_CODE_INT, 1, 0, tp = init_integer_type (objfile, 8, 0, "char");
"char", objfile);
break; break;
case btUChar: case btUChar:
tp = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 8, 1, "unsigned char");
"unsigned char", objfile);
break; break;
case btShort: case btShort:
tp = init_type (TYPE_CODE_INT, 2, 0, tp = init_integer_type (objfile, 16, 0, "short");
"short", objfile);
break; break;
case btUShort: case btUShort:
tp = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 16, 1, "unsigned short");
"unsigned short", objfile);
break; break;
case btInt: case btInt:
tp = init_type (TYPE_CODE_INT, 4, 0, tp = init_integer_type (objfile, 32, 0, "int");
"int", objfile);
break; break;
case btUInt: case btUInt:
tp = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 32, 1, "unsigned int");
"unsigned int", objfile);
break; break;
case btLong: case btLong:
tp = init_type (TYPE_CODE_INT, 4, 0, tp = init_integer_type (objfile, 32, 0, "long");
"long", objfile);
break; break;
case btULong: case btULong:
tp = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 32, 1, "unsigned long");
"unsigned long", objfile);
break; break;
case btFloat: case btFloat:
tp = init_type (TYPE_CODE_FLT, tp = init_float_type (objfile, gdbarch_float_bit (gdbarch),
gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT, 0, "float", NULL);
"float", objfile);
break; break;
case btDouble: case btDouble:
tp = init_type (TYPE_CODE_FLT, tp = init_float_type (objfile, gdbarch_double_bit (gdbarch),
gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0, "double", NULL);
"double", objfile);
break; break;
case btComplex: case btComplex:
tp = init_type (TYPE_CODE_COMPLEX, tp = init_complex_type (objfile, "complex",
2 * gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT, 0, basic_type (btFloat, objfile));
"complex", objfile);
TYPE_TARGET_TYPE (tp) = basic_type (btFloat, objfile);
break; break;
case btDComplex: case btDComplex:
tp = init_type (TYPE_CODE_COMPLEX, tp = init_complex_type (objfile, "double complex",
2 * gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0, basic_type (btFloat, objfile));
"double complex", objfile);
TYPE_TARGET_TYPE (tp) = basic_type (btDouble, objfile);
break; break;
case btFixedDec: case btFixedDec:
/* 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_type (TYPE_CODE_INT, tp = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT, 0, "fixed decimal");
"fixed decimal", objfile);
break; break;
case btFloatDec: case btFloatDec:
tp = init_type (TYPE_CODE_ERROR, tp = init_type (objfile, TYPE_CODE_ERROR,
gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0, gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
"floating decimal", objfile); "floating decimal");
break; break;
case btString: case btString:
/* Is a "string" the way btString means it the same as TYPE_CODE_STRING? /* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
FIXME. */ FIXME. */
tp = init_type (TYPE_CODE_STRING, 1, 0, tp = init_type (objfile, TYPE_CODE_STRING, 1, "string");
"string", objfile);
break; break;
case btVoid: case btVoid:
@ -1500,39 +1483,32 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btLong64: case btLong64:
tp = init_type (TYPE_CODE_INT, 8, 0, tp = init_integer_type (objfile, 64, 0, "long");
"long", objfile);
break; break;
case btULong64: case btULong64:
tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 64, 1, "unsigned long");
"unsigned long", objfile);
break; break;
case btLongLong64: case btLongLong64:
tp = init_type (TYPE_CODE_INT, 8, 0, tp = init_integer_type (objfile, 64, 0, "long long");
"long long", objfile);
break; break;
case btULongLong64: case btULongLong64:
tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 64, 1, "unsigned long long");
"unsigned long long", objfile);
break; break;
case btAdr64: case btAdr64:
tp = init_type (TYPE_CODE_PTR, 8, TYPE_FLAG_UNSIGNED, tp = init_pointer_type (objfile, 64, "adr_64",
"adr_64", objfile); objfile_type (objfile)->builtin_void);
TYPE_TARGET_TYPE (tp) = objfile_type (objfile)->builtin_void;
break; break;
case btInt64: case btInt64:
tp = init_type (TYPE_CODE_INT, 8, 0, tp = init_integer_type (objfile, 64, 0, "int");
"int", objfile);
break; break;
case btUInt64: case btUInt64:
tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, tp = init_integer_type (objfile, 64, 1, "unsigned int");
"unsigned int", objfile);
break; break;
default: default:
@ -1684,7 +1660,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
/* Try to cross reference this type, build new type on failure. */ /* Try to cross reference this type, build new type on failure. */
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name); ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == (struct type *) NULL) if (tp == (struct type *) NULL)
tp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile); tp = init_type (mdebugread_objfile, type_code, 0, NULL);
/* DEC c89 produces cross references to qualified aggregate types, /* DEC c89 produces cross references to qualified aggregate types,
dereference them. */ dereference them. */
@ -1744,7 +1720,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
/* Try to cross reference this type, build new type on failure. */ /* Try to cross reference this type, build new type on failure. */
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name); ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == (struct type *) NULL) if (tp == (struct type *) NULL)
tp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile); tp = init_type (mdebugread_objfile, type_code, 0, NULL);
/* Make sure that TYPE_CODE(tp) has an expected type code. /* Make sure that TYPE_CODE(tp) has an expected type code.
Any type may be returned from cross_ref if file indirect entries Any type may be returned from cross_ref if file indirect entries
@ -4410,13 +4386,13 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
} }
/* mips cc uses a rf of -1 for opaque struct definitions. /* mips cc uses a rf of -1 for opaque struct definitions.
Set TYPE_FLAG_STUB for these types so that check_typedef will Set TYPE_STUB for these types so that check_typedef will
resolve them if the struct gets defined in another compilation unit. */ resolve them if the struct gets defined in another compilation unit. */
if (rf == -1) if (rf == -1)
{ {
*pname = "<undefined>"; *pname = "<undefined>";
*tpp = init_type (type_code, 0, TYPE_FLAG_STUB, *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
(char *) NULL, mdebugread_objfile); TYPE_STUB (*tpp) = 1;
return result; return result;
} }
@ -4502,8 +4478,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
switch (tir.bt) switch (tir.bt)
{ {
case btVoid: case btVoid:
*tpp = init_type (type_code, 0, 0, (char *) NULL, *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
mdebugread_objfile);
*pname = "<undefined>"; *pname = "<undefined>";
break; break;
@ -4538,8 +4513,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
complaint (&symfile_complaints, complaint (&symfile_complaints,
_("illegal bt %d in forward typedef for %s"), tir.bt, _("illegal bt %d in forward typedef for %s"), tir.bt,
sym_name); sym_name);
*tpp = init_type (type_code, 0, 0, (char *) NULL, *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
mdebugread_objfile);
break; break;
} }
return result; return result;
@ -4567,7 +4541,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
has not been parsed yet. has not been parsed yet.
Initialize the type only, it will be filled in when Initialize the type only, it will be filled in when
it's definition is parsed. */ it's definition is parsed. */
*tpp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile); *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
} }
add_pending (fh, esh, *tpp); add_pending (fh, esh, *tpp);
} }

View File

@ -2098,130 +2098,115 @@ 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_type (TYPE_CODE_INT, 4, 0, "int", objfile); rettype = init_integer_type (objfile, 32, 0, "int");
break; break;
case 2: case 2:
rettype = init_type (TYPE_CODE_INT, 1, 0, "char", objfile); rettype = init_integer_type (objfile, 8, 0, "char");
break; break;
case 3: case 3:
rettype = init_type (TYPE_CODE_INT, 2, 0, "short", objfile); rettype = init_integer_type (objfile, 16, 0, "short");
break; break;
case 4: case 4:
rettype = init_type (TYPE_CODE_INT, 4, 0, "long", objfile); rettype = init_integer_type (objfile, 32, 0, "long");
break; break;
case 5: case 5:
rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 8, 1, "unsigned char");
"unsigned char", objfile);
break; break;
case 6: case 6:
rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", objfile); rettype = init_integer_type (objfile, 8, 0, "signed char");
break; break;
case 7: case 7:
rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 16, 1, "unsigned short");
"unsigned short", objfile);
break; break;
case 8: case 8:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 32, 1, "unsigned int");
"unsigned int", objfile);
break; break;
case 9: case 9:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 32, 1, "unsigned");
"unsigned", objfile);
break; break;
case 10: case 10:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 32, 1, "unsigned long");
"unsigned long", objfile);
break; break;
case 11: case 11:
rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", objfile); rettype = init_type (objfile, TYPE_CODE_VOID, 1, "void");
break; break;
case 12: case 12:
/* IEEE single precision (32 bit). */ /* IEEE single precision (32 bit). */
rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", objfile); rettype = init_float_type (objfile, 32, "float", NULL);
break; break;
case 13: case 13:
/* IEEE double precision (64 bit). */ /* IEEE double precision (64 bit). */
rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", objfile); rettype = init_float_type (objfile, 64, "double", NULL);
break; break;
case 14: case 14:
/* This is an IEEE double on the RS/6000, and different machines with /* This is an IEEE double on the RS/6000, and different machines with
different sizes for "long double" should use different negative different sizes for "long double" should use different negative
type numbers. See stabs.texinfo. */ type numbers. See stabs.texinfo. */
rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", objfile); rettype = init_float_type (objfile, 64, "long double", NULL);
break; break;
case 15: case 15:
rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", objfile); rettype = init_integer_type (objfile, 32, 0, "integer");
break; break;
case 16: case 16:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, rettype = init_boolean_type (objfile, 32, 1, "boolean");
"boolean", objfile);
break; break;
case 17: case 17:
rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", objfile); rettype = init_float_type (objfile, 32, "short real", NULL);
break; break;
case 18: case 18:
rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", objfile); rettype = init_float_type (objfile, 64, "real", NULL);
break; break;
case 19: case 19:
rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", objfile); rettype = init_type (objfile, TYPE_CODE_ERROR, 0, "stringptr");
break; break;
case 20: case 20:
rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED, rettype = init_character_type (objfile, 8, 1, "character");
"character", objfile);
break; break;
case 21: case 21:
rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED, rettype = init_boolean_type (objfile, 8, 1, "logical*1");
"logical*1", objfile);
break; break;
case 22: case 22:
rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED, rettype = init_boolean_type (objfile, 16, 1, "logical*2");
"logical*2", objfile);
break; break;
case 23: case 23:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, rettype = init_boolean_type (objfile, 32, 1, "logical*4");
"logical*4", objfile);
break; break;
case 24: case 24:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, rettype = init_boolean_type (objfile, 32, 1, "logical");
"logical", objfile);
break; break;
case 25: case 25:
/* Complex type consisting of two IEEE single precision values. */ /* Complex type consisting of two IEEE single precision values. */
rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", objfile); rettype = init_complex_type (objfile, "complex",
TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 4, 0, "float", rs6000_builtin_type (12, objfile));
objfile);
break; break;
case 26: case 26:
/* Complex type consisting of two IEEE double precision values. */ /* Complex type consisting of two IEEE double precision values. */
rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL); rettype = init_complex_type (objfile, "double complex",
TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 8, 0, "double", rs6000_builtin_type (13, objfile));
objfile);
break; break;
case 27: case 27:
rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", objfile); rettype = init_integer_type (objfile, 8, 0, "integer*1");
break; break;
case 28: case 28:
rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", objfile); rettype = init_integer_type (objfile, 16, 0, "integer*2");
break; break;
case 29: case 29:
rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", objfile); rettype = init_integer_type (objfile, 32, 0, "integer*4");
break; break;
case 30: case 30:
rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", objfile); rettype = init_character_type (objfile, 16, 0, "wchar");
break; break;
case 31: case 31:
rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", objfile); rettype = init_integer_type (objfile, 64, 0, "long long");
break; break;
case 32: case 32:
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 64, 1, "unsigned long long");
"unsigned long long", objfile);
break; break;
case 33: case 33:
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, rettype = init_integer_type (objfile, 64, 1, "logical*8");
"logical*8", objfile);
break; break;
case 34: case 34:
rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", objfile); rettype = init_integer_type (objfile, 64, 0, "integer*8");
break; break;
} }
negative_types[-typenum] = rettype; negative_types[-typenum] = rettype;
@ -3762,16 +3747,16 @@ read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile)
{ {
int type_bits; int type_bits;
int nbits; int nbits;
int signed_type; int unsigned_type;
enum type_code code = TYPE_CODE_INT; int boolean_type = 0;
switch (**pp) switch (**pp)
{ {
case 's': case 's':
signed_type = 1; unsigned_type = 0;
break; break;
case 'u': case 'u':
signed_type = 0; unsigned_type = 1;
break; break;
default: default:
return error_type (pp, objfile); return error_type (pp, objfile);
@ -3788,7 +3773,7 @@ read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile)
(*pp)++; (*pp)++;
else if (**pp == 'b') else if (**pp == 'b')
{ {
code = TYPE_CODE_BOOL; boolean_type = 1;
(*pp)++; (*pp)++;
} }
@ -3819,14 +3804,17 @@ read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile)
++(*pp); ++(*pp);
if (type_bits == 0) if (type_bits == 0)
return init_type (TYPE_CODE_VOID, 1, {
signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL, struct type *type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
objfile); if (unsigned_type)
TYPE_UNSIGNED (type) = 1;
return type;
}
if (boolean_type)
return init_boolean_type (objfile, type_bits, unsigned_type, NULL);
else else
return init_type (code, return init_integer_type (objfile, type_bits, unsigned_type, NULL);
type_bits / TARGET_CHAR_BIT,
signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
objfile);
} }
static struct type * static struct type *
@ -3848,16 +3836,16 @@ read_sun_floating_type (char **pp, int typenums[2], struct objfile *objfile)
if (nbits != 0) if (nbits != 0)
return error_type (pp, objfile); return error_type (pp, objfile);
nbits = nbytes * TARGET_CHAR_BIT;
if (details == NF_COMPLEX || details == NF_COMPLEX16 if (details == NF_COMPLEX || details == NF_COMPLEX16
|| details == NF_COMPLEX32) || details == NF_COMPLEX32)
{ {
rettype = init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile); rettype = init_float_type (objfile, nbits / 2, NULL, NULL);
TYPE_TARGET_TYPE (rettype) return init_complex_type (objfile, NULL, rettype);
= init_type (TYPE_CODE_FLT, nbytes / 2, 0, NULL, objfile);
return rettype;
} }
return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile); return init_float_type (objfile, nbits, NULL, NULL);
} }
/* Read a number from the string pointed to by *PP. /* Read a number from the string pointed to by *PP.
@ -4120,18 +4108,14 @@ read_range_type (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_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
objfile);
}
else else
return error_type (pp, objfile); return error_type (pp, objfile);
} }
/* A type defined as a subrange of itself, with bounds both 0, is void. */ /* A type defined as a subrange of itself, with bounds both 0, is void. */
if (self_subrange && n2 == 0 && n3 == 0) if (self_subrange && n2 == 0 && n3 == 0)
return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile); return init_type (objfile, TYPE_CODE_VOID, 1, NULL);
/* If n3 is zero and n2 is positive, we want a floating type, and n2 /* If n3 is zero and n2 is positive, we want a floating type, and n2
is the width in bytes. is the width in bytes.
@ -4148,16 +4132,10 @@ read_range_type (char **pp, int typenums[2], int type_size,
if (n3 == 0 && n2 > 0) if (n3 == 0 && n2 > 0)
{ {
struct type *float_type struct type *float_type
= init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile); = init_float_type (objfile, n2 * TARGET_CHAR_BIT, NULL, NULL);
if (self_subrange) if (self_subrange)
{ return init_complex_type (objfile, NULL, float_type);
struct type *complex_type =
init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
TYPE_TARGET_TYPE (complex_type) = float_type;
return complex_type;
}
else else
return float_type; return float_type;
} }
@ -4176,15 +4154,17 @@ read_range_type (char **pp, int typenums[2], int type_size,
bits = gdbarch_int_bit (gdbarch); bits = gdbarch_int_bit (gdbarch);
} }
return init_type (TYPE_CODE_INT, bits / TARGET_CHAR_BIT, return init_integer_type (objfile, bits, 1, NULL);
TYPE_FLAG_UNSIGNED, NULL, objfile);
} }
/* 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)
return init_type (TYPE_CODE_INT, 1, TYPE_FLAG_NOSIGN, NULL, objfile); {
struct type *type = init_integer_type (objfile, 1, 0, NULL);
TYPE_NOSIGN (type) = 1;
return type;
}
/* We used to do this only for subrange of self or subrange of int. */ /* We used to do this only for subrange of self or subrange of int. */
else if (n2 == 0) else if (n2 == 0)
{ {
@ -4194,8 +4174,7 @@ read_range_type (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_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED, return init_integer_type (objfile, -n3 * TARGET_CHAR_BIT, 1, NULL);
NULL, objfile);
/* 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
@ -4209,8 +4188,7 @@ read_range_type (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_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL, return init_integer_type (objfile, bytes * TARGET_CHAR_BIT, 1, NULL);
objfile);
} }
} }
/* 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
@ -4220,15 +4198,15 @@ read_range_type (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_type (TYPE_CODE_INT, -n2, 0, NULL, objfile); return init_integer_type (objfile, -n2 * TARGET_CHAR_BIT, 0, NULL);
else if (n2 == -n3 - 1) else if (n2 == -n3 - 1)
{ {
if (n3 == 0x7f) if (n3 == 0x7f)
return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile); return init_integer_type (objfile, 8, 0, NULL);
if (n3 == 0x7fff) if (n3 == 0x7fff)
return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile); return init_integer_type (objfile, 16, 0, NULL);
if (n3 == 0x7fffffff) if (n3 == 0x7fffffff)
return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile); return init_integer_type (objfile, 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