+2009-07-16 Phil Muldoon <pmuldoon@redhat.com>
+ Tom Tromey <tromey@redhat.com>
+
+ * python/libstdcxx/v6/printers.py (StdStringPrinter.to_string):
+ Fetch std::string to the given length.
+
2009-07-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/istream.tcc (basic_istream<>::operator>>(short&),
encoding = gdb.parameter('target-charset')
elif encoding == 1:
encoding = gdb.parameter('target-wide-charset')
- return self.val['_M_dataplus']['_M_p'].string(encoding)
+
+ # Make sure &string works, too.
+ type = self.val.type
+ if type.code == gdb.TYPE_CODE_REF:
+ type = type.target ()
+
+ # Calculate the length of the string so that to_string returns
+ # the string according to length, not according to first null
+ # encountered.
+ ptr = self.val ['_M_dataplus']['_M_p']
+ realtype = type.unqualified ().strip_typedefs ()
+ reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
+ header = ptr.cast(reptype) - 1
+ len = header.dereference ()['_M_length']
+ return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
def display_hint (self):
return 'string'