blarsen / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
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
f524ac5
FileName: gdb-rhbz1350436-type-printers-error.patch
f524ac5
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
Jan Kratochvil 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
Jan Kratochvil fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc	2013-01-01 07:41:26.000000000 +0100
Jan Kratochvil fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc	2016-06-27 22:57:58.168642470 +0200
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;
Jan Kratochvil 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
Jan Kratochvil fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp	2013-01-01 07:41:26.000000000 +0100
Jan Kratochvil fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp	2016-06-27 22:58:13.846785208 +0200
Jan Kratochvil fb74e3a
@@ -51,3 +51,7 @@ gdb_test_no_output "enable type-printer
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"
Jan Kratochvil 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
Jan Kratochvil fb74e3a
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py	2013-01-01 07:41:26.000000000 +0100
Jan Kratochvil fb74e3a
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py	2016-06-27 22:57:58.169642479 +0200
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())