Commit: 0eaff41c6ba5f282fa48722e5d9f62af45aa3cfa
Parent: eda8c2fa3f53319c12e8628b0c2d76590f01c137
Author: Randy Palamar
Date: Tue, 26 Mar 2024 07:43:49 -0600
add gdb helper for printing fixed length strings
Diffstat:
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/.config/gdb/gdbinit b/.config/gdb/gdbinit
@@ -0,0 +1,3 @@
+tui new-layout hackerman {-horizontal regs 1 asm 1} 2 src 2 status 0 cmd 1
+
+source ~/.config/gdb/plugins.py
diff --git a/.config/gdb/plugins.py b/.config/gdb/plugins.py
@@ -0,0 +1,22 @@
+import gdb.printing
+
+
+class s8_printer(gdb.ValuePrinter):
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ len = self.val["len"]
+ str = self.val["data"].string(length=len)
+ return '{data = "%s", len = %s}' % (str, len)
+
+
+def build_pretty_printer():
+ pp = gdb.printing.RegexpCollectionPrettyPrinter("rnpnr")
+ pp.add_printer("s8", "s8", s8_printer)
+ return pp
+
+
+gdb.printing.register_pretty_printer(
+ gdb.current_objfile(), build_pretty_printer()
+)