This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] fix -var-set-child-range reporting
- From: Tom Tromey <tromey at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Mon, 14 Sep 2009 13:46:22 -0600
- Subject: [python] fix -var-set-child-range reporting
- Reply-to: tromey at redhat dot com
I'm checking this in on the archer-tromey-python branch.
This fixes a bug that Nick noticed about -var-set-child-range not
properly handling children below the low bound of the range.
Tom
2009-09-14 Tom Tromey <tromey@redhat.com>
* varobj.c (install_dynamic_child): Conditionally update
*cchanged.
(update_dynamic_varobj_children): Add 'from' argument. Update
call to install_dynamic_child. Update all callers.
2009-09-14 Tom Tromey <tromey@redhat.com>
* gdb.python/py-prettyprint.c (main): Add another container
update.
* gdb.python/py-mi.exp: Add regression test.
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index afde8c4..30d6f32 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -161,6 +161,29 @@ mi_list_varobj_children container {
mi_next "next over update 4"
+# This should only show the first child, because the update range has
+# been set.
+mi_varobj_update_dynamic container \
+ "update after next with restricted range" {
+ type_changed false new_num_children 1 dynamic 1 has_more 1
+ } {
+ { name {container.\[0\]} in_scope true type_changed false dynamic 1 has_more 0 }
+ } {
+ }
+
+mi_gdb_test "-var-set-update-range container 3 4" \
+ "\\^done" \
+ "set update range with non-zero start"
+
+# Elements were updated but should not be reported.
+mi_varobj_update_dynamic container \
+ "update varobj with change outside selected range" {
+ type_changed false new_num_children 3 dynamic 1 has_more 0
+ } {
+ } {
+ }
+
+mi_next "next over update 5"
# Regression test: examine an object that has no children, then update
# it to ensure that we don't print the children.
@@ -171,7 +194,7 @@ mi_gdb_test "-var-update container2" \
"\\^done,changelist=.." \
"update varobj, no children requested"
-mi_next "next over update 5"
+mi_next "next over update 6"
# Now container2 has an element -- and an update should mention that
# it has_more. But, because we did not request children, we still
@@ -181,16 +204,6 @@ mi_varobj_update_dynamic container2 \
type_changed false dynamic 1 has_more 1
} {} {}
-# This should only show the first child, because the update range has
-# been set.
-mi_varobj_update_dynamic container \
- "update after next with restricted range" {
- type_changed false new_num_children 1 dynamic 1 has_more 1
- } {
- { name {container.\[0\]} in_scope true type_changed false dynamic 1 has_more 0 }
- } {
- }
-
mi_continue_to_line \
[gdb_get_line_number {MI outer breakpoint here} ${testfile}.c] \
"step to outer breakpoint"
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index bf41ebc..7f16400 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -232,6 +232,7 @@ main ()
#ifdef MI
add_item (&c, 1011);
c.elements[0] = 1023;
+ c.elements[0] = 2323;
add_item (&c2, 2222);
add_item (&c2, 3333);
diff --git a/gdb/varobj.c b/gdb/varobj.c
index e884e19..e7fb589 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -917,8 +917,10 @@ install_dynamic_child (struct varobj *var,
/* There's no child yet. */
struct varobj *child = varobj_add_child (var, name, value);
if (new)
- VEC_safe_push (varobj_p, *new, child);
- *cchanged = 1;
+ {
+ VEC_safe_push (varobj_p, *new, child);
+ *cchanged = 1;
+ }
}
else
{
@@ -957,6 +959,7 @@ update_dynamic_varobj_children (struct varobj *var,
VEC (varobj_p) **unchanged,
int *cchanged,
int update_children,
+ int from,
int to)
{
#if HAVE_PYTHON
@@ -1031,6 +1034,7 @@ update_dynamic_varobj_children (struct varobj *var,
char *name;
struct value *v;
struct cleanup *inner;
+ int can_mention = from < 0 || i >= from;
inner = make_cleanup_py_decref (item);
@@ -1038,8 +1042,10 @@ update_dynamic_varobj_children (struct varobj *var,
error (_("Invalid item from the child list"));
v = convert_value_from_python (py_v);
- install_dynamic_child (var, changed, new, unchanged,
- cchanged, i, name, v);
+ install_dynamic_child (var, can_mention ? changed : NULL,
+ can_mention ? new : NULL,
+ can_mention ? unchanged : NULL,
+ can_mention ? cchanged : NULL, i, name, v);
do_cleanups (inner);
}
else
@@ -1088,7 +1094,8 @@ varobj_get_num_children (struct varobj *var)
/* If we have a dynamic varobj, don't report -1 children.
So, try to fetch some children first. */
- update_dynamic_varobj_children (var, NULL, NULL, NULL, &dummy, 0, 0);
+ update_dynamic_varobj_children (var, NULL, NULL, NULL, &dummy,
+ 0, 0, 0);
}
else
var->num_children = number_of_children (var);
@@ -1115,7 +1122,7 @@ varobj_list_children (struct varobj *var, int *from, int *to)
frontend noticing. But well, calling -var-list-children on the same
varobj twice is not something a sane frontend would do. */
update_dynamic_varobj_children (var, NULL, NULL, NULL, &children_changed,
- 0, *to);
+ 0, 0, *to);
restrict_range (var->children, from, to);
return var->children;
}
@@ -1770,7 +1777,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
if (!varobj_has_more (v, 0))
{
update_dynamic_varobj_children (v, NULL, NULL, NULL,
- &dummy, 0, 0);
+ &dummy, 0, 0, 0);
if (varobj_has_more (v, 0))
r.changed = 1;
}
@@ -1784,7 +1791,8 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
/* If update_dynamic_varobj_children returns 0, then we have
a non-conforming pretty-printer, so we skip it. */
if (update_dynamic_varobj_children (v, &changed, &new, &unchanged,
- &children_changed, 1, v->to))
+ &children_changed, 1,
+ v->from, v->to))
{
if (children_changed || new)
{