aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorAnton Gorenkov <xgsa@sourceware.org>2012-02-21 13:48:59 +0000
committerAnton Gorenkov <xgsa@sourceware.org>2012-02-21 13:48:59 +0000
commitdfcee124897d3395925bdfbfded468c9c81394a0 (patch)
treeff8b1acd9e1b0763ff5edff8183a73fbc997643e /gdb/valops.c
parent16a87420985f256b5cde070586ebcdfda2225b01 (diff)
downloadgdb-dfcee124897d3395925bdfbfded468c9c81394a0.zip
gdb-dfcee124897d3395925bdfbfded468c9c81394a0.tar.gz
gdb-dfcee124897d3395925bdfbfded468c9c81394a0.tar.bz2
gdb/
* c-valprint.c (c_value_print): Use value_rtti_indirect_type instead of value_rtti_target_type. * eval.c (evaluate_subexp_standard): Use value_rtti_indirect_type instead of value_rtti_target_type. * typeprint.c (whatis_exp): Use value_rtti_indirect_type instead of value_rtti_target_type. * valops.c (value_ind): Extract function readjust_indirect_value_type. (value_rtti_target_type): Rename to ... (value_rtti_indirect_type): ... here and make it indirect. Update function comment. * value.c (readjust_indirect_value_type): New function. (coerce_ref): Support for enclosing type setting for references with readjust_indirect_value_type. * value.h (readjust_value_type): New declaration. (value_rtti_target_type): Rename to ... (value_rtti_indirect_type): ... here.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index fca601f..ee450e3 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1772,15 +1772,7 @@ value_ind (struct value *arg1)
(value_as_address (arg1)
- value_pointed_to_offset (arg1)));
- /* Re-adjust type. */
- deprecated_set_value_type (arg2, TYPE_TARGET_TYPE (base_type));
- /* Add embedding info. */
- set_value_enclosing_type (arg2, enc_type);
- set_value_embedded_offset (arg2, value_pointed_to_offset (arg1));
-
- /* We may be pointing to an object of some derived type. */
- arg2 = value_full_object (arg2, NULL, 0, 0, 0);
- return arg2;
+ return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
}
error (_("Attempt to take contents of a non-pointer value."));
@@ -3526,21 +3518,48 @@ value_maybe_namespace_elt (const struct type *curtype,
return result;
}
-/* Given a pointer value V, find the real (RTTI) type of the object it
- points to.
+/* Given a pointer or a reference value V, find its real (RTTI) type.
Other parameters FULL, TOP, USING_ENC as with value_rtti_type()
and refer to the values computed for the object pointed to. */
struct type *
-value_rtti_target_type (struct value *v, int *full,
- int *top, int *using_enc)
+value_rtti_indirect_type (struct value *v, int *full,
+ int *top, int *using_enc)
{
struct value *target;
+ struct type *type, *real_type, *target_type;
+
+ type = value_type (v);
+ type = check_typedef (type);
+ if (TYPE_CODE (type) == TYPE_CODE_REF)
+ target = coerce_ref (v);
+ else if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ target = value_ind (v);
+ else
+ return NULL;
- target = value_ind (v);
+ real_type = value_rtti_type (target, full, top, using_enc);
+
+ if (real_type)
+ {
+ /* Copy qualifiers to the referenced object. */
+ target_type = value_type (target);
+ real_type = make_cv_type (TYPE_CONST (target_type),
+ TYPE_VOLATILE (target_type), real_type, NULL);
+ if (TYPE_CODE (type) == TYPE_CODE_REF)
+ real_type = lookup_reference_type (real_type);
+ else if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ real_type = lookup_pointer_type (real_type);
+ else
+ internal_error (__FILE__, __LINE__, _("Unexpected value type."));
+
+ /* Copy qualifiers to the pointer/reference. */
+ real_type = make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type),
+ real_type, NULL);
+ }
- return value_rtti_type (target, full, top, using_enc);
+ return real_type;
}
/* Given a value pointed to by ARGP, check its real run-time type, and