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
fb74e3a
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc
fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc	2013-01-01 07:41:26.000000000 +0100
fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc	2016-06-27 22:57:58.168642470 +0200
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;
fb74e3a
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp
fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp	2013-01-01 07:41:26.000000000 +0100
fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp	2016-06-27 22:58:13.846785208 +0200
fb74e3a
@@ -51,3 +51,7 @@ gdb_test_no_output "enable type-printer
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"
fb74e3a
diff -dup -rup gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py
fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py	2013-01-01 07:41:26.000000000 +0100
fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py	2016-06-27 22:57:58.169642479 +0200
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())