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