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

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