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