This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[patch] Support counted strings and embedded nulls in value.string


This patch adds two related elements to the pretty-printer python support. This patch already exists in the archer-tromey-python branch of the archer repository, and here is my submission for the FSF repository.

The first element of the patch adds counted string support to the value.string method by an optional length parameter; the second element preserves the length of the string and respects embedded nulls in the case where a string is regarded as "counted". This allows the preservation of embedded nulls in python value strings as long as a length is specified. If an explicit length is not provided, it reverts to the old behaviour of regarding the first null as a sting terminator.

Originally this patch was written as two separate patches:

The counted string support is discussed here in the archer archives:

http://sourceware.org/ml/archer/2009-q2/msg00017.html

And the preservation and embedded nulls in the counted string scenario is here:

http://sourceware.org/ml/archer/2009-q2/msg00111.html

Regards

Phil

ChangeLog

2009-06-30 Phil Muldoon <pmuldoon@redhat.com>

    * 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-prettyprint.c (pretty_print_one_value): Likewise.
    (print_string_repr): Refactor to logic to account for PyObject
    returned strings.
    (apply_varobj_pretty_printer): Likewise.
    * python/python-value.c (valpy_string): Parse length keyword. Use
    length keyword in LA_GET_STRING.
    * varobj.c (value_get_print_value): Refactor logic to account for
    PyObject returned strings.
    * c-lang.c (c_get_string): If the length parameter is specified,
    use that. Return value in characters. Update comments.
       * language.h: Update c_get_string prototype comments.

Testsuite ChangeLog:

2009-06-30 Phil Muldoon <pmuldoon@redhat.com>

    * 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.
    * gdb.python/python-value.exp (test_value_in_inferior): Add
    variable length string fetch tests.
    * gdb.python/python-value.c (main): Add strings for string fetch tests.

Documentation ChangeLog

2009-06-30 Phil Muldoon <pmuldoon@redhat.com>

    * gdb.texinfo (Values From Inferior): Add length parameter
    description.


Attachment: gdb_upstream_counted_and_null_string.patch
Description: Text document


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