]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdbarch.sh (function_list): Add new property bits_big_endian to
authorMarkus Deuling <deuling@de.ibm.com>
Fri, 18 Jan 2008 17:07:40 +0000 (17:07 +0000)
committerMarkus Deuling <deuling@de.ibm.com>
Fri, 18 Jan 2008 17:07:40 +0000 (17:07 +0000)
gdbarch structure.
* gdbarch.{c,h}: Regenerate.

* value.c (struct value): Replace BITS_BIG_ENDIAN by
gdbarch_bits_big_endian (comment).
(unpack_field_as_long, modify_field): Likewise.
* value.h: Likewise (comment).
* valops.c (value_slice): Likewise.
* valarith.c (value_subscript, value_bit_index): Likewise.
* gdbtypes.h (field): Likewise (comment).
* eval.c (evaluate_subexp_standard): Likewise.
* dwarf2read.c (dwarf2_add_field): Likewise.
* ada-lang.c (decode_packed_array, ada_value_primitive_packed_val)
(move_bits, ada_value_assign, value_assign_to_component): Likewise.

* defs.h (BITS_BIG_ENDIAN): Remove.

* gdbint.texinfo (Target Conditionals): Replace the description of
BITS_BIG_ENDIAN with a description of gdbarch_bits_big_endian.

15 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/defs.h
gdb/doc/ChangeLog
gdb/doc/gdbint.texinfo
gdb/dwarf2read.c
gdb/eval.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/gdbtypes.h
gdb/valarith.c
gdb/valops.c
gdb/value.c
gdb/value.h

index ed9f2dc6b1ad164e9c21b89ba5cd29ebaa52e524..e66df1e93125933d26663dd25d806dd99bf5ecf1 100644 (file)
@@ -1,3 +1,23 @@
+2008-01-18  Markus Deuling  <deuling@de.ibm.com>
+
+       * gdbarch.sh (function_list): Add new property bits_big_endian to
+       gdbarch structure.
+       * gdbarch.{c,h}: Regenerate.
+
+       * value.c (struct value): Replace BITS_BIG_ENDIAN by
+       gdbarch_bits_big_endian (comment).
+       (unpack_field_as_long, modify_field): Likewise.
+       * value.h: Likewise (comment).
+       * valops.c (value_slice): Likewise.
+       * valarith.c (value_subscript, value_bit_index): Likewise.
+       * gdbtypes.h (field): Likewise (comment).
+       * eval.c (evaluate_subexp_standard): Likewise.
+       * dwarf2read.c (dwarf2_add_field): Likewise.
+       * ada-lang.c (decode_packed_array, ada_value_primitive_packed_val)
+       (move_bits, ada_value_assign, value_assign_to_component): Likewise.
+       
+       * defs.h (BITS_BIG_ENDIAN): Remove.
+
 2008-01-18  Markus Deuling  <deuling@de.ibm.com>
 
        * jv-exp.y (yylex): Replace DEPRECATED_STREQN with the appropriate
index 49da2ec43bf65e9eaf54687a1d9bd4e310233233..7880645fc4dc4873a433715b39dc358f93ebf603 100644 (file)
@@ -1875,7 +1875,8 @@ decode_packed_array (struct value *arr)
       return NULL;
     }
 
-  if (BITS_BIG_ENDIAN && ada_is_modular_type (value_type (arr)))
+  if (gdbarch_bits_big_endian (current_gdbarch)
+      && ada_is_modular_type (value_type (arr)))
     {
        /* This is a (right-justified) modular type representing a packed
         array with no wrapper.  In order to interpret the value through
@@ -1998,7 +1999,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
   int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
   /* Transmit bytes from least to most significant; delta is the direction
      the indices move.  */
-  int delta = BITS_BIG_ENDIAN ? -1 : 1;
+  int delta = gdbarch_bits_big_endian (current_gdbarch) ? -1 : 1;
 
   type = ada_check_typedef (type);
 
@@ -2047,7 +2048,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
       memset (unpacked, 0, TYPE_LENGTH (type));
       return v;
     }
-  else if (BITS_BIG_ENDIAN)
+  else if (gdbarch_bits_big_endian (current_gdbarch))
     {
       src = len - 1;
       if (has_negatives (type)
@@ -2141,7 +2142,7 @@ move_bits (gdb_byte *target, int targ_offset, const gdb_byte *source,
   targ_offset %= HOST_CHAR_BIT;
   source += src_offset / HOST_CHAR_BIT;
   src_offset %= HOST_CHAR_BIT;
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     {
       accum = (unsigned char) *source;
       source += 1;
@@ -2229,7 +2230,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
         fromval = value_cast (type, fromval);
 
       read_memory (to_addr, buffer, len);
-      if (BITS_BIG_ENDIAN)
+      if (gdbarch_bits_big_endian (current_gdbarch))
         move_bits (buffer, value_bitpos (toval),
                    value_contents (fromval),
                    TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT -
@@ -2276,7 +2277,7 @@ value_assign_to_component (struct value *container, struct value *component,
   else
     bits = value_bitsize (component);
 
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     move_bits (value_contents_writeable (container) + offset_in_container, 
               value_bitpos (container) + bit_offset_in_container,
               value_contents (val),
index b0d07e7c2b721a7aafa658b17ddf3df300dc9497..3486df8c6327e047e55e37bf9a356b81b774b182 100644 (file)
@@ -1011,14 +1011,6 @@ enum { MAX_REGISTER_SIZE = 16 };
 #define HOST_CHAR_BIT TARGET_CHAR_BIT
 #endif
 
-/* The bit byte-order has to do just with numbering of bits in
-   debugging symbols and such.  Conceptually, it's quite separate
-   from byte/word byte order.  */
-
-#if !defined (BITS_BIG_ENDIAN)
-#define BITS_BIG_ENDIAN (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
-#endif
-
 /* In findvar.c.  */
 
 extern LONGEST extract_signed_integer (const gdb_byte *, int);
index 9a477603801348b0c69ed451ec134ba97d0280a9..5de82446de83d23a160ac07b61121d2d14462ff0 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-18  Markus Deuling  <deuling@de.ibm.com>
+
+       * gdbint.texinfo (Target Conditionals): Replace the description of
+       BITS_BIG_ENDIAN with a description of gdbarch_bits_big_endian.
+
 2008-01-12  Paul Hilfinger  <hilfinger@adacore.com>
 
        * gdb.texinfo (C Operators): Remove incorrect parenthetical comment
index da2cd7bb76a469f5b1734d9230ce96c174c34a07..8aa741006ebfb3da5f8d1d42d136b30ddce61b40 100644 (file)
@@ -3344,12 +3344,18 @@ Used to notify if the compiler promotes a @code{short} or @code{char}
 parameter to an @code{int}, but still reports the parameter as its
 original type, rather than the promoted type.
 
-@item BITS_BIG_ENDIAN
-@findex BITS_BIG_ENDIAN
-Define this if the numbering of bits in the targets does @strong{not} match the
-endianness of the target byte order.  A value of 1 means that the bits
+@item gdbarch_bits_big_endian (@var{gdbarch})
+@findex gdbarch_bits_big_endian
+This is used if the numbering of bits in the targets does @strong{not} match
+the endianness of the target byte order.  A value of 1 means that the bits
 are numbered in a big-endian bit order, 0 means little-endian.
 
+@item set_gdbarch_bits_big_endian (@var{gdbarch}, @var{bits_big_endian})
+@findex set_gdbarch_bits_big_endian
+Calling set_gdbarch_bits_big_endian with a value of 1 indicates that the
+bits in the target are numbered in a big-endian bit order, 0 indicates
+little-endian.
+
 @item BREAKPOINT
 @findex BREAKPOINT
 This is the character array initializer for the bit pattern to put into
index 44f9c2aac64ae38775e0eda3d2b24ab11259890d..15e168ff9b4ff83942979eb7c93c61ac25f2c09c 100644 (file)
@@ -3502,7 +3502,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr)
        {
-         if (BITS_BIG_ENDIAN)
+         if (gdbarch_bits_big_endian (current_gdbarch))
            {
              /* For big endian bits, the DW_AT_bit_offset gives the
                 additional bit offset from the MSB of the containing
index 188cca0e0b09b39abfc6e9ed696a48e4c3b0a118..466ae248ce5541b83b23fb0b58ef9e2609290184 100644 (file)
@@ -686,7 +686,7 @@ evaluate_subexp_standard (struct type *expect_type,
              for (; range_low <= range_high; range_low++)
                {
                  int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
-                 if (BITS_BIG_ENDIAN)
+                 if (gdbarch_bits_big_endian (current_gdbarch))
                    bit_index = TARGET_CHAR_BIT - 1 - bit_index;
                  valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
                    |= 1 << bit_index;
index 90e3f47c42a5c17b756ee5b73c8c8611a9a223c0..3c5a282eb50926e6cfbcf96d23d9b8bde9920d79 100644 (file)
@@ -130,6 +130,7 @@ struct gdbarch
 
      */
 
+  int bits_big_endian;
   int short_bit;
   int int_bit;
   int long_bit;
@@ -251,6 +252,7 @@ struct gdbarch startup_gdbarch =
   /*per-architecture data-pointers and swap regions */
   0, NULL, NULL,
   /* Multi-arch values */
+  1,  /* bits_big_endian */
   8 * sizeof (short),  /* short_bit */
   8 * sizeof (int),  /* int_bit */
   8 * sizeof (long),  /* long_bit */
@@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->target_desc = info->target_desc;
 
   /* Force the explicit initialization of these. */
+  gdbarch->bits_big_endian = (gdbarch->byte_order == BFD_ENDIAN_BIG);
   gdbarch->short_bit = 2*TARGET_CHAR_BIT;
   gdbarch->int_bit = 4*TARGET_CHAR_BIT;
   gdbarch->long_bit = 4*TARGET_CHAR_BIT;
@@ -480,6 +483,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   if (gdbarch->bfd_arch_info == NULL)
     fprintf_unfiltered (log, "\n\tbfd_arch_info");
   /* Check those that need to be defined for the given multi-arch level. */
+  /* Skip verify of bits_big_endian, invalid_p == 0 */
   /* Skip verify of short_bit, invalid_p == 0 */
   /* Skip verify of int_bit, invalid_p == 0 */
   /* Skip verify of long_bit, invalid_p == 0 */
@@ -647,6 +651,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: bfd_arch_info = %s\n",
                       gdbarch_bfd_arch_info (gdbarch)->printable_name);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: bits_big_endian = %s\n",
+                      paddr_d (gdbarch->bits_big_endian));
   fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <0x%lx>\n",
                       (long) gdbarch->breakpoint_from_pc);
@@ -1059,6 +1066,23 @@ gdbarch_target_desc (struct gdbarch *gdbarch)
   return gdbarch->target_desc;
 }
 
+int
+gdbarch_bits_big_endian (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of bits_big_endian, invalid_p == 0 */
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_bits_big_endian called\n");
+  return gdbarch->bits_big_endian;
+}
+
+void
+set_gdbarch_bits_big_endian (struct gdbarch *gdbarch,
+                             int bits_big_endian)
+{
+  gdbarch->bits_big_endian = bits_big_endian;
+}
+
 int
 gdbarch_short_bit (struct gdbarch *gdbarch)
 {
index ebb8c6099569bb18c53a940eeca66ce7cd24208c..c068ddec5a8116e45b6ebff06ff46a4803c251d2 100644 (file)
@@ -71,6 +71,12 @@ extern const struct target_desc * gdbarch_target_desc (struct gdbarch *gdbarch);
 
 /* The following are initialized by the target dependent code. */
 
+/* The bit byte-order has to do just with numbering of bits in debugging symbols
+   and such.  Conceptually, it's quite separate from byte/word byte order. */
+
+extern int gdbarch_bits_big_endian (struct gdbarch *gdbarch);
+extern void set_gdbarch_bits_big_endian (struct gdbarch *gdbarch, int bits_big_endian);
+
 /* Number of bits in a char or unsigned char for the target machine.
    Just like CHAR_BIT in <limits.h> but describes the target machine.
    v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
index 92b2316033bf1d02a4a14d2d8b620bad02ae30bc..eda85af533f22eeffc70a22848bb4a196e261297 100755 (executable)
@@ -343,6 +343,11 @@ i:int:byte_order:::BFD_ENDIAN_BIG
 i:enum gdb_osabi:osabi:::GDB_OSABI_UNKNOWN
 #
 i:const struct target_desc *:target_desc:::::::paddr_d ((long) gdbarch->target_desc)
+
+# The bit byte-order has to do just with numbering of bits in debugging symbols
+# and such.  Conceptually, it's quite separate from byte/word byte order.
+v:int:bits_big_endian:::1:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
+
 # Number of bits in a char or unsigned char for the target machine.
 # Just like CHAR_BIT in <limits.h> but describes the target machine.
 # v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
index 54aae9c10acba897e44a5a2a422f7e50ec9dcb10..d224140de38ee159a899d08053a7c9e2046a23c1 100644 (file)
@@ -403,8 +403,8 @@ struct main_type
     {
       /* Position of this field, counting in bits from start of
         containing structure.
-        For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
-        For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
+        For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
+        For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
         For a range bound or enum value, this is the value itself. */
 
       int bitpos;
index 562be0cab1bbe921ff58083403e6167ef9f8e42b..173c7a5dbb1dac90b5365050febd73632078ff38 100644 (file)
@@ -230,7 +230,8 @@ value_subscript (struct value *array, struct value *idx)
       offset = index / TARGET_CHAR_BIT;
       byte = *((char *) value_contents (array) + offset);
       bit_index = index % TARGET_CHAR_BIT;
-      byte >>= (BITS_BIG_ENDIAN ? TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+      byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
+               TARGET_CHAR_BIT - 1 - bit_index : bit_index);
       v = value_from_longest (LA_BOOL_TYPE, byte & 1);
       set_value_bitpos (v, bit_index);
       set_value_bitsize (v, 1);
@@ -1575,7 +1576,7 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
   word = unpack_long (builtin_type_unsigned_char,
                      valaddr + (rel_index / TARGET_CHAR_BIT));
   rel_index %= TARGET_CHAR_BIT;
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
index bb4814f00ac10e076547ef545ef20b4d6784517f..d4a0a9a27d4c84d2463540e593edd1fb080738a7 100644 (file)
@@ -2743,7 +2743,7 @@ value_slice (struct value *array, int lowbound, int length)
          else if (element > 0)
            {
              int j = i % TARGET_CHAR_BIT;
-             if (BITS_BIG_ENDIAN)
+             if (gdbarch_bits_big_endian (current_gdbarch))
                j = TARGET_CHAR_BIT - 1 - j;
              value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
            }
index 1a5f984febc15f2860c69ef4a1d1b44920d171f4..e620550eca3ec768f70f4ffa0ebf4d6cb12967e2 100644 (file)
@@ -72,8 +72,8 @@ struct value
   int bitsize;
 
   /* Only used for bitfields; position of start of field.  For
-     BITS_BIG_ENDIAN=0 targets, it is the position of the LSB.  For
-     BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+     gdbarch_bits_big_endian=0 targets, it is the position of the LSB.  For
+     gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
   int bitpos;
 
   /* Frame register value is relative to.  This will be described in
@@ -1481,7 +1481,7 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 
   /* Extract bits.  See comment above. */
 
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
   else
     lsbcount = (bitpos % 8);
@@ -1537,7 +1537,7 @@ modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize)
   oword = extract_unsigned_integer (addr, sizeof oword);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     bitpos = sizeof (oword) * 8 - bitpos - bitsize;
 
   oword &= ~(mask << bitpos);
index 7e1ccaf298424be67a32c34751a57d78513b3ea8..6086917b40940224f0a41826b3e2d30b61d2e1c1 100644 (file)
@@ -62,8 +62,8 @@ extern int value_bitsize (struct value *);
 extern void set_value_bitsize (struct value *, int bit);
 
 /* Only used for bitfields; position of start of field.  For
-   BITS_BIG_ENDIAN=0 targets, it is the position of the LSB.  For
-   BITS_BIG_ENDIAN=1 targets, it is the position of the MSB.  */
+   gdbarch_bits_big_endian=0 targets, it is the position of the LSB.  For
+   gdbarch_bits_big_endian=1 targets, it is the position of the MSB.  */
 
 extern int value_bitpos (struct value *);
 extern void set_value_bitpos (struct value *, int bit);