aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2016-11-21 14:15:06 +0000
committerYao Qi <yao.qi@linaro.org>2016-11-21 14:15:06 +0000
commit3fff9862d5229def9318912c2de64a03dab74532 (patch)
tree15dedc88e7f86a779b2ce53554802a4178f0b6f5 /gdb/value.c
parent5689c9424b33aac68c4762ce0bda09ca7e3affe0 (diff)
downloadgdb-3fff9862d5229def9318912c2de64a03dab74532.zip
gdb-3fff9862d5229def9318912c2de64a03dab74532.tar.gz
gdb-3fff9862d5229def9318912c2de64a03dab74532.tar.bz2
Create subobject value in pretty printer
Nowadays, we create a value of subobject in pretty printer with 'address' being used, value = value_from_contents_and_address (type, valaddr + embedded_offset, address + embedded_offset); set_value_component_location (value, val); /* set_value_component_location resets the address, so we may need to set it again. */ if (VALUE_LVAL (value) != lval_internalvar && VALUE_LVAL (value) != lval_internalvar_component && VALUE_LVAL (value) != lval_computed) set_value_address (value, address + embedded_offset); value_from_contents_and_address creates a value from memory, but the value we are pretty-printing may not from memory at all. Instead of using value_from_contents_and_address, we create a value of subobject with the same location as object's but different offset. We avoid using address in this way. As a result, parameter 'address' in apply_val_pretty_printer is no longer needed, we can remove it in next step. We've already had the location of the 'whole' value, so it is safe to assume we can create a value of 'component' or 'suboject' value at the same location but with different offset. gdb: 2016-11-21 Yao Qi <yao.qi@linaro.org> * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Don't call value_from_contents_and_address and set_value_address. Call value_from_component. * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Likewise. * value.c (value_from_component): New function. * value.h (value_from_component): Likewise. * valarith.c (value_subscripted_rvalue): Call value_from_component.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/value.c b/gdb/value.c
index 0575a55..200d61d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3795,6 +3795,31 @@ value_from_history_ref (const char *h, const char **endp)
return access_value_history (index);
}
+/* Get the component value (offset by OFFSET bytes) of a struct or
+ union WHOLE. Component's type is TYPE. */
+
+struct value *
+value_from_component (struct value *whole, struct type *type, LONGEST offset)
+{
+ struct value *v;
+
+ if (VALUE_LVAL (whole) == lval_memory && value_lazy (whole))
+ v = allocate_value_lazy (type);
+ else
+ {
+ v = allocate_value (type);
+ value_contents_copy (v, value_embedded_offset (v),
+ whole, value_embedded_offset (whole) + offset,
+ type_length_units (type));
+ }
+ v->offset = value_offset (whole) + offset + value_embedded_offset (whole);
+ set_value_component_location (v, whole);
+ VALUE_REGNUM (v) = VALUE_REGNUM (whole);
+ VALUE_FRAME_ID (v) = VALUE_FRAME_ID (whole);
+
+ return v;
+}
+
struct value *
coerce_ref_if_computed (const struct value *arg)
{