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

689258
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
689258
From: Fedora GDB patches <invalid@email.com>
689258
Date: Fri, 27 Oct 2017 21:07:50 +0200
689258
Subject: gdb-rhbz1350436-type-printers-error.patch
689258
689258
;; Test 'info type-printers' Python error (RH BZ 1350436).
689258
;;=fedoratest
689258
689258
Typo in Python support breaks info type-printers command
689258
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
689258
689258
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
689258
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
689258
689258
diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc
689258
--- a/gdb/testsuite/gdb.python/py-typeprint.cc
689258
+++ b/gdb/testsuite/gdb.python/py-typeprint.cc
689258
@@ -31,6 +31,12 @@ templ<basic_string> s;
689258
 
689258
 basic_string bs;
689258
 
689258
+class Other
689258
+{
689258
+};
689258
+
689258
+Other ovar;
689258
+
689258
 int main()
689258
 {
689258
   return 0;
689258
diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp
689258
--- a/gdb/testsuite/gdb.python/py-typeprint.exp
689258
+++ b/gdb/testsuite/gdb.python/py-typeprint.exp
689258
@@ -50,3 +50,7 @@ gdb_test_no_output "enable type-printer string"
689258
 gdb_test "whatis bs" "string" "whatis with enabled printer"
689258
 
689258
 gdb_test "whatis s" "templ<string>"
689258
+
689258
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
689258
+	 "info type-printers for other"
689258
+gdb_test "whatis ovar" "type = Another"
689258
diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py
689258
--- a/gdb/testsuite/gdb.python/py-typeprint.py
689258
+++ b/gdb/testsuite/gdb.python/py-typeprint.py
689258
@@ -15,7 +15,7 @@
689258
 
689258
 import gdb
689258
 
689258
-class Recognizer(object):
689258
+class StringRecognizer(object):
689258
     def __init__(self):
689258
         self.enabled = True
689258
 
689258
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
689258
         self.enabled = True
689258
 
689258
     def instantiate(self):
689258
-        return Recognizer()
689258
+        return StringRecognizer()
689258
 
689258
 gdb.type_printers.append(StringTypePrinter())
689258
+
689258
+class OtherRecognizer(object):
689258
+    def __init__(self):
689258
+        self.enabled = True
689258
+
689258
+    def recognize(self, type_obj):
689258
+        if type_obj.tag == 'Other':
689258
+            return 'Another'
689258
+        return None
689258
+
689258
+class OtherTypePrinter(object):
689258
+    def __init__(self):
689258
+        self.name = 'other'
689258
+        self.enabled = True
689258
+
689258
+    def instantiate(self):
689258
+        return OtherRecognizer()
689258
+
689258
+import gdb.types
689258
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())