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

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