diff options
author | Thiago Jung Bauermann <bauerman@br.ibm.com> | 2009-02-05 21:16:09 +0000 |
---|---|---|
committer | Thiago Jung Bauermann <bauerman@br.ibm.com> | 2009-02-05 21:16:09 +0000 |
commit | b6cb8e7dead0c48df80c28f95ee7543799672d11 (patch) | |
tree | d6a9f0104500adf91e8ba8f95d7e9e35444ab026 /gdb/python/python-utils.c | |
parent | 54ba13f733396d107167bf89afd43db66bebe779 (diff) | |
download | gdb-b6cb8e7dead0c48df80c28f95ee7543799672d11.zip gdb-b6cb8e7dead0c48df80c28f95ee7543799672d11.tar.gz gdb-b6cb8e7dead0c48df80c28f95ee7543799672d11.tar.bz2 |
gdb/
2009-02-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
Tom Tromey <tromey@redhat.com>
* python/python-utils.c (target_string_to_unicode): New function.
* python/python-internal.h (target_string_to_unicode): New prototype.
* python/python-value.c (valpy_string): New function.
(value_object_methods): Add `string' entry.
gdb/doc/
2009-02-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Values From Inferior): Document Value.string.
Diffstat (limited to 'gdb/python/python-utils.c')
-rw-r--r-- | gdb/python/python-utils.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c index 6a95939..b0ec7b3 100644 --- a/gdb/python/python-utils.c +++ b/gdb/python/python-utils.c @@ -160,6 +160,19 @@ python_string_to_host_string (PyObject *obj) return unicode_to_encoded_string (str, host_charset ()); } +/* Converts a target string of LENGTH bytes in the target's charset to a + Python Unicode string. If LENGTH is -1, convert until a null byte is found. + + Returns NULL on error, with a python exception set. */ +PyObject * +target_string_to_unicode (const gdb_byte *str, int length) +{ + if (length == -1) + length = strlen (str); + + return PyUnicode_Decode (str, length, target_charset (), NULL); +} + /* Return true if OBJ is a Python string or unicode object, false otherwise. */ |