This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python][patch] Preserve string length, and embedded-nulls inpretty-print string emission.

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?



2009-06-18 Phil Muldoon <>

* python/lib/gdb/libstdcxx/v6/
(StdStringPrinter.to_string): Extract length from header. Use in
string extraction.
* python/python-internal.h (apply_varobj_pretty_printer): Update
(python_string_to_target_python_string): Add definition.
* python/python-utils.c (unicode_to_encoded_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
* gdb.python/python-prettyprint.exp: Print null string. Test for
embedded nulls.
* gdb.python/ (pp_ns): New

Attachment: strings_as_pyobjects.patch
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]