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

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