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

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