+2020-07-12 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (struct type) <bounds, set_bounds>: New methods.
+ (TYPE_RANGE_DATA): Use type::bounds. Change all uses that
+ are used to set the range type's bounds to use set_bounds.
+
2020-07-11 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* exec.c (_initialize_exec): Update exec-file-mismatch help.
else
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
- TYPE_RANGE_DATA (result_type) = (struct range_bounds *)
- TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
- TYPE_RANGE_DATA (result_type)->low = *low_bound;
- TYPE_RANGE_DATA (result_type)->high = *high_bound;
- TYPE_RANGE_DATA (result_type)->bias = bias;
+ range_bounds *bounds
+ = (struct range_bounds *) TYPE_ZALLOC (result_type, sizeof (range_bounds));
+ bounds->low = *low_bound;
+ bounds->high = *high_bound;
+ bounds->bias = bias;
/* Initialize the stride to be a constant, the value will already be zero
thanks to the use of TYPE_ZALLOC above. */
- TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST;
+ bounds->stride.kind = PROP_CONST;
+
+ result_type->set_bounds (bounds);
if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
TYPE_UNSIGNED (result_type) = 1;
/* For range types, copy the bounds information. */
if (type->code () == TYPE_CODE_RANGE)
{
- TYPE_RANGE_DATA (new_type) = (struct range_bounds *)
- TYPE_ALLOC (new_type, sizeof (struct range_bounds));
- *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
+ range_bounds *bounds
+ = ((struct range_bounds *) TYPE_ALLOC
+ (new_type, sizeof (struct range_bounds)));
+
+ *bounds = *type->bounds ();
+ new_type->set_bounds (bounds);
}
if (type->main_type->dyn_prop_list != NULL)
this->field (0).set_type (index_type);
}
+ /* Get the bounds bounds of this type. The type must be a range type. */
+ range_bounds *bounds () const
+ {
+ gdb_assert (this->code () == TYPE_CODE_RANGE);
+
+ return this->main_type->flds_bnds.bounds;
+ }
+
+ /* Set the bounds of this type. The type must be a range type. */
+ void set_bounds (range_bounds *bounds)
+ {
+ gdb_assert (this->code () == TYPE_CODE_RANGE);
+
+ this->main_type->flds_bnds.bounds = bounds;
+ }
+
/* * 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;
space in struct type. */
extern bool set_type_align (struct type *, ULONGEST);
-#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
+#define TYPE_RANGE_DATA(thistype) ((thistype)->bounds ())
#define TYPE_LOW_BOUND(range_type) \
TYPE_RANGE_DATA(range_type)->low.data.const_val
#define TYPE_HIGH_BOUND(range_type) \
if (t->bt == btRange)
{
tp->set_num_fields (0);
- TYPE_RANGE_DATA (tp) = ((struct range_bounds *)
- TYPE_ZALLOC (tp, sizeof (struct range_bounds)));
+ tp->set_bounds (((struct range_bounds *)
+ TYPE_ZALLOC (tp, sizeof (struct range_bounds))));
TYPE_LOW_BOUND (tp) = AUX_GET_DNLOW (bigend, ax);
ax++;
TYPE_HIGH_BOUND (tp) = AUX_GET_DNHIGH (bigend, ax);