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

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