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

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