aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-07-12 22:58:53 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2020-07-12 22:58:53 -0400
commit107406b7380489559c70702b8e6e9b3395c2662a (patch)
treedb0420345533a1a7e5fdb6b4dc327058c9d79fff
parentbb789949e90d4580ce0ce9034c632d3e7f39a0ac (diff)
downloadgdb-107406b7380489559c70702b8e6e9b3395c2662a.zip
gdb-107406b7380489559c70702b8e6e9b3395c2662a.tar.gz
gdb-107406b7380489559c70702b8e6e9b3395c2662a.tar.bz2
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
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/gdbtypes.c2
-rw-r--r--gdb/gdbtypes.h19
3 files changed, 22 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ab2b777..444315e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
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,
TYPE_ARRAY_UPPER_BOUND_VALUE): Remove. Update all
callers to use the equivalent accessor methods instead.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 227f696..e876488 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 26db793..bf6b270 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++ */