74 lines
2.5 KiB
Diff
74 lines
2.5 KiB
Diff
Typo in Python support breaks info type-printers command
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
|
|
|
|
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
|
|
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
|
|
|
|
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
|
|
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc 2013-01-01 07:41:26.000000000 +0100
|
|
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc 2016-06-27 22:57:58.168642470 +0200
|
|
@@ -31,6 +31,12 @@ templ<basic_string> s;
|
|
|
|
basic_string bs;
|
|
|
|
+class Other
|
|
+{
|
|
+};
|
|
+
|
|
+Other ovar;
|
|
+
|
|
int main()
|
|
{
|
|
return 0;
|
|
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
|
|
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp 2013-01-01 07:41:26.000000000 +0100
|
|
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp 2016-06-27 22:58:13.846785208 +0200
|
|
@@ -51,3 +51,7 @@ gdb_test_no_output "enable type-printer
|
|
gdb_test "whatis bs" "string" "whatis with enabled printer"
|
|
|
|
gdb_test "whatis s" "templ<string>"
|
|
+
|
|
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
|
|
+ "info type-printers for other"
|
|
+gdb_test "whatis ovar" "type = Another"
|
|
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
|
|
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py 2013-01-01 07:41:26.000000000 +0100
|
|
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py 2016-06-27 22:57:58.169642479 +0200
|
|
@@ -15,7 +15,7 @@
|
|
|
|
import gdb
|
|
|
|
-class Recognizer(object):
|
|
+class StringRecognizer(object):
|
|
def __init__(self):
|
|
self.enabled = True
|
|
|
|
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
|
|
self.enabled = True
|
|
|
|
def instantiate(self):
|
|
- return Recognizer()
|
|
+ return StringRecognizer()
|
|
|
|
gdb.type_printers.append(StringTypePrinter())
|
|
+
|
|
+class OtherRecognizer(object):
|
|
+ def __init__(self):
|
|
+ self.enabled = True
|
|
+
|
|
+ def recognize(self, type_obj):
|
|
+ if type_obj.tag == 'Other':
|
|
+ return 'Another'
|
|
+ return None
|
|
+
|
|
+class OtherTypePrinter(object):
|
|
+ def __init__(self):
|
|
+ self.name = 'other'
|
|
+ self.enabled = True
|
|
+
|
|
+ def instantiate(self):
|
|
+ return OtherRecognizer()
|
|
+
|
|
+import gdb.types
|
|
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())
|