aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-08-06 18:44:45 +0000
committerTom Tromey <tromey@redhat.com>2012-08-06 18:44:45 +0000
commit2c12abee48e5615dd8573bbafd1b8a167967147d (patch)
treebbe7be1714a31fc407cca93a305631fcd3aec785 /gdb/testsuite/gdb.python
parent4979d7f0a6644db8a512fdf29a6a9df8d258969c (diff)
downloadgdb-2c12abee48e5615dd8573bbafd1b8a167967147d.zip
gdb-2c12abee48e5615dd8573bbafd1b8a167967147d.tar.gz
gdb-2c12abee48e5615dd8573bbafd1b8a167967147d.tar.bz2
PR python/14386:
* 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.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-mi.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.c5
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.py15
3 files changed, 24 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index a792e44..e7034a1 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -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" \
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index 1ff9e05..b1a12b1 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -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;
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index b02b90f..6e960e6 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -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