Index: tools/gdb/gdb_chrome.py |
diff --git a/tools/gdb/gdb_chrome.py b/tools/gdb/gdb_chrome.py |
index 4f6976c2fd3c4c84951260c48fb1395ea036bb81..f3073e382239431b8172edc1696e366aeddf9c34 100644 |
--- a/tools/gdb/gdb_chrome.py |
+++ b/tools/gdb/gdb_chrome.py |
@@ -14,6 +14,12 @@ Add this to your gdb by amending your ~/.gdbinit as follows: |
Use |
(gdb) p /r any_variable |
to print |any_variable| without using any printers. |
+ |
+To interactively type Python for development of the printers: |
+ (gdb) python foo = gdb.parse_and_eval('bar') |
+to put the C++ value 'bar' in the current scope into a Python variable 'foo'. |
+Then you can interact with that variable: |
+ (gdb) python print foo['impl_'] |
""" |
import datetime |
@@ -240,6 +246,20 @@ class ManualConstructorPrinter(object): |
pp_set.add_printer('base::ManualConstructor', '^base::ManualConstructor<.*>$', ManualConstructorPrinter) |
+class FlatMapPrinter(object): |
+ def __init__(self, val): |
+ self.val = val |
+ |
+ def to_string(self): |
+ # It would be nice to match the output of std::map which is a little |
+ # nicer than printing the vector of pairs. But iterating over it in |
+ # Python is much more complicated and this output is reasonable. |
+ # (Without this printer, a flat_map will output 7 lines of internal |
+ # template goop before the vector contents.) |
+ return 'base::flat_map with ' + str(self.val['impl_']['body_']) |
+pp_set.add_printer('base::flat_map', '^base::flat_map<.*>$', FlatMapPrinter) |
+ |
+ |
class ValuePrinter(object): |
def __init__(self, val): |
self.val = val |