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

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