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