* [python] fix PR 10584
@ 2009-09-03 18:11 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2009-09-03 18:11 UTC (permalink / raw)
To: Project Archer
I'm checking this in on the python branch.
This fixes PR 10584, a case where a scalar varobj did not properly
update when the underlying value changed.
I've included a regression test.
Tom
2009-09-03 Tom Tromey <tromey@redhat.com>
* varobj.c (install_new_value): Properly set 'changed' when a
pretty-printer is installed.
(varobj_update): Push a changed varobj even if it has no
children.
2009-09-03 Tom Tromey <tromey@redhat.com>
* gdb.python/python-prettyprint.c (string_1, string_2): New
globals.
* gdb.python/python-mi.exp: Add scalar regression test.
diff --git a/gdb/testsuite/gdb.python/python-mi.exp b/gdb/testsuite/gdb.python/python-mi.exp
index 018c6a2..7791775 100644
--- a/gdb/testsuite/gdb.python/python-mi.exp
+++ b/gdb/testsuite/gdb.python/python-mi.exp
@@ -61,6 +61,17 @@ mi_delete_varobj container "delete varobj"
mi_gdb_test "-enable-pretty-printing" ""
+mi_create_varobj_checked string string_1 \
+ "struct string_repr" \
+ "create string_1 varobj"
+
+mi_gdb_test "-data-evaluate-expression \"string_1 = string_2\"" ".*" \
+ "assign string_1 from string_2"
+
+mi_gdb_test "-var-update string" \
+ "\\^done,changelist=\\\[{name=\"string\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"}\\\]" \
+ "update string varobj after assignment"
+
mi_create_dynamic_varobj container c \
"create container varobj"
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
index 5fbd534..adf66b5 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.c
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -155,6 +155,9 @@ struct nullstr
char *s;
};
+struct string_repr string_1 = { { "one" } };
+struct string_repr string_2 = { { "two" } };
+
int
main ()
{
diff --git a/gdb/varobj.c b/gdb/varobj.c
index b6a16d2..e1dec23 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1551,9 +1551,6 @@ install_new_value (struct varobj *var, struct value *value, int initial)
var->value = value;
if (value != NULL)
value_incref (value);
- if (var->print_value)
- xfree (var->print_value);
- var->print_value = print_value;
if (value && value_lazy (value) && intentionally_not_fetched)
var->not_fetched = 1;
else
@@ -1562,6 +1559,19 @@ install_new_value (struct varobj *var, struct value *value, int initial)
install_new_value_visualizer (var);
+ /* If we installed a pretty-printer, re-compare the printed version
+ to see if the variable changed. */
+ if (var->pretty_printer)
+ {
+ xfree (print_value);
+ print_value = value_get_print_value (var->value, var->format, var);
+ if (!var->print_value || strcmp (var->print_value, print_value) != 0)
+ changed = 1;
+ }
+ if (var->print_value)
+ xfree (var->print_value);
+ var->print_value = print_value;
+
gdb_assert (!var->value || value_type (var->value));
return changed;
@@ -1746,11 +1756,14 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
it as unchanged -- presumably, such varobj is not yet
expanded in the UI, so we need not bother getting
it. */
- if (varobj_has_more (v, 0))
- continue;
+ if (!varobj_has_more (v, 0))
+ {
+ update_dynamic_varobj_children (v, NULL, NULL, &dummy, 0, 0);
+ if (varobj_has_more (v, 0))
+ r.changed = 1;
+ }
- update_dynamic_varobj_children (v, NULL, NULL, &dummy, 0, 0);
- if (varobj_has_more (v, 0))
+ if (r.changed)
VEC_safe_push (varobj_update_result, result, &r);
continue;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-03 18:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-03 18:11 [python] fix PR 10584 Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).