From: Simon Marchi Date: Mon, 13 Jul 2020 02:58:53 +0000 (-0400) Subject: gdb: remove TYPE_BIT_STRIDE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=107406b7380489559c70702b8e6e9b3395c2662a;p=binutils-gdb.git gdb: remove TYPE_BIT_STRIDE Remove the macro and add a `bit_stride` method to `struct range_bounds`, which does the byte -> bit conversion if needed. Add a convenience `bit_stride` method to `struct type` as well. I don't really understand why the bit/byte stride is stored in the data structure for bounds. Maybe it was just put there because `range_bounds` was already a data structure specific to TYPE_CODE_RANGE types? If the stride is indeed not related to the bounds, then I find it more logical to do `my_range_type->bit_stride ()` than `my_range_type->bounds ()->bit_stride ()`, hence the convenience function on `struct type`. gdb/ChangeLog: * gdbtypes.h (struct range_bounds) : New method. (struct type) : New method. (TYPE_BIT_STRIDE): Remove. * gdbtypes.c (update_static_array_size): Use type::bit_stride. Change-Id: I6ecc1cfefdc20711fa8f188a94a05c1e116c9922 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ab2b7778075..444315e9733 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-07-12 Simon Marchi + + * gdbtypes.h (struct range_bounds) : New method. + (struct type) : New method. + (TYPE_BIT_STRIDE): Remove. + * gdbtypes.c (update_static_array_size): Use type::bit_stride. + 2020-07-12 Simon Marchi * gdbtypes.h (TYPE_ARRAY_LOWER_BOUND_VALUE, diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 227f696b736..e87648813ec 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1205,7 +1205,7 @@ update_static_array_size (struct type *type) arrays bit size field. */ stride = TYPE_FIELD_BITSIZE (type, 0); if (stride == 0) - stride = TYPE_BIT_STRIDE (range_type); + stride = range_type->bit_stride (); if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) low_bound = high_bound = 0; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 26db7935f26..bf6b270515f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -757,6 +757,14 @@ struct field struct range_bounds { + ULONGEST bit_stride () const + { + if (this->flag_is_byte_stride) + return this->stride.const_val () * 8; + else + return this->stride.const_val (); + } + /* * Low bound of range. */ struct dynamic_prop low; @@ -1045,6 +1053,11 @@ struct type this->main_type->flds_bnds.bounds = bounds; } + ULONGEST bit_stride () const + { + return this->bounds ()->bit_stride (); + } + /* * Return the dynamic property of the requested KIND from this type's list of dynamic properties. */ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; @@ -1594,10 +1607,6 @@ extern unsigned type_align (struct type *); space in struct type. */ extern bool set_type_align (struct type *, ULONGEST); -#define TYPE_BIT_STRIDE(range_type) \ - ((range_type)->bounds ()->stride.const_val () \ - * ((range_type)->bounds ()->flag_is_byte_stride ? 8 : 1)) - /* Property accessors for the type data location. */ #define TYPE_DATA_LOCATION(thistype) \ ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)) @@ -1629,7 +1638,7 @@ extern bool set_type_align (struct type *, ULONGEST); index type. */ #define TYPE_ARRAY_BIT_STRIDE(arraytype) \ - (TYPE_BIT_STRIDE(((arraytype)->index_type ()))) + ((arraytype)->index_type ()->bounds ()->bit_stride ()) /* C++ */