In fact, there's yet another case:
class StdStringPrinter:
"Print a std::basic_string of some kind"
def __init__(self, encoding, val):
self.encoding = encoding
self.val = val
def to_string(self):
# Look up the target encoding as late as possible.
encoding = self.encoding
if encoding == 0:
encoding = gdb.parameter('target-charset')
elif encoding == 1:
encoding = gdb.parameter('target-wide-charset')
elif isinstance(encoding, WideEncoding):
encoding = encoding.value
return self.val['_M_dataplus']['_M_p'].string(encoding)
I am not quite sure where the 'string' method is defined, so the
question is -- assuming I know the expected size of the string.
How do I make the 'string' method not to fetch more than that?