This is the mail archive of the 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:

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




2009-06-30 Phil Muldoon <>

    * 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-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 <>

    * 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
    * 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 <>

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

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]