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

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