GDB_INIT_DISASSEMBLE_INFO(info, stream);
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
- return print_insn_big_a29k (memaddr, &info);
-#else
- return print_insn_little_a29k (memaddr, &info);
-#endif
+ if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ return print_insn_big_a29k (memaddr, &info);
+ else
+ return print_insn_little_a29k (memaddr, &info);
}
int n;
struct dieinfo mbr;
char *nextdie;
-#if !BITS_BIG_ENDIAN
int anonymous_size;
-#endif
if ((type = lookup_utype (dip -> die_ref)) == NULL)
{
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
+ /* 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)
{
- /* 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);
+ 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;
}
- list -> field.bitpos +=
- anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
}
-#endif
nfields++;
break;
default:
val = 0;
for (j = 0; j < 4; j++)
{
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
- get_hex_byte(&b);
- val = (val << 8) + b;
-#else
- get_hex_byte(&b);
- val = val + (b << (j*8));
-#endif
+ get_hex_byte (&b);
+ if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ val = (val << 8) + b;
+ else
+ val = val + (b << (j*8));
}
supply_register (regno++, (char *) &val);
}
val = 0;
for (j = 0; j < 2; j++)
{
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
- get_hex_byte(&b);
- val = (val << 8) + b;
-#else
- get_hex_byte(&b);
- val = val + (b << (j*8));
-#endif
+ get_hex_byte (&b);
+ if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ val = (val << 8) + b;
+ else
+ val = val + (b << (j*8));
}
if (regno == 8) i = 10;
val = 0;
for (j = 0; j < 2; j++)
{
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
- get_hex_byte(&b);
- val = (val << 8) + b;
-#else
- get_hex_byte(&b);
- val = val + (b << (j*8));
-#endif
+ get_hex_byte (&b);
+ if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ val = (val << 8) + b;
+ else
+ val = val + (b << (j*8));
}
supply_register (regno, (char *) &val);
}
#endif
add_symbol_to_list (sym, &local_symbols);
-#if TARGET_BYTE_ORDER == LITTLE_ENDIAN
- /* On little-endian machines, this crud is never necessary, and,
- if the extra bytes contain garbage, is harmful. */
- break;
-#else /* Big endian. */
+ if (TARGET_BYTE_ORDER != BIG_ENDIAN)
+ {
+ /* On little-endian machines, this crud is never necessary,
+ and, if the extra bytes contain garbage, is harmful. */
+ break;
+ }
+
/* If it's gcc-compiled, if it says `short', believe it. */
if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
break;
#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
}
#endif /* !BELIEVE_PCC_PROMOTION. */
-#endif /* Big endian. */
case 'P':
/* acc seems to use P to delare the prototypes of functions that
static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+static void set_endian PARAMS ((char *, int));
+
+static void set_endian_big PARAMS ((char *, int));
+
+static void set_endian_little PARAMS ((char *, int));
+
+static void show_endian PARAMS ((char *, int));
+
+#endif
+
static void show_history PARAMS ((char *, int));
static void set_history PARAMS ((char *, int));
struct cmd_list_element *showlist;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+/* Chain containing the \"set endian\" commands. */
+
+struct cmd_list_element *endianlist;
+#endif
+
/* Chain containing all defined \"set history\". */
struct cmd_list_element *sethistlist;
gdb_flush (gdb_stdout);
}
+\f
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+/* Functions to manipulate the endianness of the target. */
+
+#ifndef TARGET_BYTE_ORDER_DEFAULT
+#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
+#endif
+
+int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
+
+/* Called if the user enters ``set endian'' without an argument. */
+static void
+set_endian (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ printf_unfiltered ("\"set endian\" must be followed by \"big\" or \"little\".\n");
+ show_endian (args, from_tty);
+}
+
+/* Called by ``set endian big''. */
+static void
+set_endian_big (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ target_byte_order = BIG_ENDIAN;
+}
+
+/* Called by ``set endian little''. */
+static void
+set_endian_little (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ target_byte_order = LITTLE_ENDIAN;
+}
+
+/* Called by ``show endian''. */
+static void
+show_endian (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ printf_unfiltered ("The target is assumed to be %s endian.\n",
+ TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
+}
+
+#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
\f
/* Functions to manipulate command line editing control variables. */
setlist = NULL;
unsetlist = NULL;
showlist = NULL;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+ endianlist = NULL;
+#endif
sethistlist = NULL;
showhistlist = NULL;
unsethistlist = NULL;
{
struct cmd_list_element *c;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+ add_prefix_cmd ("endian", class_support, set_endian,
+ "Set endianness of target.",
+ &endianlist, "set endian ", 0, &setlist);
+ add_cmd ("big", class_support, set_endian_big,
+ "Set target as being big endian.", &endianlist);
+ add_cmd ("little", class_support, set_endian_little,
+ "Set target as being little endian.", &endianlist);
+ add_cmd ("endian", class_support, show_endian,
+ "Show endianness of target.", &showlist);
+
+#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
+
#ifdef DEFAULT_PROMPT
prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT));
#else
/* Extract bits. See comment above. */
-#if BITS_BIG_ENDIAN
- lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
-#else
- lsbcount = (bitpos % 8);
-#endif
+ if (BITS_BIG_ENDIAN)
+ lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
+ else
+ lsbcount = (bitpos % 8);
val >>= lsbcount;
/* If the field does not entirely fill a LONGEST, then zero the sign bits.
oword = extract_signed_integer (addr, sizeof oword);
/* Shifting for bit field depends on endianness of the target machine. */
-#if BITS_BIG_ENDIAN
- bitpos = sizeof (oword) * 8 - bitpos - bitsize;
-#endif
+ if (BITS_BIG_ENDIAN)
+ bitpos = sizeof (oword) * 8 - bitpos - bitsize;
/* Mask out old value, while avoiding shifts >= size of oword */
if (bitsize < 8 * sizeof (oword))