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

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