public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-python: gdb Date: Fri, 21 Nov 2008 18:25:00 -0000 [thread overview] Message-ID: <20081121182506.19149.qmail@sourceware.org> (raw) The branch, archer-tromey-python has been updated via 0fdf3e3468cebce67721a34c04adf813d7dc48eb (commit) from d622890c0091978356760aafbb8bc7adfec3724e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 0fdf3e3468cebce67721a34c04adf813d7dc48eb Author: Tom Tromey <tromey@redhat.com> Date: Fri Nov 21 11:24:44 2008 -0700 gdb * python/python-value.c (value_object_methods) <string>: Accept varargs. (valpy_string): Accept optional encoding argument. gdb/doc * gdb.texinfo (Values From Inferior): Document Value.string. ----------------------------------------------------------------------- Summary of changes: gdb/ChangeLog | 6 ++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 20 ++++++++++++++++++++ gdb/python/python-value.c | 11 +++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) First 500 lines of diff: diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ca4807f..549ca85 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2008-11-21 Tom Tromey <tromey@redhat.com> + + * python/python-value.c (value_object_methods) <string>: Accept + varargs. + (valpy_string): Accept optional encoding argument. + 2008-11-20 Tom Tromey <tromey@redhat.com> * gdbtypes.c (delete_main_type): Use TYPE_FIELD_LOC_KIND. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index e6b9a7b..4a557f9 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2008-11-21 Tom Tromey <tromey@redhat.com> + + * gdb.texinfo (Values From Inferior): Document Value.string. + 2008-11-18 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Commands In Python): Document prefix commands. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fad65e2..18fe77f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18225,6 +18225,26 @@ The result @code{bar} will be a @code{gdb.Value} object holding the value pointed to by @code{foo}. @end defmethod +@defmethod Value string @r{[}encoding@r{]} +If this @code{gdb.Value} represents a string, then this method +converts the contents to a Python string. Otherwise, this method will +throw an exception. + +Strings are recognized in a language-specific way; whether a given +@code{gdb.Value} represents a string is determined by the current +language. + +For C-like languages, a value is a string if it is a pointer to or an +array of characters or ints. The string is assumed to be terminated +by a zero of the appropriate width. + +If the optional @var{encoding} argument is given, it must be a string +naming the encoding of the string in the @code{gdb.Value}. The Python +codec machinery will be used to convert the string. If @var{encoding} +is not given, then the @code{target-charset} (@pxref{Character Sets}) +will be used. +@end defmethod + @defmethod Value type Return the type of this @code{gdb.Value}. The result is a @code{gdb.Type} object. diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index 0712408..e8196ed 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -164,6 +164,13 @@ valpy_string (PyObject *self, PyObject *args) struct value *value = ((value_object *) self)->value; volatile struct gdb_exception except; PyObject *unicode; + const char *encoding = NULL; + + if (!PyArg_ParseTuple (args, "|s", &encoding)) + return NULL; + + if (!encoding) + encoding = target_charset (); TRY_CATCH (except, RETURN_MASK_ALL) { @@ -181,7 +188,7 @@ valpy_string (PyObject *self, PyObject *args) return NULL; } - unicode = target_string_to_unicode (buffer, length); + unicode = PyUnicode_Decode (buffer, length, encoding, NULL); xfree (buffer); return unicode; @@ -905,7 +912,7 @@ static PyMethodDef value_object_methods[] = { { "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." }, { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." }, { "type", valpy_type, METH_NOARGS, "Return type of the value." }, - { "string", valpy_string, METH_NOARGS, + { "string", valpy_string, METH_VARARGS, "Return Unicode string representation of the value." }, {NULL} /* Sentinel */ }; hooks/post-receive -- Repository for Project Archer.
next reply other threads:[~2008-11-21 18:25 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-11-21 18:25 tromey [this message] -- strict thread matches above, loose matches on Subject: below -- 2009-04-07 20:28 tromey 2009-03-24 17:27 tromey 2009-02-05 19:56 tromey 2008-12-17 23:10 tromey 2008-12-15 22:38 tromey 2008-12-13 0:37 tromey 2008-12-12 23:54 tromey 2008-12-10 15:28 tromey 2008-12-09 0:33 tromey 2008-12-02 21:29 tromey 2008-12-01 19:10 tromey 2008-11-25 21:17 tromey 2008-11-18 18:52 tromey 2008-11-18 15:54 tromey 2008-11-17 15:45 tromey 2008-11-16 22:18 tromey 2008-11-16 16:56 tromey 2008-11-12 1:54 tromey 2008-11-10 14:15 tromey 2008-11-06 21:11 tromey 2008-11-06 19:58 tromey 2008-10-23 22:27 tromey 2008-10-23 21:28 tromey 2008-10-22 18:18 tromey 2008-10-21 18:32 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20081121182506.19149.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=archer-commits@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).