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

2c2fa1
Typo in Python support breaks info type-printers command
2c2fa1
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
2c2fa1
2c2fa1
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
2c2fa1
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
2c2fa1
2c2fa1
--- gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py-orig	2015-01-15 11:58:12.000000000 +0100
2c2fa1
+++ gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py	2015-06-26 15:33:43.972460415 +0200
2c2fa1
@@ -47,7 +47,7 @@ class InfoTypePrinter(gdb.Command):
2c2fa1
         sep = ''
2c2fa1
         for objfile in gdb.objfiles():
2c2fa1
             if objfile.type_printers:
2c2fa1
-                print ("%sType printers for %s:" % (sep, objfile.name))
2c2fa1
+                print ("%sType printers for %s:" % (sep, objfile.filename))
2c2fa1
                 self.list_type_printers(objfile.type_printers)
2c2fa1
                 sep = '\n'
2c2fa1
         if gdb.current_progspace().type_printers:
2c2fa1
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
2c2fa1
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc	2013-01-01 07:41:26.000000000 +0100
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc	2016-06-27 22:57:58.168642470 +0200
2c2fa1
@@ -31,6 +31,12 @@ templ<basic_string> s;
2c2fa1
 
2c2fa1
 basic_string bs;
2c2fa1
 
2c2fa1
+class Other
2c2fa1
+{
2c2fa1
+};
2c2fa1
+
2c2fa1
+Other ovar;
2c2fa1
+
2c2fa1
 int main()
2c2fa1
 {
2c2fa1
   return 0;
2c2fa1
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
2c2fa1
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp	2013-01-01 07:41:26.000000000 +0100
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp	2016-06-27 22:58:13.846785208 +0200
2c2fa1
@@ -50,4 +50,8 @@ gdb_test "whatis bs" "string" "whatis wi
2c2fa1
 
2c2fa1
 gdb_test "whatis s" "templ<string>"
2c2fa1
 
2c2fa1
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
2c2fa1
+	 "info type-printers for other"
2c2fa1
+gdb_test "whatis ovar" "type = Another"
2c2fa1
+
2c2fa1
 remote_file host delete ${remote_python_file}
2c2fa1
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
2c2fa1
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py	2013-01-01 07:41:26.000000000 +0100
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py	2016-06-27 22:57:58.169642479 +0200
2c2fa1
@@ -15,7 +15,7 @@
2c2fa1
 
2c2fa1
 import gdb
2c2fa1
 
2c2fa1
-class Recognizer(object):
2c2fa1
+class StringRecognizer(object):
2c2fa1
     def __init__(self):
2c2fa1
         self.enabled = True
2c2fa1
 
2c2fa1
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
2c2fa1
         self.enabled = True
2c2fa1
 
2c2fa1
     def instantiate(self):
2c2fa1
-        return Recognizer()
2c2fa1
+        return StringRecognizer()
2c2fa1
 
2c2fa1
 gdb.type_printers.append(StringTypePrinter())
2c2fa1
+
2c2fa1
+class OtherRecognizer(object):
2c2fa1
+    def __init__(self):
2c2fa1
+        self.enabled = True
2c2fa1
+
2c2fa1
+    def recognize(self, type_obj):
2c2fa1
+        if type_obj.tag == 'Other':
2c2fa1
+            return 'Another'
2c2fa1
+        return None
2c2fa1
+
2c2fa1
+class OtherTypePrinter(object):
2c2fa1
+    def __init__(self):
2c2fa1
+        self.name = 'other'
2c2fa1
+        self.enabled = True
2c2fa1
+
2c2fa1
+    def instantiate(self):
2c2fa1
+        return OtherRecognizer()
2c2fa1
+
2c2fa1
+import gdb.types
2c2fa1
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())