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

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