aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2007-01-24 10:49:31 +0000
committerVladimir Prus <vladimir@codesourcery.com>2007-01-24 10:49:31 +0000
commit6e2a9270a0ea3be318f176ea87d84a323d2ed239 (patch)
tree9522a06ed11072f25faf284a2db7a1a0e54eac50 /gdb/varobj.c
parent56163ce1d3a08ade22d84d366dc9066df789914a (diff)
downloadgdb-6e2a9270a0ea3be318f176ea87d84a323d2ed239.zip
gdb-6e2a9270a0ea3be318f176ea87d84a323d2ed239.tar.gz
gdb-6e2a9270a0ea3be318f176ea87d84a323d2ed239.tar.bz2
Fix computation of the 'editable' attribute and
value changeability for for references. * varobj.c (get_value_type): New function. (c_variable_editable): Use get_value_type. (varobj_value_is_changeable): Likewise.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index dc1c356..f97c090 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -176,6 +176,8 @@ static struct cleanup *make_cleanup_free_variable (struct varobj *var);
static struct type *get_type (struct varobj *var);
+static struct type *get_value_type (struct varobj *var);
+
static struct type *get_type_deref (struct varobj *var);
static struct type *get_target_type (struct type *);
@@ -1459,6 +1461,37 @@ get_type (struct varobj *var)
return type;
}
+/* Return the type of the value that's stored in VAR,
+ or that would have being stored there if the
+ value were accessible.
+
+ This differs from VAR->type in that VAR->type is always
+ the true type of the expession in the source language.
+ The return value of this function is the type we're
+ actually storing in varobj, and using for displaying
+ the values and for comparing previous and new values.
+
+ For example, top-level references are always stripped. */
+static struct type *
+get_value_type (struct varobj *var)
+{
+ struct type *type;
+
+ if (var->value)
+ type = value_type (var->value);
+ else
+ type = var->type;
+
+ type = check_typedef (type);
+
+ if (TYPE_CODE (type) == TYPE_CODE_REF)
+ type = get_target_type (type);
+
+ type = check_typedef (type);
+
+ return type;
+}
+
/* This returns the type of the variable, dereferencing references, pointers
and references to pointers, too. */
static struct type *
@@ -1723,7 +1756,7 @@ varobj_value_is_changeable_p (struct varobj *var)
if (CPLUS_FAKE_CHILD (var))
return 0;
- type = get_type (var);
+ type = get_value_type (var);
switch (TYPE_CODE (type))
{
@@ -2020,7 +2053,7 @@ c_type_of_child (struct varobj *parent, int index)
static int
c_variable_editable (struct varobj *var)
{
- switch (TYPE_CODE (get_type (var)))
+ switch (TYPE_CODE (get_value_type (var)))
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION: