#!/usr/bin/python3 import gdb from gdb.printing import register_pretty_printer from gdb.printing import RegexpCollectionPrettyPrinter class CHAR16_PrettyPrinter(object): def __init__(self, val): self.val = val def to_string(self): if int(self.val) < 0x20: return f"L'\\x{int(self.val):02x}'" else: return f"L'{chr(self.val):s}'" def build_pretty_printer(): pp = RegexpCollectionPrettyPrinter("EFI") pp.add_printer('CHAR16', '^CHAR16$', CHAR16_PrettyPrinter) return pp register_pretty_printer(None, build_pretty_printer(), replace=True)