This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] matrix prettyprinting


This is a small patch to libstdc++-v3/python/libstdcxx/v6/printers.py that goes with a matrix prettyprinter in gdb.

Chris Moller
Index: libstdc++-v3/python/libstdcxx/v6/printers.py
===================================================================
--- libstdc++-v3/python/libstdcxx/v6/printers.py	(revision 159937)
+++ libstdc++-v3/python/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.
Index: libstdc++-v3/ChangeLog
===================================================================
--- libstdc++-v3/ChangeLog	(revision 159937)
+++ libstdc++-v3/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2010-06-01  Chris Moller  <cmoller@redhat.com>
+
+	* python/libstdcxx/v6/printers.py (StdVectorPrinter): Add
+	detection for matrices as nested vectors.
+
 2010-05-27  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR libstdc++/40497

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]