PR python/14386:
authorTom Tromey <tromey@redhat.com>
Mon, 6 Aug 2012 18:44:45 +0000 (18:44 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 6 Aug 2012 18:44:45 +0000 (18:44 +0000)
* varobj.c (update_dynamic_varobj_children): Don't call
PyIter_Check.
gdb/testsuite
* gdb.python/py-mi.exp: Add test for printer whose children
are a list.
* gdb.python/py-prettyprint.c (struct children_as_list): New.
(main): New variable children_as_list.
* gdb.python/py-prettyprint.py (class pp_children_as_list):
New.
(register_pretty_printers): Register new printer.

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-mi.exp
gdb/testsuite/gdb.python/py-prettyprint.c
gdb/testsuite/gdb.python/py-prettyprint.py
gdb/varobj.c

index e36f729773c84efe070b71ff88b4e3d73efb6bb7..e2ff0a9b73f9e016417a1214a0b022f4637555e3 100644 (file)
@@ -1,3 +1,9 @@
+2012-08-06  Tom Tromey  <tromey@redhat.com>
+
+       PR python/14386:
+       * varobj.c (update_dynamic_varobj_children): Don't call
+       PyIter_Check.
+
 2012-08-06  Tom Tromey  <tromey@redhat.com>
 
        PR cli/14392:
index debce6521b606f50d4e9b802f104fb29e3d9a81c..3f2e49662b7e7f6c91e73f608a97757e4b010024 100644 (file)
@@ -1,3 +1,13 @@
+2012-08-06  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.python/py-mi.exp: Add test for printer whose children
+       are a list.
+       * gdb.python/py-prettyprint.c (struct children_as_list): New.
+       (main): New variable children_as_list.
+       * gdb.python/py-prettyprint.py (class pp_children_as_list):
+       New.
+       (register_pretty_printers): Register new printer.
+
 2012-08-03  Edjunior Machado  <emachado@linux.vnet.ibm.com>
 
        * gdb.base/valgrind-infcall.exp: Expect leading `.' on ppc64's
index a792e44cd66facb57e03f1c6db1014f1c0644eee..e7034a1517a6d2fd1b57c6cab37dc99698dc3239 100644 (file)
@@ -289,6 +289,10 @@ mi_gdb_test "-var-evaluate-expression me" \
        "\\^done,value=\"<error reading variable: Cannot access memory.>.*\"" \
        "evaluate me varobj"
 
+# Regression test for python/14836.
+mi_create_dynamic_varobj children_as_list children_as_list \
+    "printer whose children are returned as a list"
+
 # C++ MI tests
 gdb_exit
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \
index 1ff9e0511f0c890b4f48d6017eff95d946133d00..b1a12b12fb20712e294aaf9533c799e73fa02909 100644 (file)
@@ -48,6 +48,10 @@ struct hint_error {
   int x;
 };
 
+struct children_as_list {
+  int x;
+};
+
 #ifdef __cplusplus
 struct S : public s {
   int zs;
@@ -252,6 +256,7 @@ main ()
   struct ns ns, ns2;
   struct lazystring estring, estring2;
   struct hint_error hint_error;
+  struct children_as_list children_as_list;
 
   nstype.elements = narray;
   nstype.len = 0;
index b02b90fe112ca625775057ad1b50382188a7ffdb..6e960e6805d543b78112ef7f9a55e4201c2ba426 100644 (file)
@@ -174,6 +174,18 @@ class pp_hint_error:
     def display_hint (self):
         raise Exception("hint failed")
 
+class pp_children_as_list:
+    "Throw error from display_hint"
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return 'children_as_list_val'
+
+    def children (self):
+        return [('one', 1)]
+
 class pp_outer:
     "Print struct outer"
 
@@ -282,6 +294,9 @@ def register_pretty_printers ():
     pretty_printers_dict[re.compile ('^struct hint_error$')]  = pp_hint_error
     pretty_printers_dict[re.compile ('^hint_error$')]  = pp_hint_error
 
+    pretty_printers_dict[re.compile ('^struct children_as_list$')]  = pp_children_as_list
+    pretty_printers_dict[re.compile ('^children_as_list$')]  = pp_children_as_list
+
     pretty_printers_dict[re.compile ('^memory_error$')]  = MemoryErrorString
 
     pretty_printers_dict[re.compile ('^eval_type_s$')] = pp_eval_type
index c345c804ab74ea666e1e2b2d197bb064540f525d..669969961ebcef77ca2145cd57db8865c0710439 100644 (file)
@@ -1114,9 +1114,6 @@ update_dynamic_varobj_children (struct varobj *var,
 
       make_cleanup_py_decref (children);
 
-      if (!PyIter_Check (children))
-       error (_("Returned value is not iterable"));
-
       Py_XDECREF (var->child_iter);
       var->child_iter = PyObject_GetIter (children);
       if (!var->child_iter)