+2014-08-18 Keven Boell <keven.boell@intel.com>
+ Joel Brobecker <brobecker@adacore.com>
+
+ * gdbtypes.h (struct main_type): Add field "data_location".
+ (TYPE_DATA_LOCATION, TYPE_DATA_LOCATION_BATON)
+ (TYPE_DATA_LOCATION_ADDR, TYPE_DATA_LOCATION_KIND): New macros.
+ * gdbtypes.c (is_dynamic_type): Return 1 if the type has
+ a dynamic data location.
+ (resolve_dynamic_type): Add DW_AT_data_location handling.
+ (copy_recursive, copy_type): Copy the data_location information
+ when present.
+ * dwarf2read.c (set_die_type): Add DW_AT_data_location handling.
+ * value.c (value_from_contents_and_address): Add
+ DW_AT_data_location handling.
+
2014-08-18 Keven Boell <keven.boell@intel.com>
Joel Brobecker <brobecker@adacore.com>
{
struct dwarf2_per_cu_offset_and_type **slot, ofs;
struct objfile *objfile = cu->objfile;
+ struct attribute *attr;
+ struct dynamic_prop prop;
/* For Ada types, make sure that the gnat-specific data is always
initialized (if not already set). There are a few types where
&& !HAVE_GNAT_AUX_INFO (type))
INIT_GNAT_SPECIFIC (type);
+ /* Read DW_AT_data_location and set in type. */
+ attr = dwarf2_attr (die, DW_AT_data_location, cu);
+ if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ {
+ TYPE_DATA_LOCATION (type)
+ = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
+ *TYPE_DATA_LOCATION (type) = prop;
+ }
+
if (dwarf2_per_objfile->die_type_hash == NULL)
{
dwarf2_per_objfile->die_type_hash =
if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
type = check_typedef (TYPE_TARGET_TYPE (type));
+ /* Types that have a dynamic TYPE_DATA_LOCATION are considered
+ dynamic, even if the type itself is statically defined.
+ From a user's point of view, this may appear counter-intuitive;
+ but it makes sense in this context, because the point is to determine
+ whether any part of the type needs to be resolved before it can
+ be exploited. */
+ if (TYPE_DATA_LOCATION (type) != NULL
+ && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR
+ || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
+ return 1;
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_RANGE:
{
struct type *real_type = check_typedef (type);
struct type *resolved_type = type;
+ const struct dynamic_prop *prop;
+ CORE_ADDR value;
if (!is_dynamic_type_internal (real_type, top_level))
return type;
break;
}
+ /* Resolve data_location attribute. */
+ prop = TYPE_DATA_LOCATION (resolved_type);
+ if (dwarf2_evaluate_property (prop, addr, &value))
+ {
+ TYPE_DATA_LOCATION_ADDR (resolved_type) = value;
+ TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST;
+ }
+ else
+ TYPE_DATA_LOCATION (resolved_type) = NULL;
+
return resolved_type;
}
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
+ /* Copy the data location information. */
+ if (TYPE_DATA_LOCATION (type) != NULL)
+ {
+ TYPE_DATA_LOCATION (new_type)
+ = TYPE_ALLOC (new_type, sizeof (struct dynamic_prop));
+ memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
+ sizeof (struct dynamic_prop));
+ }
+
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_TARGET_TYPE (new_type) =
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
sizeof (struct main_type));
+ if (TYPE_DATA_LOCATION (type) != NULL)
+ {
+ TYPE_DATA_LOCATION (new_type)
+ = TYPE_ALLOC (new_type, sizeof (struct dynamic_prop));
+ memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
+ sizeof (struct dynamic_prop));
+ }
return new_type;
}
struct func_type *func_stuff;
} type_specific;
+
+ /* * Contains a location description value for the current type. Evaluating
+ this field yields to the location of the data for an object. */
+
+ struct dynamic_prop *data_location;
};
/* * A ``struct type'' describes a particular instance of a type, with
#define TYPE_LOW_BOUND_KIND(range_type) \
TYPE_RANGE_DATA(range_type)->low.kind
+/* Attribute accessors for the type data location. */
+#define TYPE_DATA_LOCATION(thistype) \
+ TYPE_MAIN_TYPE(thistype)->data_location
+#define TYPE_DATA_LOCATION_BATON(thistype) \
+ TYPE_DATA_LOCATION (thistype)->data.baton
+#define TYPE_DATA_LOCATION_ADDR(thistype) \
+ TYPE_DATA_LOCATION (thistype)->data.const_val
+#define TYPE_DATA_LOCATION_KIND(thistype) \
+ TYPE_DATA_LOCATION (thistype)->kind
+
/* Moto-specific stuff for FORTRAN arrays. */
#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
v = allocate_value_lazy (resolved_type);
else
v = value_from_contents (resolved_type, valaddr);
+ if (TYPE_DATA_LOCATION (resolved_type) != NULL
+ && TYPE_DATA_LOCATION_KIND (resolved_type) == PROP_CONST)
+ address = TYPE_DATA_LOCATION_ADDR (resolved_type);
set_value_address (v, address);
VALUE_LVAL (v) = lval_memory;
return v;