]> git.rmz.io Git - dotfiles.git/commitdiff
gdb: add printer for geo_point type
authorSamir Benmendil <me@rmz.io>
Fri, 11 Mar 2022 08:10:50 +0000 (08:10 +0000)
committerSamir Benmendil <me@rmz.io>
Fri, 11 Mar 2022 08:10:50 +0000 (08:10 +0000)
This is mainly as an example for printers for other types.

gdb/fpp.py [new file with mode: 0644]
gdbinit

diff --git a/gdb/fpp.py b/gdb/fpp.py
new file mode 100644 (file)
index 0000000..0c72822
--- /dev/null
@@ -0,0 +1,18 @@
+import gdb
+import gdb.printing
+import re
+
+class GeoPointPrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return self.val['d_']['d_']['_M_elems']
+
+    def display_hint(self):
+        return 'array'
+
+def build_pretty_printer():
+    pp = gdb.printing.RegexpCollectionPrettyPrinter("fpp")
+    pp.add_printer('geo_point', '^base::geo_point<.*>$', GeoPointPrinter)
+    return pp
diff --git a/gdbinit b/gdbinit
index 58b24120ec46f2f791c231a598a75dd387375c2a..17928325972e63621807fb6acd5be8f31fb34464 100644 (file)
--- a/gdbinit
+++ b/gdbinit
@@ -11,6 +11,13 @@ import sys
 sys.path.insert(0, xdg_config + '/gdb')
 from qt import register_qt_printers
 register_qt_printers (None)
+
+import gdb.printing
+import fpp
+gdb.printing.register_pretty_printer(
+    gdb.current_objfile(),
+    fpp.build_pretty_printer())
+
 end
 
 set print pretty on