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

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