Jan Kratochvil 278e869
http://sourceware.org/ml/gdb-patches/2011-01/msg00016.html
Jan Kratochvil 278e869
Subject: [patch] New testcase: py-prettyprint.exp: print hint_error
Jan Kratochvil 278e869
Jan Kratochvil 278e869
Hi,
Jan Kratochvil 278e869
Jan Kratochvil 278e869
PASS: gdb.python/py-prettyprint.exp: print hint_error
Jan Kratochvil 278e869
for
Jan Kratochvil 278e869
	FYI: fix buglet in gdbpy_get_display_hint
Jan Kratochvil 278e869
	http://sourceware.org/ml/gdb-patches/2010-07/msg00190.html
Jan Kratochvil 278e869
	http://sourceware.org/ml/gdb-cvs/2010-07/msg00061.html
Jan Kratochvil 278e869
Jan Kratochvil 278e869
I would check it in as obvious but the 2011 ChangeLog move process has to be
Jan Kratochvil 278e869
done first.  So to be checked in later.
Jan Kratochvil 278e869
Jan Kratochvil 278e869
Jan Kratochvil 278e869
Thanks,
Jan Kratochvil 278e869
Jan
Jan Kratochvil 278e869
Jan Kratochvil 278e869
Jan Kratochvil 278e869
gdb/testsuite/
Jan Kratochvil 278e869
2011-01-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 278e869
Jan Kratochvil 278e869
	* gdb.python/py-prettyprint.c (struct hint_error): New.
Jan Kratochvil 278e869
	(main): New variable hint_error.
Jan Kratochvil 278e869
	* gdb.python/py-prettyprint.exp (run_lang_tests): New testcase
Jan Kratochvil 278e869
	"print hint_error".
Jan Kratochvil 278e869
	* gdb.python/py-prettyprint.py (class pp_hint_error): New.
Jan Kratochvil 278e869
	(register_pretty_printers): Register it.
Jan Kratochvil 278e869
Jan Kratochvil 33ff709
Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.c
Jan Kratochvil 33ff709
===================================================================
Jan Kratochvil 33ff709
--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.c	2011-01-01 16:33:49.000000000 +0100
Jan Kratochvil 33ff709
+++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.c	2011-01-07 09:11:18.000000000 +0100
Jan Kratochvil 278e869
@@ -44,6 +44,10 @@ struct lazystring {
Jan Kratochvil 278e869
   const char *lazy_str;
Jan Kratochvil 278e869
 };
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
+struct hint_error {
Jan Kratochvil 278e869
+  int x;
Jan Kratochvil 278e869
+};
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
 #ifdef __cplusplus
Jan Kratochvil 278e869
 struct S : public s {
Jan Kratochvil 278e869
   int zs;
Jan Kratochvil 278e869
@@ -215,6 +219,7 @@ main ()
Jan Kratochvil 278e869
   nostring_type nstype;
Jan Kratochvil 278e869
   struct ns ns, ns2;
Jan Kratochvil 278e869
   struct lazystring estring, estring2;
Jan Kratochvil 278e869
+  struct hint_error hint_error;
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
   nstype.elements = narray;
Jan Kratochvil 278e869
   nstype.len = 0;
Jan Kratochvil 33ff709
Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.exp
Jan Kratochvil 33ff709
===================================================================
Jan Kratochvil 33ff709
--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.exp	2011-01-07 09:03:38.000000000 +0100
Jan Kratochvil 33ff709
+++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.exp	2011-01-07 09:11:32.000000000 +0100
Jan Kratochvil 278e869
@@ -97,6 +97,8 @@ proc run_lang_tests {lang} {
Jan Kratochvil 278e869
     gdb_test_no_output "python pp_ls_encoding = 'UTF-8'"
Jan Kratochvil 278e869
     gdb_test "print estring2" "\"embedded \", <incomplete sequence \\\\302>"
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
+    gdb_test "print hint_error" "Exception: hint failed\r\nhint_error_val"
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
     gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
Jan Kratochvil 278e869
 
Jan Kratochvil 33ff709
     gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*"
Jan Kratochvil 33ff709
Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.py
Jan Kratochvil 33ff709
===================================================================
Jan Kratochvil 33ff709
--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.py	2011-01-01 16:33:49.000000000 +0100
Jan Kratochvil 33ff709
+++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.py	2011-01-07 09:11:18.000000000 +0100
Jan Kratochvil 278e869
@@ -156,6 +156,18 @@ class pp_ls:
Jan Kratochvil 278e869
     def display_hint (self):
Jan Kratochvil 278e869
         return 'string'
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
+class pp_hint_error:
Jan Kratochvil 278e869
+    "Throw error from display_hint"
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
+    def __init__(self, val):
Jan Kratochvil 278e869
+        self.val = val
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
+    def to_string(self):
Jan Kratochvil 278e869
+        return 'hint_error_val'
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
+    def display_hint (self):
Jan Kratochvil 278e869
+        raise Exception("hint failed")
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
 class pp_outer:
Jan Kratochvil 278e869
     "Print struct outer"
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
@@ -241,6 +253,9 @@ def register_pretty_printers ():
Jan Kratochvil 278e869
     pretty_printers_dict[re.compile ('^struct outerstruct$')]  = pp_outer
Jan Kratochvil 278e869
     pretty_printers_dict[re.compile ('^outerstruct$')]  = pp_outer
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
+    pretty_printers_dict[re.compile ('^struct hint_error$')]  = pp_hint_error
Jan Kratochvil 278e869
+    pretty_printers_dict[re.compile ('^hint_error$')]  = pp_hint_error
Jan Kratochvil 278e869
+
Jan Kratochvil 278e869
 pretty_printers_dict = {}
Jan Kratochvil 278e869
 
Jan Kratochvil 278e869
 register_pretty_printers ()