import gdb.printing import re class StdStringPrinter: def __init__ (self, val): self.val = val def to_string (self): return self.val['_M_dataplus']['_M_p'] def display_hint (self): return 'string' def str_lookup_function(val): bbb = {} try: bbb = val.type.fields () except: pass found = 0 for x in bbb: if x.name == '_M_dataplus': found = 1 if found == 1: return StdStringPrinter(val) return None gdb.printing.register_pretty_printer (gdb, str_lookup_function)