|
|
0b42f8 |
Typo in Python support breaks info type-printers command
|
|
|
0b42f8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1350436
|
|
|
0b42f8 |
|
|
|
0b42f8 |
[testsuite patch] PR python/17136: 'info type-printers' causes an exception when there are per-objfile printers
|
|
|
0b42f8 |
https://sourceware.org/ml/gdb-patches/2016-06/msg00455.html
|
|
|
0b42f8 |
|
|
|
0b42f8 |
--- gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py-orig 2015-01-15 11:58:12.000000000 +0100
|
|
|
0b42f8 |
+++ gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py 2015-06-26 15:33:43.972460415 +0200
|
|
|
0b42f8 |
@@ -47,7 +47,7 @@ class InfoTypePrinter(gdb.Command):
|
|
|
0b42f8 |
sep = ''
|
|
|
0b42f8 |
for objfile in gdb.objfiles():
|
|
|
0b42f8 |
if objfile.type_printers:
|
|
|
0b42f8 |
- print ("%sType printers for %s:" % (sep, objfile.name))
|
|
|
0b42f8 |
+ print ("%sType printers for %s:" % (sep, objfile.filename))
|
|
|
0b42f8 |
self.list_type_printers(objfile.type_printers)
|
|
|
0b42f8 |
sep = '\n'
|
|
|
0b42f8 |
if gdb.current_progspace().type_printers:
|
|
|
0b42f8 |
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
|
|
|
0b42f8 |
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.cc 2013-01-01 07:41:26.000000000 +0100
|
|
|
0b42f8 |
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.cc 2016-06-27 22:57:58.168642470 +0200
|
|
|
0b42f8 |
@@ -31,6 +31,12 @@ templ<basic_string> s;
|
|
|
0b42f8 |
|
|
|
0b42f8 |
basic_string bs;
|
|
|
0b42f8 |
|
|
|
0b42f8 |
+class Other
|
|
|
0b42f8 |
+{
|
|
|
0b42f8 |
+};
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+Other ovar;
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
int main()
|
|
|
0b42f8 |
{
|
|
|
0b42f8 |
return 0;
|
|
|
0b42f8 |
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
|
|
|
0b42f8 |
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.exp 2013-01-01 07:41:26.000000000 +0100
|
|
|
0b42f8 |
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.exp 2016-06-27 22:58:13.846785208 +0200
|
|
|
0b42f8 |
@@ -50,4 +50,8 @@ gdb_test "whatis bs" "string" "whatis wi
|
|
|
0b42f8 |
|
|
|
0b42f8 |
gdb_test "whatis s" "templ<string>"
|
|
|
0b42f8 |
|
|
|
0b42f8 |
+gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
|
|
|
0b42f8 |
+ "info type-printers for other"
|
|
|
0b42f8 |
+gdb_test "whatis ovar" "type = Another"
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
remote_file host delete ${remote_python_file}
|
|
|
0b42f8 |
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
|
|
|
0b42f8 |
--- gdb-7.6.1/gdb/testsuite/gdb.python-orig/py-typeprint.py 2013-01-01 07:41:26.000000000 +0100
|
|
|
0b42f8 |
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-typeprint.py 2016-06-27 22:57:58.169642479 +0200
|
|
|
0b42f8 |
@@ -15,7 +15,7 @@
|
|
|
0b42f8 |
|
|
|
0b42f8 |
import gdb
|
|
|
0b42f8 |
|
|
|
0b42f8 |
-class Recognizer(object):
|
|
|
0b42f8 |
+class StringRecognizer(object):
|
|
|
0b42f8 |
def __init__(self):
|
|
|
0b42f8 |
self.enabled = True
|
|
|
0b42f8 |
|
|
|
0b42f8 |
@@ -30,6 +30,26 @@ class StringTypePrinter(object):
|
|
|
0b42f8 |
self.enabled = True
|
|
|
0b42f8 |
|
|
|
0b42f8 |
def instantiate(self):
|
|
|
0b42f8 |
- return Recognizer()
|
|
|
0b42f8 |
+ return StringRecognizer()
|
|
|
0b42f8 |
|
|
|
0b42f8 |
gdb.type_printers.append(StringTypePrinter())
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+class OtherRecognizer(object):
|
|
|
0b42f8 |
+ def __init__(self):
|
|
|
0b42f8 |
+ self.enabled = True
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ def recognize(self, type_obj):
|
|
|
0b42f8 |
+ if type_obj.tag == 'Other':
|
|
|
0b42f8 |
+ return 'Another'
|
|
|
0b42f8 |
+ return None
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+class OtherTypePrinter(object):
|
|
|
0b42f8 |
+ def __init__(self):
|
|
|
0b42f8 |
+ self.name = 'other'
|
|
|
0b42f8 |
+ self.enabled = True
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ def instantiate(self):
|
|
|
0b42f8 |
+ return OtherRecognizer()
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+import gdb.types
|
|
|
0b42f8 |
+gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())
|