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
Jan Kratochvil fb74e3a
Typo in Python support breaks info type-printers command
Jan Kratochvil fb74e3a
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
Jan Kratochvil fb74e3a
Jan Kratochvil fb74e3a
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
Jan Kratochvil fb74e3a
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
Jan Kratochvil 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
Jan Kratochvil fb74e3a
@@ -31,6 +31,12 @@ templ<basic_string> s;
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
 basic_string bs;
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
+class Other
Jan Kratochvil fb74e3a
+{
Jan Kratochvil fb74e3a
+};
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+Other ovar;
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
 int main()
Jan Kratochvil fb74e3a
 {
Jan Kratochvil 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"
Jan Kratochvil fb74e3a
 gdb_test "whatis bs" "string" "whatis with enabled printer"
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
 gdb_test "whatis s" "templ<string>"
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
Jan Kratochvil fb74e3a
+	 "info type-printers for other"
Jan Kratochvil 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
Jan Kratochvil fb74e3a
@@ -15,7 +15,7 @@
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
 import gdb
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
-class Recognizer(object):
Jan Kratochvil fb74e3a
+class StringRecognizer(object):
Jan Kratochvil fb74e3a
     def __init__(self):
Jan Kratochvil fb74e3a
         self.enabled = True
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
Jan Kratochvil fb74e3a
         self.enabled = True
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
     def instantiate(self):
Jan Kratochvil fb74e3a
-        return Recognizer()
Jan Kratochvil fb74e3a
+        return StringRecognizer()
Jan Kratochvil fb74e3a
 
Jan Kratochvil fb74e3a
 gdb.type_printers.append(StringTypePrinter())
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+class OtherRecognizer(object):
Jan Kratochvil fb74e3a
+    def __init__(self):
Jan Kratochvil fb74e3a
+        self.enabled = True
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+    def recognize(self, type_obj):
Jan Kratochvil fb74e3a
+        if type_obj.tag == 'Other':
Jan Kratochvil fb74e3a
+            return 'Another'
Jan Kratochvil fb74e3a
+        return None
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+class OtherTypePrinter(object):
Jan Kratochvil fb74e3a
+    def __init__(self):
Jan Kratochvil fb74e3a
+        self.name = 'other'
Jan Kratochvil fb74e3a
+        self.enabled = True
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+    def instantiate(self):
Jan Kratochvil fb74e3a
+        return OtherRecognizer()
Jan Kratochvil fb74e3a
+
Jan Kratochvil fb74e3a
+import gdb.types
Jan Kratochvil fb74e3a
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())