gdb/testsuite/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 11 Apr 2011 17:40:41 +0000 (17:40 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 11 Apr 2011 17:40:41 +0000 (17:40 +0000)
* gdb.python/py-prettyprint.c (struct hint_error): New.
(main): New variable hint_error.
* gdb.python/py-prettyprint.exp (run_lang_tests): New testcase
"print hint_error".
* gdb.python/py-prettyprint.py (class pp_hint_error): New.
(register_pretty_printers): Register it.

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

index 9ae251bdf561a2f3a3153d88cc8949d1d4340b97..7205f18a3882065c2fe6b210927644651c8214bc 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.python/py-prettyprint.c (struct hint_error): New.
+       (main): New variable hint_error.
+       * gdb.python/py-prettyprint.exp (run_lang_tests): New testcase
+       "print hint_error".
+       * gdb.python/py-prettyprint.py (class pp_hint_error): New.
+       (register_pretty_printers): Register it.
+
 2011-04-04  Tom Tromey  <tromey@redhat.com>
 
        * gdb.cp/maint.exp (test_help): Update.
index 5f984338c3c9cc69d46e905e35e53c9d1eda1fe5..1d88b4ef0a944eacd805971a2cfbfcaaa27b3aa2 100644 (file)
@@ -44,6 +44,10 @@ struct lazystring {
   const char *lazy_str;
 };
 
+struct hint_error {
+  int x;
+};
+
 #ifdef __cplusplus
 struct S : public s {
   int zs;
@@ -215,6 +219,7 @@ main ()
   nostring_type nstype, nstype2;
   struct ns ns, ns2;
   struct lazystring estring, estring2;
+  struct hint_error hint_error;
 
   nstype.elements = narray;
   nstype.len = 0;
index c5033c9370ae52e02cee366fe41c0734f531a936..1fd8c6f2ccc6f2791d1ae4d706bc62c530a47ed3 100644 (file)
@@ -97,6 +97,8 @@ proc run_lang_tests {lang} {
     gdb_test_no_output "python pp_ls_encoding = 'UTF-8'"
     gdb_test "print estring2" "\"embedded \", <incomplete sequence \\\\302>"
 
+    gdb_test "print hint_error" "Exception: hint failed\r\nhint_error_val"
+
     gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
 
     gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
index 831a16373d7bb60cb91d09886fb72a5c43ff2b81..92280e0a62fbe29f2d6634064d0240a3d8a591e3 100644 (file)
@@ -161,6 +161,18 @@ class pp_ls:
     def display_hint (self):
         return 'string'
 
+class pp_hint_error:
+    "Throw error from display_hint"
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return 'hint_error_val'
+
+    def display_hint (self):
+        raise Exception("hint failed")
+
 class pp_outer:
     "Print struct outer"
 
@@ -246,6 +258,9 @@ def register_pretty_printers ():
     pretty_printers_dict[re.compile ('^struct outerstruct$')]  = pp_outer
     pretty_printers_dict[re.compile ('^outerstruct$')]  = pp_outer
 
+    pretty_printers_dict[re.compile ('^struct hint_error$')]  = pp_hint_error
+    pretty_printers_dict[re.compile ('^hint_error$')]  = pp_hint_error
+
 pretty_printers_dict = {}
 
 register_pretty_printers ()