This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Patch: Tweak the libstdc++ std::string pretty-printer to fetch to the string's actual length
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Wed, 15 Jul 2009 14:16:24 +0100
- Subject: Patch: Tweak the libstdc++ std::string pretty-printer to fetch to the string's actual length
Over at GDB we've tweaked the pretty-printers and other Python scripting
code to preserve "embedded nulls" within a string if string has an
actual length assigned to it (i.e. a counted string). To do this we
also added an optional "length" parameter to the value.string ()
function. Now that these two patches are in mainline GDB, it allows the
std::string printer to fetch to the string's actual length, bypassing
and preserving any embedded nulls that happen to be in the string.
In the old code, the pretty-printed output for:
std::string barstr ("bar\0string",10);
would be:
barstr = "bar"
But in the new code it would be:
barstr = "bar\000string"
In the scenario below, the output would always be: "foo"
std::string foostr ("foo\0string");
foostr = "foo"
We need to make a few changes to the Python bits of the std::string
printer to make this work with the new GDB code. What do you think?
Regards
Phil
2009-07-15 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.
Attachment:
printer.py.patch
Description: Text document