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) <bit_stride>: New method. (struct type) <bit_stride>: New method. (TYPE_BIT_STRIDE): Remove. * gdbtypes.c (update_static_array_size): Use type::bit_stride. Change-Id: I6ecc1cfefdc20711fa8f188a94a05c1e116c9922
This commit is contained in:
parent
bb789949e9
commit
107406b738
@ -1,3 +1,10 @@
|
||||
2020-07-12 Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
* gdbtypes.h (struct range_bounds) <bit_stride>: New method.
|
||||
(struct type) <bit_stride>: New method.
|
||||
(TYPE_BIT_STRIDE): Remove.
|
||||
* gdbtypes.c (update_static_array_size): Use type::bit_stride.
|
||||
|
||||
2020-07-12 Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
* gdbtypes.h (TYPE_ARRAY_LOWER_BOUND_VALUE,
|
||||
|
@ -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;
|
||||
|
@ -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++ */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user