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