* defs.h: If TARGET_BYTE_ORDER_SELECTABLE is defined by tm.h,

define TARGET_BYTE_ORDER as target_byte_order, and declare
	target_byte_order as an extern int, and define BITS_BIG_ENDIAN as
	a test of TARGET_BYTE_ORDER.
	* top.c: Several additions if TARGET_BYTE_ORDER_SELECTABLE is
	defined:
	(endianlist, target_byte_order): New variables.
	(set_endian, set_endian_big, set_endian_little): New functions.
	(show_endian): New function.
	(init_cmd_lists): Initialize endianlist.
	(init_main): Add commands ``set endian big'', ``set endian
	little'', and ``show endian''.
	* a29k-pinsn.c: Rewrite uses of TARGET_BYTE_ORDER and
	BITS_BIG_ENDIAN to switch at run time rather than at compile time.
	* coffread.c, dwarfread.c, findvar.c, mips-tdep.c: Likewise.
	* remote-os9k.c, stabsread.c, valarith.c, valprint.c: Likewise.
	* values.c: Likewise.
	* mips-tdep.c: Rewrite uses of GDB_TARGET_IS_MIPS64 to switch at
	run time rather than at compile time.
This commit is contained in:
Ian Lance Taylor
1994-10-06 16:47:32 +00:00
parent 97d3151a59
commit b8176214a5
6 changed files with 156 additions and 73 deletions

View File

@@ -985,9 +985,7 @@ struct_type (dip, thisdie, enddie, objfile)
int n;
struct dieinfo mbr;
char *nextdie;
#if !BITS_BIG_ENDIAN
int anonymous_size;
#endif
if ((type = lookup_utype (dip -> die_ref)) == NULL)
{
@@ -1060,39 +1058,47 @@ struct_type (dip, thisdie, enddie, objfile)
list -> field.bitpos = 8 * locval (mbr.at_location);
/* Handle bit fields. */
list -> field.bitsize = mbr.at_bit_size;
#if BITS_BIG_ENDIAN
/* For big endian bits, the at_bit_offset gives the additional
bit offset from the MSB of the containing anonymous object to
the MSB of the field. We don't have to do anything special
since we don't need to know the size of the anonymous object. */
list -> field.bitpos += mbr.at_bit_offset;
#else
/* For little endian bits, we need to have a non-zero at_bit_size,
so that we know we are in fact dealing with a bitfield. Compute
the bit offset to the MSB of the anonymous object, subtract off
the number of bits from the MSB of the field to the MSB of the
object, and then subtract off the number of bits of the field
itself. The result is the bit offset of the LSB of the field. */
if (mbr.at_bit_size > 0)
if (BITS_BIG_ENDIAN)
{
if (mbr.has_at_byte_size)
{
/* The size of the anonymous object containing the bit field
is explicit, so use the indicated size (in bytes). */
anonymous_size = mbr.at_byte_size;
}
else
{
/* The size of the anonymous object containing the bit field
matches the size of an object of the bit field's type.
DWARF allows at_byte_size to be left out in such cases,
as a debug information size optimization. */
anonymous_size = TYPE_LENGTH (list -> field.type);
}
list -> field.bitpos +=
anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
/* For big endian bits, the at_bit_offset gives the
additional bit offset from the MSB of the containing
anonymous object to the MSB of the field. We don't
have to do anything special since we don't need to
know the size of the anonymous object. */
list -> field.bitpos += mbr.at_bit_offset;
}
else
{
/* For little endian bits, we need to have a non-zero
at_bit_size, so that we know we are in fact dealing
with a bitfield. Compute the bit offset to the MSB
of the anonymous object, subtract off the number of
bits from the MSB of the field to the MSB of the
object, and then subtract off the number of bits of
the field itself. The result is the bit offset of
the LSB of the field. */
if (mbr.at_bit_size > 0)
{
if (mbr.has_at_byte_size)
{
/* The size of the anonymous object containing
the bit field is explicit, so use the
indicated size (in bytes). */
anonymous_size = mbr.at_byte_size;
}
else
{
/* The size of the anonymous object containing
the bit field matches the size of an object
of the bit field's type. DWARF allows
at_byte_size to be left out in such cases, as
a debug information size optimization. */
anonymous_size = TYPE_LENGTH (list -> field.type);
}
list -> field.bitpos +=
anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
}
}
#endif
nfields++;
break;
default: