aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-12-06 18:59:57 +0000
committerTom Tromey <tromey@redhat.com>2012-12-06 18:59:57 +0000
commit731145cb171b848d564a696e81153166524eb35a (patch)
treeab76e30954e6d4f133e8795e385d0fe84ecfd2b8
parentcd6fa7fd8801453ab5caef588fc772d14cb1ee9a (diff)
downloadgdb-731145cb171b848d564a696e81153166524eb35a.zip
gdb-731145cb171b848d564a696e81153166524eb35a.tar.gz
gdb-731145cb171b848d564a696e81153166524eb35a.tar.bz2
2012-12-06 Jens Elmenthaler <jens.elmenthaler@advantest.com>
PR mi/14741: * mi/mi-cmd-var.c (varobj_update_one): Take value of attribute "dynamic" and "displayhint" from printed child, not the root variable. * gdb.python/py-mi.exp: Correct expected results for attribute "dynamic" returned by -var-update. Add test case for correct handling of "diplayhint" for children of dynamic varobjs. * gdb.python/py-prettyprint.c (set_itme): New function. (bug_14741) New function. (main) Add call to bug_14741(). * gdb.python/py-prettyprint.py (class ArrayPrinter): New class.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/mi/mi-cmd-var.c4
-rw-r--r--gdb/testsuite/ChangeLog11
-rw-r--r--gdb/testsuite/gdb.python/py-mi.exp26
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.c19
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.py30
6 files changed, 92 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1bfbc7d..4f89004 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2012-12-06 Jens Elmenthaler <jens.elmenthaler@advantest.com>
+
+ PR mi/14741:
+ * mi/mi-cmd-var.c (varobj_update_one): Take value of
+ attribute "dynamic" and "displayhint" from printed child,
+ not the root variable.
+
2012-12-06 Joel Brobecker <brobecker@adacore.com>
* aix-thread.c (getthrds): Fix type of 4th parameter.
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index dc47bc1..6416d7d 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -793,14 +793,14 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
ui_out_field_int (uiout, "new_num_children",
varobj_get_num_children (r->varobj));
- display_hint = varobj_get_display_hint (var);
+ display_hint = varobj_get_display_hint (r->varobj);
if (display_hint)
{
ui_out_field_string (uiout, "displayhint", display_hint);
xfree (display_hint);
}
- if (varobj_pretty_printed_p (var))
+ if (varobj_pretty_printed_p (r->varobj))
ui_out_field_int (uiout, "dynamic", 1);
varobj_get_child_range (r->varobj, &from, &to);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ad6874e..f05cd87 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2012-12-06 Jens Elmenthaler <jens.elmenthaler@advantest.com>
+
+ * gdb.python/py-mi.exp: Correct expected results for attribute
+ "dynamic" returned by -var-update.
+ Add test case for correct handling of "diplayhint" for children
+ of dynamic varobjs.
+ * gdb.python/py-prettyprint.c (set_itme): New function.
+ (bug_14741) New function.
+ (main) Add call to bug_14741().
+ * gdb.python/py-prettyprint.py (class ArrayPrinter): New class.
+
2012-12-05 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.base/gnu-debugdata.exp: Also include "D" symbols in
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index e7034a1..49b4def 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -182,7 +182,7 @@ 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 }
+ { name {container.\[0\]} in_scope true type_changed false has_more 0 }
} {
}
@@ -239,7 +239,7 @@ mi_list_varobj_children outer.s {
mi_next "next over outer update"
mi_gdb_test "-var-update outer" \
- ".done,changelist=.{name=\"outer.s.a\",in_scope=\"true\",type_changed=\"false\",dynamic=\"1\",has_more=\"0\"}." \
+ ".done,changelist=.{name=\"outer.s.a\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"}." \
"update after updating element of outer"
mi_continue_to_line \
@@ -293,6 +293,28 @@ mi_gdb_test "-var-evaluate-expression me" \
mi_create_dynamic_varobj children_as_list children_as_list \
"printer whose children are returned as a list"
+# Regression test for bug 14741.
+mi_continue_to_line \
+ [gdb_get_line_number {breakpoint bug 14741} ${srcfile}] \
+ "step to breakpoint for bug 14741"
+
+mi_create_dynamic_varobj c c \
+ "create varobj for c"
+
+mi_gdb_test "-var-set-visualizer c ArrayPrinter" \
+ "\\^done" \
+ "choose array visualizer for c"
+
+mi_list_varobj_children c {
+ { {c.\[0\]} {\[0\]} 0 int }
+} "list children of c"
+
+mi_next "next over change of array element"
+
+mi_gdb_test "-var-update c" \
+ "\\^done,changelist=\\\[{name=\"c.\\\[0\\\]\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"}\\\]" \
+ "update varobj after element change"
+
# C++ MI tests
gdb_exit
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index b1a12b1..14fd528 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -196,6 +196,13 @@ add_item (zzz_type *c, int val)
++c->len;
}
+void
+set_item(zzz_type *c, int i, int val)
+{
+ if (i < c->len)
+ c->elements[i] = val;
+}
+
void init_s(struct s *s, int a)
{
s->a = a;
@@ -239,6 +246,15 @@ eval_sub (void)
eval1.x++; /* eval-break */
}
+static void
+bug_14741()
+{
+ zzz_type c = make_container ("bug_14741");
+ add_item (&c, 71);
+ set_item(&c, 0, 42); /* breakpoint bug 14741 */
+ set_item(&c, 0, 5);
+}
+
int
main ()
{
@@ -332,5 +348,6 @@ main ()
eval_sub ();
- return 0; /* break to inspect struct and union */
+ bug_14741(); /* break to inspect struct and union */
+ return 0;
}
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index 6e960e6..65a7cab 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -54,6 +54,36 @@ class ContainerPrinter:
def children(self):
return self._iterator(self.val['elements'], self.val['len'])
+# Treats a container as array.
+class ArrayPrinter:
+ class _iterator:
+ def __init__ (self, pointer, len):
+ self.start = pointer
+ self.pointer = pointer
+ self.end = pointer + len
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.pointer == self.end:
+ raise StopIteration
+ result = self.pointer
+ self.pointer = self.pointer + 1
+ return ('[%d]' % int (result - self.start), result.dereference())
+
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ return 'array %s with %d elements' % (self.val['name'], self.val['len'])
+
+ def children(self):
+ return self._iterator(self.val['elements'], self.val['len'])
+
+ def display_hint (self):
+ return 'array'
+
# Flag to make NoStringContainerPrinter throw an exception.
exception_flag = False