aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2009-05-17 07:13:19 +0000
committerVladimir Prus <vladimir@codesourcery.com>2009-05-17 07:13:19 +0000
commitee342b2344e091d2d8a5bfea83b19f651ea58dff (patch)
tree854f620f66decdde5bda9c56600f0b2e5782f9ae
parent177b81d66a6cf42aaa2b15ccc499bb7b292c3955 (diff)
downloadgdb-ee342b2344e091d2d8a5bfea83b19f651ea58dff.zip
gdb-ee342b2344e091d2d8a5bfea83b19f651ea58dff.tar.gz
gdb-ee342b2344e091d2d8a5bfea83b19f651ea58dff.tar.bz2
Always report varobj as changed when in_scope attribute changes.
* varobj.c (install_new_value): If non-NULL-ness of value changed, return 1.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cmd.exp27
-rw-r--r--gdb/varobj.c18
4 files changed, 55 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 14b12de..b676f11 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-17 Vladimir Prus <vladimir@codesourcery.com>
+
+ Always report varobj as changed when in_scope attribute changes.
+
+ * varobj.c (install_new_value): If non-NULL-ness of value
+ changed, return 1.
+
2009-05-15 Paul Pluzhnikov <ppluzhnikov@google.com>
* NEWS: Mention set/show libthread-db-search-path.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a9d5de7..54d1de6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-17 Vladimir Prus <vladimir@codesourcery.com>
+
+ * gdb.mi/mi-cmd-var.exp: Check that when varobj
+ of structure type enters or leaves the scope, it
+ is reported by -var-update.
+
2009-05-11 Doug Evans <dje@sebabeach.org>
* gdb.mi/nsintrall.c (main): Fix off-by-one error.
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index ffe0b79..78b30bd 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -631,5 +631,32 @@ mi_gdb_test "-var-delete endvar" \
"\\^done,ndeleted=\"1\"" \
"delete endvar"
+mi_delete_breakpoints
+
+mi_runto do_locals_tests
+
+mi_create_varobj "L" "lsimple" "in-and-out-of-scope: create varobj"
+mi_check_varobj_value "L" "{...}" "in-and-out-of-scope: check initial value"
+
+mi_runto main
+
+mi_gdb_test "-var-update L" \
+ {\^done,changelist=\[{name="L",in_scope="false",type_changed="false"}\]} \
+ "in-and-out-of-scope: out of scope now"
+
+mi_gdb_test "-var-update L" \
+ {\^done,changelist=\[]} \
+ "in-and-out-of-scope: out of scope now, not changed"
+
+mi_continue_to do_locals_tests
+
+mi_gdb_test "-var-update L" \
+ {\^done,changelist=\[{name="L",in_scope="true",type_changed="false"}\]} \
+ "in-and-out-of-scope: in scope now"
+
+mi_gdb_test "-var-update L" \
+ {\^done,changelist=\[\]} \
+ "in-and-out-of-scope: in scope now, not changed"
+
mi_gdb_exit
return 0
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 8ec67b7..d36e46d 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -982,9 +982,12 @@ varobj_list (struct varobj ***varlist)
this is the first assignement after the variable object was just
created, or changed type. In that case, just assign the value
and return 0.
- Otherwise, assign the value and if type_changeable returns non-zero,
- find if the new value is different from the current value.
- Return 1 if so, and 0 if the values are equal.
+ Otherwise, assign the new value, and return 1 if the value is different
+ from the current one, 0 otherwise. The comparison is done on textual
+ representation of value. Therefore, some types need not be compared. E.g.
+ for structures the reported value is always "{...}", so no comparison is
+ necessary here. If the old value was NULL and new one is not, or vice versa,
+ we always return 1.
The VALUE parameter should not be released -- the function will
take care of releasing it when needed. */
@@ -1105,6 +1108,15 @@ install_new_value (struct varobj *var, struct value *value, int initial)
}
}
+ if (!initial && !changeable)
+ {
+ /* For values that are not changeable, we don't compare the values.
+ However, we want to notice if a value was not NULL and now is NULL,
+ or vise versa, so that we report when top-level varobjs come in scope
+ and leave the scope. */
+ changed = (var->value != NULL) != (value != NULL);
+ }
+
/* We must always keep the new value, since children depend on it. */
if (var->value != NULL && var->value != value)
value_free (var->value);