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

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