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/18/2009 09:21 PM, Tom Tromey wrote:

Hi Tom

This needs an 'else' case to call gdbpy_print_stack.

Also, why the '+ 1' in the computation of 'len'?
Won't this make LA_PRINT_STRING print one too many bytes?


Phil> + if (replacement == NULL&& py_str == NULL)

'replacement' cannot be NULL here.
You want '*replacement'.

Phil> + thevalue = xmemdup (s, len, len);

Here you do want to copy size+1 bytes, but...

Phil> + LA_PRINT_STRING (stb, thevalue, len, 1, 0,&opts);

... here I think you wan to just print size bytes.

I've implemented requested changes. What do you think?



2009-06-23 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 (pretty_print_one_value): Likewise.
(print_string_repr): Refactor to logic to account for PyObject
returned strings.
(apply_varobj_pretty_printer): Likewise.
* varobj.c (value_get_print_value): Refactor logic to account for
PyObject returned strings.

Testsuite ChangeLog:

2009-06-23 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: pystring_review.patch
Description: Text document

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