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

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