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

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