summaryrefslogtreecommitdiff
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
commit96d936129086666d8be9f243efc1b73e00478763 (patch)
tree051293fd3bb07e957a5d53f8a2f48f681b6837f6 /gdb/varobj.c
parente65af494f33cf1fa7cde06d267fb8c5be4e288b6 (diff)
downloadgdb-96d936129086666d8be9f243efc1b73e00478763.tar.gz
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 dc1c356a0b4..f97c0909053 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: