public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] Remove gdbarch_bits_big_endian
@ 2019-11-27 18:56 Tom Tromey (Code Review)
  2019-11-27 22:09 ` Simon Marchi (Code Review)
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-27 18:56 UTC (permalink / raw)
  To: gdb-patches

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................

Remove gdbarch_bits_big_endian

From what I can tell, set_gdbarch_bits_big_endian has never been used.
That is, all architectures since its introduction have simply used the
default, which is simply check the architecture's byte-endianness.

Because this interferes with the scalar_storage_order code, this patch
removes this gdbarch setting entirely.  In some places,
type_byte_order is used rather than the plain gdbarch.

gdb/ChangeLog
2019-11-27  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (decode_constrained_packed_array)
	(ada_value_assign, value_assign_to_component): Update.
	* dwarf2loc.c (rw_pieced_value, access_memory)
	(dwarf2_compile_expr_to_ax): Update.
	* dwarf2read.c (dwarf2_add_field): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (bits_big_endian): Remove.
	* gdbtypes.h (union field_location): Update comment.
	* target-descriptions.c (make_gdb_type): Update.
	* valarith.c (value_bit_index): Update.
	* value.c (struct value) <bitpos>: Update comment.
	(unpack_bits_as_long, modify_field): Update.
	* value.h (value_bitpos): Update comment.

Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
---
M gdb/ChangeLog
M gdb/ada-lang.c
M gdb/dwarf2loc.c
M gdb/dwarf2read.c
M gdb/eval.c
M gdb/gdbarch.c
M gdb/gdbarch.h
M gdb/gdbarch.sh
M gdb/gdbtypes.h
M gdb/target-descriptions.c
M gdb/valarith.c
M gdb/value.c
M gdb/value.h
13 files changed, 37 insertions(+), 55 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 876a027..58f7f46 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
 2019-11-27  Tom Tromey  <tromey@adacore.com>
 
+	* ada-lang.c (decode_constrained_packed_array)
+	(ada_value_assign, value_assign_to_component): Update.
+	* dwarf2loc.c (rw_pieced_value, access_memory)
+	(dwarf2_compile_expr_to_ax): Update.
+	* dwarf2read.c (dwarf2_add_field): Update.
+	* eval.c (evaluate_subexp_standard): Update.
+	* gdbarch.c, gdbarch.h: Rebuild.
+	* gdbarch.sh (bits_big_endian): Remove.
+	* gdbtypes.h (union field_location): Update comment.
+	* target-descriptions.c (make_gdb_type): Update.
+	* valarith.c (value_bit_index): Update.
+	* value.c (struct value) <bitpos>: Update comment.
+	(unpack_bits_as_long, modify_field): Update.
+	* value.h (value_bitpos): Update comment.
+
+2019-11-27  Tom Tromey  <tromey@adacore.com>
+
 	* gdbtypes.c (type_byte_order): Move earlier.
 
 2019-11-27  Tom Tromey  <tromey@adacore.com>
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7959a5f..3289a8e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2257,7 +2257,7 @@
       return NULL;
     }
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (arr)))
+  if (type_byte_order (value_type (arr)) == BFD_ENDIAN_BIG
       && ada_is_modular_type (value_type (arr)))
     {
        /* This is a (right-justified) modular type representing a packed
@@ -2499,7 +2499,7 @@
   const gdb_byte *src;                /* First byte containing data to unpack */
   gdb_byte *unpacked;
   const int is_scalar = is_scalar_type (type);
-  const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+  const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
   gdb::byte_vector staging;
 
   type = ada_check_typedef (type);
@@ -2645,7 +2645,7 @@
       if (from_size == 0)
 	from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT;
 
-      const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+      const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
       ULONGEST from_offset = 0;
       if (is_big_endian && is_scalar_type (value_type (fromval)))
 	from_offset = from_size - bits;
@@ -2694,7 +2694,7 @@
   else
     bits = value_bitsize (component);
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (container))))
+  if (type_byte_order (value_type (container)) == BFD_ENDIAN_BIG)
     {
       int src_offset;
 
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 0b22745..49c79ec 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1577,8 +1577,7 @@
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (v);
   gdb::byte_vector buffer;
-  int bits_big_endian
-    = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
+  int bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG;
 
   if (from != NULL)
     {
@@ -2817,7 +2816,7 @@
   if (8 * nbytes == nbits)
     return;
 
-  if (gdbarch_bits_big_endian (arch))
+  if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
     {
       /* On a bits-big-endian machine, we want the high-order
 	 NBITS.  */
@@ -2867,7 +2866,7 @@
   enum bfd_endian byte_order = gdbarch_byte_order (arch);
   ULONGEST bits_collected = 0;
   unsigned int addr_size_bits = 8 * addr_size;
-  int bits_big_endian = gdbarch_bits_big_endian (arch);
+  int bits_big_endian = byte_order == BFD_ENDIAN_BIG;
 
   std::vector<int> offsets (op_end - op_ptr, -1);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index cc815a2..d809427 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15121,7 +15121,7 @@
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr != nullptr)
 	{
-	  if (gdbarch_bits_big_endian (gdbarch))
+	  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
 	    {
 	      /* For big endian bits, the DW_AT_bit_offset gives the
 	         additional bit offset from the MSB of the containing
diff --git a/gdb/eval.c b/gdb/eval.c
index 72f5109..8787442 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1547,7 +1547,7 @@
 		{
 		  int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
 
-		  if (gdbarch_bits_big_endian (exp->gdbarch))
+		  if (gdbarch_byte_order (exp->gdbarch) == BFD_ENDIAN_BIG)
 		    bit_index = TARGET_CHAR_BIT - 1 - bit_index;
 		  valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
 		    |= 1 << bit_index;
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index fa6be50..59c97da 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -172,7 +172,6 @@
 
      */
 
-  int bits_big_endian;
   int short_bit;
   int int_bit;
   int long_bit;
@@ -389,7 +388,6 @@
   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;
@@ -528,7 +526,6 @@
   if (gdbarch->bfd_arch_info == NULL)
     log.puts ("\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 */
@@ -817,9 +814,6 @@
                       "gdbarch_dump: bfd_arch_info = %s\n",
                       gdbarch_bfd_arch_info (gdbarch)->printable_name);
   fprintf_unfiltered (file,
-                      "gdbarch_dump: bits_big_endian = %s\n",
-                      plongest (gdbarch->bits_big_endian));
-  fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <%s>\n",
                       host_address_to_string (gdbarch->breakpoint_from_pc));
   fprintf_unfiltered (file,
@@ -1565,23 +1559,6 @@
 }
 
 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)
 {
   gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 01b5aef..78e05ec 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -146,12 +146,6 @@
 
 /* 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 short or unsigned short for the target machine. */
 
 extern int gdbarch_short_bit (struct gdbarch *gdbarch);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 62f68dc..331eb39 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -347,10 +347,6 @@
 #
 i;const struct target_desc *;target_desc;;;;;;;host_address_to_string (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 short or unsigned short for the target machine.
 v;int;short_bit;;;8 * sizeof (short);2*TARGET_CHAR_BIT;;0
 # Number of bits in an int or unsigned int for the target machine.
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index dc4cb3e..80d2808 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -552,10 +552,9 @@
 union field_location
 {
   /* * Position of this field, counting in bits from start of
-     containing structure.  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.  */
+     containing structure.  For big-endian targets, it is the bit
+     offset to the MSB.  For little-endian targets, it is the bit
+     offset to the LSB.  */
 
   LONGEST bitpos;
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index f83c2f9..29b80dd 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -224,7 +224,7 @@
 		 the total size of the structure.  */
 	      bitsize = f.end - f.start + 1;
 	      total_size = e->size * TARGET_CHAR_BIT;
-	      if (gdbarch_bits_big_endian (m_gdbarch))
+	      if (gdbarch_byte_order (m_gdbarch) == BFD_ENDIAN_BIG)
 		SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
 	      else
 		SET_FIELD_BITPOS (fld[0], f.start);
diff --git a/gdb/valarith.c b/gdb/valarith.c
index ea999b5..6ba9305 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1712,7 +1712,7 @@
   word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
 				   type_byte_order (type));
   rel_index %= TARGET_CHAR_BIT;
-  if (gdbarch_bits_big_endian (gdbarch))
+  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
diff --git a/gdb/value.c b/gdb/value.c
index 57e62b9..41c937a 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -273,8 +273,8 @@
   LONGEST bitsize = 0;
 
   /* Only used for bitfields; position of start of field.  For
-     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.  */
+     little-endian targets, it is the position of the LSB.  For
+     big-endian targets, it is the position of the MSB.  */
   LONGEST bitpos = 0;
 
   /* The number of references to this value.  When a value is created,
@@ -3135,7 +3135,7 @@
 
   /* Extract bits.  See comment above.  */
 
-  if (gdbarch_bits_big_endian (get_type_arch (field_type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize);
   else
     lsbcount = (bitpos % 8);
@@ -3311,7 +3311,7 @@
   oword = extract_unsigned_integer (addr, bytesize, byte_order);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
-  if (gdbarch_bits_big_endian (get_type_arch (type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     bitpos = bytesize * 8 - bitpos - bitsize;
 
   oword &= ~(mask << bitpos);
diff --git a/gdb/value.h b/gdb/value.h
index 96c9c21..0816247 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -146,8 +146,8 @@
 extern void set_value_bitsize (struct value *, LONGEST bit);
 
 /* Only used for bitfields; position of start of field.  For
-   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.  */
+   little-endian targets, it is the position of the LSB.  For
+   big-endian targets, it is the position of the MSB.  */
 
 extern LONGEST value_bitpos (const struct value *);
 extern void set_value_bitpos (struct value *, LONGEST bit);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [review] Remove gdbarch_bits_big_endian
  2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
@ 2019-11-27 22:09 ` Simon Marchi (Code Review)
  2019-12-03 21:32 ` Tom Tromey (Code Review)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi (Code Review) @ 2019-11-27 22:09 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................


Patch Set 1:

(2 comments)

| --- gdb/dwarf2loc.c
| +++ gdb/dwarf2loc.c
| @@ -1573,18 +1573,17 @@ rw_pieced_value (struct value *v, struct value *from)
|    LONGEST offset = 0, max_offset;
|    ULONGEST bits_to_skip;
|    gdb_byte *v_contents;
|    const gdb_byte *from_contents;
|    struct piece_closure *c
|      = (struct piece_closure *) value_computed_closure (v);
|    gdb::byte_vector buffer;
| -  int bits_big_endian
| -    = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
| +  int bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG;

PS1, Line 1580:

It could be a good opportunity to change all these int to bool, in the
lines that you touched.

|  
|    if (from != NULL)
|      {
|        from_contents = value_contents (from);
|        v_contents = NULL;
|      }
|    else
|      {
|        if (value_type (v) != value_enclosing_type (v))
| --- gdb/gdbtypes.h
| +++ gdb/gdbtypes.h
| @@ -545,16 +545,15 @@ };
|  
|  union type_owner
|  {
|    struct objfile *objfile;
|    struct gdbarch *gdbarch;
|  };
|  
|  union field_location
|  {
|    /* * Position of this field, counting in bits from start of

PS1, Line 554:

Could you remove this extra asterisk while at it?

| -     containing structure.  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.  */
| +     containing structure.  For big-endian targets, it is the bit
| +     offset to the MSB.  For little-endian targets, it is the bit
| +     offset to the LSB.  */
|  
|    LONGEST bitpos;

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Wed, 27 Nov 2019 22:08:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [review] Remove gdbarch_bits_big_endian
  2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
  2019-11-27 22:09 ` Simon Marchi (Code Review)
@ 2019-12-03 21:32 ` Tom Tromey (Code Review)
  2019-12-04 14:36 ` [review v2] " Tom Tromey (Code Review)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey (Code Review) @ 2019-12-03 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................


Patch Set 1:

(1 comment)

| --- gdb/gdbtypes.h
| +++ gdb/gdbtypes.h
| @@ -545,16 +545,15 @@ };
|  
|  union type_owner
|  {
|    struct objfile *objfile;
|    struct gdbarch *gdbarch;
|  };
|  
|  union field_location
|  {
|    /* * Position of this field, counting in bits from start of

PS1, Line 554:

> Could you remove this extra asterisk while at it?

This is for doxygen, which gdbtypes.h (and no other file) generally
uses.
Not sure if we should move toward more doxygen, or remove these; but
either way I'd rather not deal with it in this patch.

Sometimes I think we should fix up "chew" to just extract, and then
write the doc comments in texinfo.

| -     containing structure.  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.  */
| +     containing structure.  For big-endian targets, it is the bit
| +     offset to the MSB.  For little-endian targets, it is the bit
| +     offset to the LSB.  */
|  
|    LONGEST bitpos;

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Tue, 03 Dec 2019 21:32:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [review v2] Remove gdbarch_bits_big_endian
  2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
  2019-11-27 22:09 ` Simon Marchi (Code Review)
  2019-12-03 21:32 ` Tom Tromey (Code Review)
@ 2019-12-04 14:36 ` Tom Tromey (Code Review)
  2019-12-04 15:35 ` Simon Marchi (Code Review)
  2019-12-04 16:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  4 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey (Code Review) @ 2019-12-04 14:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................

Remove gdbarch_bits_big_endian

From what I can tell, set_gdbarch_bits_big_endian has never been used.
That is, all architectures since its introduction have simply used the
default, which is simply check the architecture's byte-endianness.

Because this interferes with the scalar_storage_order code, this patch
removes this gdbarch setting entirely.  In some places,
type_byte_order is used rather than the plain gdbarch.

gdb/ChangeLog
2019-12-04  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (decode_constrained_packed_array)
	(ada_value_assign, value_assign_to_component): Update.
	* dwarf2loc.c (rw_pieced_value, access_memory)
	(dwarf2_compile_expr_to_ax): Update.
	* dwarf2read.c (dwarf2_add_field): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (bits_big_endian): Remove.
	* gdbtypes.h (union field_location): Update comment.
	* target-descriptions.c (make_gdb_type): Update.
	* valarith.c (value_bit_index): Update.
	* value.c (struct value) <bitpos>: Update comment.
	(unpack_bits_as_long, modify_field): Update.
	* value.h (value_bitpos): Update comment.

Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
---
M gdb/ChangeLog
M gdb/ada-lang.c
M gdb/dwarf2loc.c
M gdb/dwarf2read.c
M gdb/eval.c
M gdb/gdbarch.c
M gdb/gdbarch.h
M gdb/gdbarch.sh
M gdb/gdbtypes.h
M gdb/target-descriptions.c
M gdb/valarith.c
M gdb/value.c
M gdb/value.h
13 files changed, 37 insertions(+), 55 deletions(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 64f2db3..d00c2c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
 2019-12-04  Tom Tromey  <tromey@adacore.com>
 
+	* ada-lang.c (decode_constrained_packed_array)
+	(ada_value_assign, value_assign_to_component): Update.
+	* dwarf2loc.c (rw_pieced_value, access_memory)
+	(dwarf2_compile_expr_to_ax): Update.
+	* dwarf2read.c (dwarf2_add_field): Update.
+	* eval.c (evaluate_subexp_standard): Update.
+	* gdbarch.c, gdbarch.h: Rebuild.
+	* gdbarch.sh (bits_big_endian): Remove.
+	* gdbtypes.h (union field_location): Update comment.
+	* target-descriptions.c (make_gdb_type): Update.
+	* valarith.c (value_bit_index): Update.
+	* value.c (struct value) <bitpos>: Update comment.
+	(unpack_bits_as_long, modify_field): Update.
+	* value.h (value_bitpos): Update comment.
+
+2019-12-04  Tom Tromey  <tromey@adacore.com>
+
 	* gdbtypes.c (type_byte_order): Move earlier.  Assert for unknown
 	endian-ness.
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7959a5f..3289a8e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2257,7 +2257,7 @@
       return NULL;
     }
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (arr)))
+  if (type_byte_order (value_type (arr)) == BFD_ENDIAN_BIG
       && ada_is_modular_type (value_type (arr)))
     {
        /* This is a (right-justified) modular type representing a packed
@@ -2499,7 +2499,7 @@
   const gdb_byte *src;                /* First byte containing data to unpack */
   gdb_byte *unpacked;
   const int is_scalar = is_scalar_type (type);
-  const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+  const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
   gdb::byte_vector staging;
 
   type = ada_check_typedef (type);
@@ -2645,7 +2645,7 @@
       if (from_size == 0)
 	from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT;
 
-      const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+      const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
       ULONGEST from_offset = 0;
       if (is_big_endian && is_scalar_type (value_type (fromval)))
 	from_offset = from_size - bits;
@@ -2694,7 +2694,7 @@
   else
     bits = value_bitsize (component);
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (container))))
+  if (type_byte_order (value_type (container)) == BFD_ENDIAN_BIG)
     {
       int src_offset;
 
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 0b22745..976d453 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1577,8 +1577,7 @@
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (v);
   gdb::byte_vector buffer;
-  int bits_big_endian
-    = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
+  bool bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG;
 
   if (from != NULL)
     {
@@ -2817,7 +2816,7 @@
   if (8 * nbytes == nbits)
     return;
 
-  if (gdbarch_bits_big_endian (arch))
+  if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
     {
       /* On a bits-big-endian machine, we want the high-order
 	 NBITS.  */
@@ -2867,7 +2866,7 @@
   enum bfd_endian byte_order = gdbarch_byte_order (arch);
   ULONGEST bits_collected = 0;
   unsigned int addr_size_bits = 8 * addr_size;
-  int bits_big_endian = gdbarch_bits_big_endian (arch);
+  bool bits_big_endian = byte_order == BFD_ENDIAN_BIG;
 
   std::vector<int> offsets (op_end - op_ptr, -1);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 34513ad..34ad519 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15127,7 +15127,7 @@
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr != nullptr)
 	{
-	  if (gdbarch_bits_big_endian (gdbarch))
+	  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
 	    {
 	      /* For big endian bits, the DW_AT_bit_offset gives the
 	         additional bit offset from the MSB of the containing
diff --git a/gdb/eval.c b/gdb/eval.c
index 72f5109..8787442 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1547,7 +1547,7 @@
 		{
 		  int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
 
-		  if (gdbarch_bits_big_endian (exp->gdbarch))
+		  if (gdbarch_byte_order (exp->gdbarch) == BFD_ENDIAN_BIG)
 		    bit_index = TARGET_CHAR_BIT - 1 - bit_index;
 		  valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
 		    |= 1 << bit_index;
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index fa6be50..59c97da 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -172,7 +172,6 @@
 
      */
 
-  int bits_big_endian;
   int short_bit;
   int int_bit;
   int long_bit;
@@ -389,7 +388,6 @@
   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;
@@ -528,7 +526,6 @@
   if (gdbarch->bfd_arch_info == NULL)
     log.puts ("\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 */
@@ -817,9 +814,6 @@
                       "gdbarch_dump: bfd_arch_info = %s\n",
                       gdbarch_bfd_arch_info (gdbarch)->printable_name);
   fprintf_unfiltered (file,
-                      "gdbarch_dump: bits_big_endian = %s\n",
-                      plongest (gdbarch->bits_big_endian));
-  fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <%s>\n",
                       host_address_to_string (gdbarch->breakpoint_from_pc));
   fprintf_unfiltered (file,
@@ -1565,23 +1559,6 @@
 }
 
 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)
 {
   gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 01b5aef..78e05ec 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -146,12 +146,6 @@
 
 /* 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 short or unsigned short for the target machine. */
 
 extern int gdbarch_short_bit (struct gdbarch *gdbarch);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 62f68dc..331eb39 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -347,10 +347,6 @@
 #
 i;const struct target_desc *;target_desc;;;;;;;host_address_to_string (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 short or unsigned short for the target machine.
 v;int;short_bit;;;8 * sizeof (short);2*TARGET_CHAR_BIT;;0
 # Number of bits in an int or unsigned int for the target machine.
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f6879e8..e399f5f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -552,10 +552,9 @@
 union field_location
 {
   /* * Position of this field, counting in bits from start of
-     containing structure.  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.  */
+     containing structure.  For big-endian targets, it is the bit
+     offset to the MSB.  For little-endian targets, it is the bit
+     offset to the LSB.  */
 
   LONGEST bitpos;
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index f83c2f9..29b80dd 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -224,7 +224,7 @@
 		 the total size of the structure.  */
 	      bitsize = f.end - f.start + 1;
 	      total_size = e->size * TARGET_CHAR_BIT;
-	      if (gdbarch_bits_big_endian (m_gdbarch))
+	      if (gdbarch_byte_order (m_gdbarch) == BFD_ENDIAN_BIG)
 		SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
 	      else
 		SET_FIELD_BITPOS (fld[0], f.start);
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 4920cfc..887acc8 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1723,7 +1723,7 @@
   word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
 				   type_byte_order (type));
   rel_index %= TARGET_CHAR_BIT;
-  if (gdbarch_bits_big_endian (gdbarch))
+  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
diff --git a/gdb/value.c b/gdb/value.c
index 2e2117b..7818080 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -273,8 +273,8 @@
   LONGEST bitsize = 0;
 
   /* Only used for bitfields; position of start of field.  For
-     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.  */
+     little-endian targets, it is the position of the LSB.  For
+     big-endian targets, it is the position of the MSB.  */
   LONGEST bitpos = 0;
 
   /* The number of references to this value.  When a value is created,
@@ -3135,7 +3135,7 @@
 
   /* Extract bits.  See comment above.  */
 
-  if (gdbarch_bits_big_endian (get_type_arch (field_type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize);
   else
     lsbcount = (bitpos % 8);
@@ -3311,7 +3311,7 @@
   oword = extract_unsigned_integer (addr, bytesize, byte_order);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
-  if (gdbarch_bits_big_endian (get_type_arch (type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     bitpos = bytesize * 8 - bitpos - bitsize;
 
   oword &= ~(mask << bitpos);
diff --git a/gdb/value.h b/gdb/value.h
index 96c9c21..0816247 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -146,8 +146,8 @@
 extern void set_value_bitsize (struct value *, LONGEST bit);
 
 /* Only used for bitfields; position of start of field.  For
-   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.  */
+   little-endian targets, it is the position of the LSB.  For
+   big-endian targets, it is the position of the MSB.  */
 
 extern LONGEST value_bitpos (const struct value *);
 extern void set_value_bitpos (struct value *, LONGEST bit);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [review v2] Remove gdbarch_bits_big_endian
  2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
                   ` (2 preceding siblings ...)
  2019-12-04 14:36 ` [review v2] " Tom Tromey (Code Review)
@ 2019-12-04 15:35 ` Simon Marchi (Code Review)
  2019-12-04 16:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  4 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi (Code Review) @ 2019-12-04 15:35 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................


Patch Set 2: Code-Review+2

(1 comment)

| --- gdb/gdbtypes.h
| +++ gdb/gdbtypes.h
| @@ -545,16 +545,15 @@ };
|  
|  union type_owner
|  {
|    struct objfile *objfile;
|    struct gdbarch *gdbarch;
|  };
|  
|  union field_location
|  {
|    /* * Position of this field, counting in bits from start of

PS1, Line 554:

Ah ok, I have always seen /** (without space between the asterisks)
for Doxygen.

| -     containing structure.  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.  */
| +     containing structure.  For big-endian targets, it is the bit
| +     offset to the MSB.  For little-endian targets, it is the bit
| +     offset to the LSB.  */
|  
|    LONGEST bitpos;

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Wed, 04 Dec 2019 15:35:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Tom Tromey <tromey@sourceware.org>
Comment-In-Reply-To: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pushed] Remove gdbarch_bits_big_endian
  2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
                   ` (3 preceding siblings ...)
  2019-12-04 15:35 ` Simon Marchi (Code Review)
@ 2019-12-04 16:41 ` Sourceware to Gerrit sync (Code Review)
  4 siblings, 0 replies; 6+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-12-04 16:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Simon Marchi

Sourceware to Gerrit sync has submitted this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/729
......................................................................

Remove gdbarch_bits_big_endian

From what I can tell, set_gdbarch_bits_big_endian has never been used.
That is, all architectures since its introduction have simply used the
default, which is simply check the architecture's byte-endianness.

Because this interferes with the scalar_storage_order code, this patch
removes this gdbarch setting entirely.  In some places,
type_byte_order is used rather than the plain gdbarch.

gdb/ChangeLog
2019-12-04  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (decode_constrained_packed_array)
	(ada_value_assign, value_assign_to_component): Update.
	* dwarf2loc.c (rw_pieced_value, access_memory)
	(dwarf2_compile_expr_to_ax): Update.
	* dwarf2read.c (dwarf2_add_field): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (bits_big_endian): Remove.
	* gdbtypes.h (union field_location): Update comment.
	* target-descriptions.c (make_gdb_type): Update.
	* valarith.c (value_bit_index): Update.
	* value.c (struct value) <bitpos>: Update comment.
	(unpack_bits_as_long, modify_field): Update.
	* value.h (value_bitpos): Update comment.

Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
---
M gdb/ChangeLog
M gdb/ada-lang.c
M gdb/dwarf2loc.c
M gdb/dwarf2read.c
M gdb/eval.c
M gdb/gdbarch.c
M gdb/gdbarch.h
M gdb/gdbarch.sh
M gdb/gdbtypes.h
M gdb/target-descriptions.c
M gdb/valarith.c
M gdb/value.c
M gdb/value.h
13 files changed, 37 insertions(+), 55 deletions(-)

Approvals:
  Simon Marchi: Looks good to me, approved


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af39621..e09a588 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
 2019-12-04  Tom Tromey  <tromey@adacore.com>
 
+	* ada-lang.c (decode_constrained_packed_array)
+	(ada_value_assign, value_assign_to_component): Update.
+	* dwarf2loc.c (rw_pieced_value, access_memory)
+	(dwarf2_compile_expr_to_ax): Update.
+	* dwarf2read.c (dwarf2_add_field): Update.
+	* eval.c (evaluate_subexp_standard): Update.
+	* gdbarch.c, gdbarch.h: Rebuild.
+	* gdbarch.sh (bits_big_endian): Remove.
+	* gdbtypes.h (union field_location): Update comment.
+	* target-descriptions.c (make_gdb_type): Update.
+	* valarith.c (value_bit_index): Update.
+	* value.c (struct value) <bitpos>: Update comment.
+	(unpack_bits_as_long, modify_field): Update.
+	* value.h (value_bitpos): Update comment.
+
+2019-12-04  Tom Tromey  <tromey@adacore.com>
+
 	* gdbtypes.c (type_byte_order): Move earlier.  Assert for unknown
 	endian-ness.
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7959a5f..3289a8e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2257,7 +2257,7 @@
       return NULL;
     }
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (arr)))
+  if (type_byte_order (value_type (arr)) == BFD_ENDIAN_BIG
       && ada_is_modular_type (value_type (arr)))
     {
        /* This is a (right-justified) modular type representing a packed
@@ -2499,7 +2499,7 @@
   const gdb_byte *src;                /* First byte containing data to unpack */
   gdb_byte *unpacked;
   const int is_scalar = is_scalar_type (type);
-  const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+  const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
   gdb::byte_vector staging;
 
   type = ada_check_typedef (type);
@@ -2645,7 +2645,7 @@
       if (from_size == 0)
 	from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT;
 
-      const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
+      const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
       ULONGEST from_offset = 0;
       if (is_big_endian && is_scalar_type (value_type (fromval)))
 	from_offset = from_size - bits;
@@ -2694,7 +2694,7 @@
   else
     bits = value_bitsize (component);
 
-  if (gdbarch_bits_big_endian (get_type_arch (value_type (container))))
+  if (type_byte_order (value_type (container)) == BFD_ENDIAN_BIG)
     {
       int src_offset;
 
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 0b22745..976d453 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1577,8 +1577,7 @@
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (v);
   gdb::byte_vector buffer;
-  int bits_big_endian
-    = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
+  bool bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG;
 
   if (from != NULL)
     {
@@ -2817,7 +2816,7 @@
   if (8 * nbytes == nbits)
     return;
 
-  if (gdbarch_bits_big_endian (arch))
+  if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
     {
       /* On a bits-big-endian machine, we want the high-order
 	 NBITS.  */
@@ -2867,7 +2866,7 @@
   enum bfd_endian byte_order = gdbarch_byte_order (arch);
   ULONGEST bits_collected = 0;
   unsigned int addr_size_bits = 8 * addr_size;
-  int bits_big_endian = gdbarch_bits_big_endian (arch);
+  bool bits_big_endian = byte_order == BFD_ENDIAN_BIG;
 
   std::vector<int> offsets (op_end - op_ptr, -1);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 40d93c9..e009b52 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15127,7 +15127,7 @@
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr != nullptr)
 	{
-	  if (gdbarch_bits_big_endian (gdbarch))
+	  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
 	    {
 	      /* For big endian bits, the DW_AT_bit_offset gives the
 	         additional bit offset from the MSB of the containing
diff --git a/gdb/eval.c b/gdb/eval.c
index 72f5109..8787442 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1547,7 +1547,7 @@
 		{
 		  int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
 
-		  if (gdbarch_bits_big_endian (exp->gdbarch))
+		  if (gdbarch_byte_order (exp->gdbarch) == BFD_ENDIAN_BIG)
 		    bit_index = TARGET_CHAR_BIT - 1 - bit_index;
 		  valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
 		    |= 1 << bit_index;
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index fa6be50..59c97da 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -172,7 +172,6 @@
 
      */
 
-  int bits_big_endian;
   int short_bit;
   int int_bit;
   int long_bit;
@@ -389,7 +388,6 @@
   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;
@@ -528,7 +526,6 @@
   if (gdbarch->bfd_arch_info == NULL)
     log.puts ("\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 */
@@ -817,9 +814,6 @@
                       "gdbarch_dump: bfd_arch_info = %s\n",
                       gdbarch_bfd_arch_info (gdbarch)->printable_name);
   fprintf_unfiltered (file,
-                      "gdbarch_dump: bits_big_endian = %s\n",
-                      plongest (gdbarch->bits_big_endian));
-  fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <%s>\n",
                       host_address_to_string (gdbarch->breakpoint_from_pc));
   fprintf_unfiltered (file,
@@ -1565,23 +1559,6 @@
 }
 
 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)
 {
   gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 01b5aef..78e05ec 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -146,12 +146,6 @@
 
 /* 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 short or unsigned short for the target machine. */
 
 extern int gdbarch_short_bit (struct gdbarch *gdbarch);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 62f68dc..331eb39 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -347,10 +347,6 @@
 #
 i;const struct target_desc *;target_desc;;;;;;;host_address_to_string (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 short or unsigned short for the target machine.
 v;int;short_bit;;;8 * sizeof (short);2*TARGET_CHAR_BIT;;0
 # Number of bits in an int or unsigned int for the target machine.
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f6879e8..e399f5f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -552,10 +552,9 @@
 union field_location
 {
   /* * Position of this field, counting in bits from start of
-     containing structure.  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.  */
+     containing structure.  For big-endian targets, it is the bit
+     offset to the MSB.  For little-endian targets, it is the bit
+     offset to the LSB.  */
 
   LONGEST bitpos;
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index f83c2f9..29b80dd 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -224,7 +224,7 @@
 		 the total size of the structure.  */
 	      bitsize = f.end - f.start + 1;
 	      total_size = e->size * TARGET_CHAR_BIT;
-	      if (gdbarch_bits_big_endian (m_gdbarch))
+	      if (gdbarch_byte_order (m_gdbarch) == BFD_ENDIAN_BIG)
 		SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
 	      else
 		SET_FIELD_BITPOS (fld[0], f.start);
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 4920cfc..887acc8 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1723,7 +1723,7 @@
   word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
 				   type_byte_order (type));
   rel_index %= TARGET_CHAR_BIT;
-  if (gdbarch_bits_big_endian (gdbarch))
+  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
diff --git a/gdb/value.c b/gdb/value.c
index 2e2117b..7818080 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -273,8 +273,8 @@
   LONGEST bitsize = 0;
 
   /* Only used for bitfields; position of start of field.  For
-     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.  */
+     little-endian targets, it is the position of the LSB.  For
+     big-endian targets, it is the position of the MSB.  */
   LONGEST bitpos = 0;
 
   /* The number of references to this value.  When a value is created,
@@ -3135,7 +3135,7 @@
 
   /* Extract bits.  See comment above.  */
 
-  if (gdbarch_bits_big_endian (get_type_arch (field_type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize);
   else
     lsbcount = (bitpos % 8);
@@ -3311,7 +3311,7 @@
   oword = extract_unsigned_integer (addr, bytesize, byte_order);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
-  if (gdbarch_bits_big_endian (get_type_arch (type)))
+  if (byte_order == BFD_ENDIAN_BIG)
     bitpos = bytesize * 8 - bitpos - bitsize;
 
   oword &= ~(mask << bitpos);
diff --git a/gdb/value.h b/gdb/value.h
index 96c9c21..0816247 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -146,8 +146,8 @@
 extern void set_value_bitsize (struct value *, LONGEST bit);
 
 /* Only used for bitfields; position of start of field.  For
-   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.  */
+   little-endian targets, it is the position of the LSB.  For
+   big-endian targets, it is the position of the MSB.  */
 
 extern LONGEST value_bitpos (const struct value *);
 extern void set_value_bitpos (struct value *, LONGEST bit);

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
Gerrit-Change-Number: 729
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-04 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 18:56 [review] Remove gdbarch_bits_big_endian Tom Tromey (Code Review)
2019-11-27 22:09 ` Simon Marchi (Code Review)
2019-12-03 21:32 ` Tom Tromey (Code Review)
2019-12-04 14:36 ` [review v2] " Tom Tromey (Code Review)
2019-12-04 15:35 ` Simon Marchi (Code Review)
2019-12-04 16:41 ` [pushed] " Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).