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

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