[review] Remove gdbarch_bits_big_endian
Commit Message
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(-)
Comments
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;
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;
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;
@@ -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>
@@ -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;
@@ -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);
@@ -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
@@ -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;
@@ -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);
@@ -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);
@@ -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.
@@ -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;
@@ -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);
@@ -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;
}
@@ -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);
@@ -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);