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

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