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

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