gdb-best-friend/examples/python/pretty-print2/str.py
Sergio Durigan Junior dd97dffcfb Adding slides in en_US
This commit adds the slides in en_US, and also the examples.
2014-10-16 18:47:50 -04:00

29 lines
494 B
Python

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)