On 06/16/2009 07:07 PM, Tom Tromey wrote: > Phil> I decided to take a crack at the mechanics of this change this > Phil> morning. This produces the following hunks (in rough). I can see how > Phil> just borrowing the underlying data from the PyObject avoids an > Phil> allocation (the results of PyString_AsString must not be deallocated, > Phil> etc). Is this what you had in mind? > This patch scraps the first value-only approach and as discussed completely implements the string in PyObject approach. Now strings are kept in a PyObject (along with their associated length data) until they are printed, or used in some other way. What do you think? Regards Phil 2009-06-18 Phil Muldoon * python/lib/gdb/libstdcxx/v6/printers.py (StdStringPrinter.to_string): Extract length from header. Use in string extraction. * python/python-internal.h (apply_varobj_pretty_printer): Update definition. (python_string_to_target_python_string): Add definition. * python/python-utils.c (unicode_to_encoded_python_string) (unicode_to_target_python_string) (python_string_to_target_python_string): New Functions. * python/python.c : (print_string_repr): Refactor to logic to account for PyObject returned strings. (pretty_print_one_value): Likewise (apply_varobj_pretty_printer): Likewise. * varobj.c (value_get_print_value): Refactor logic to account for PyObject returned strings. Testsuite ChangeLog: 2009-06-18 Phil Muldoon * gdb.python/python-prettyprint.c: Add counted null string structure. * gdb.python/python-prettyprint.exp: Print null string. Test for embedded nulls. * gdb.python/python-prettyprint.py (pp_ns): New Function.