Blame SOURCES/gdb-rhbz1350436-type-printers-error.patch

7a6771
Typo in Python support breaks info type-printers command
7a6771
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
7a6771
7a6771
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
7a6771
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
7a6771
7a6771
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc
7a6771
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc	2013-01-01 07:41:26.000000000 +0100
7a6771
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc	2016-06-27 22:57:58.168642470 +0200
7a6771
@@ -31,6 +31,12 @@ templ<basic_string> s;
7a6771
 
7a6771
 basic_string bs;
7a6771
 
7a6771
+class Other
7a6771
+{
7a6771
+};
7a6771
+
7a6771
+Other ovar;
7a6771
+
7a6771
 int main()
7a6771
 {
7a6771
   return 0;
7a6771
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp
7a6771
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp	2013-01-01 07:41:26.000000000 +0100
7a6771
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp	2016-06-27 22:58:13.846785208 +0200
7a6771
@@ -51,3 +51,7 @@ gdb_test_no_output "enable type-printer
7a6771
 gdb_test "whatis bs" "string" "whatis with enabled printer"
7a6771
 
7a6771
 gdb_test "whatis s" "templ<string>"
7a6771
+
7a6771
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
7a6771
+	 "info type-printers for other"
7a6771
+gdb_test "whatis ovar" "type = Another"
7a6771
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py
7a6771
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py	2013-01-01 07:41:26.000000000 +0100
7a6771
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py	2016-06-27 22:57:58.169642479 +0200
7a6771
@@ -15,7 +15,7 @@
7a6771
 
7a6771
 import gdb
7a6771
 
7a6771
-class Recognizer(object):
7a6771
+class StringRecognizer(object):
7a6771
     def __init__(self):
7a6771
         self.enabled = True
7a6771
 
7a6771
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
7a6771
         self.enabled = True
7a6771
 
7a6771
     def instantiate(self):
7a6771
-        return Recognizer()
7a6771
+        return StringRecognizer()
7a6771
 
7a6771
 gdb.type_printers.append(StringTypePrinter())
7a6771
+
7a6771
+class OtherRecognizer(object):
7a6771
+    def __init__(self):
7a6771
+        self.enabled = True
7a6771
+
7a6771
+    def recognize(self, type_obj):
7a6771
+        if type_obj.tag == 'Other':
7a6771
+            return 'Another'
7a6771
+        return None
7a6771
+
7a6771
+class OtherTypePrinter(object):
7a6771
+    def __init__(self):
7a6771
+        self.name = 'other'
7a6771
+        self.enabled = True
7a6771
+
7a6771
+    def instantiate(self):
7a6771
+        return OtherRecognizer()
7a6771
+
7a6771
+import gdb.types
7a6771
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())