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

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