gdb/gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch
2010-07-11 18:06:33 +00:00

44 lines
1.6 KiB
Diff

2010-06-01 Chris Moller <cmoller@redhat.com>
* python/libstdcxx/v6/printers.py (StdVectorPrinter): Add
detection for matrices as nested vectors.
Index: libstdc++-v3/python/libstdcxx/v6/printers.py
===================================================================
--- ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (revision 159937)
+++ ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (working copy)
@@ -19,6 +19,9 @@
import itertools
import re
+vector_sig = 'std::vector'
+vector_regex = re.compile('^' + vector_sig + '<.*>$')
+
class StdPointerPrinter:
"Print a smart pointer of some kind"
@@ -186,7 +189,13 @@
% (self.typename, int (finish - start), int (end - start)))
def display_hint(self):
- return 'array'
+ itype0 = self.val.type.template_argument(0)
+ itag = itype0.tag
+ if itag and re.match(vector_regex, itag):
+ rc = 'matrix'
+ else:
+ rc = 'array'
+ return rc
class StdVectorIteratorPrinter:
"Print std::vector::iterator"
@@ -692,7 +701,7 @@
pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
- pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val)
+ pretty_printers_dict[vector_regex] = lambda val: StdVectorPrinter(vector_sig, val)
# vector<bool>
# Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.