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

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