From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16696 invoked by alias); 1 Dec 2008 19:10:50 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 16638 invoked by uid 306); 1 Dec 2008 19:10:50 -0000 Date: Mon, 01 Dec 2008 19:10:00 -0000 Message-ID: <20081201191050.16622.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-python: gdb X-Git-Refname: refs/heads/archer-tromey-python X-Git-Reftype: branch X-Git-Oldrev: 57ef2e848acae84dcb8497a7a126210bc4de74ff X-Git-Newrev: a3c509dff50be9deb8f84f30123cd0458120874a X-SW-Source: 2008-q4/txt/msg00168.txt.bz2 List-Id: The branch, archer-tromey-python has been updated via a3c509dff50be9deb8f84f30123cd0458120874a (commit) from 57ef2e848acae84dcb8497a7a126210bc4de74ff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit a3c509dff50be9deb8f84f30123cd0458120874a Author: Tom Tromey Date: Mon Dec 1 12:09:55 2008 -0700 gdb * python/python.c (GdbMethods) : New. (gdbpy_parse_and_eval): New function. gdb/doc * gdb.texinfo (Basic Python): Document parse_and_eval. ----------------------------------------------------------------------- Summary of changes: gdb/ChangeLog | 5 +++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 7 +++++++ gdb/python/python.c | 23 +++++++++++++++++++++++ 4 files changed, 39 insertions(+), 0 deletions(-) First 500 lines of diff: diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 97a4223..9d51f22 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2008-12-01 Tom Tromey + * python/python.c (GdbMethods) : New. + (gdbpy_parse_and_eval): New function. + +2008-12-01 Tom Tromey + * python/python-value.c (is_intlike): New function. (valpy_int): Use it. (valpy_long): Likewise. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 90a769b..703543b 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,9 @@ 2008-12-01 Tom Tromey + * gdb.texinfo (Basic Python): Document parse_and_eval. + +2008-12-01 Tom Tromey + * gdb.texinfo (Convenience Vars): Document convenience functions. (Functions In Python): New node. (Python API): Update. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 38d3f1e..dfc19aa 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18099,6 +18099,13 @@ If the named parameter does not exist, this function throws a a Python value of the appropriate type, and returned. @end defun +@findex gdb.parse_and_eval +@defun parse_and_eval expression +Parse @var{expression} as an expression in the current language, +evaluate it, and return the result as a @code{gdb.Value}. +@var{expression} must be a string. +@end defun + @findex gdb.write @defun write string Print a string to @value{GDBN}'s paginated standard output stream. diff --git a/gdb/python/python.c b/gdb/python/python.c index 7b46f0d..bb0b428 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -394,6 +394,26 @@ gdbpy_decode_line (PyObject *self, PyObject *args) Py_RETURN_NONE; } +/* Parse a string and evaluate it as an expression. */ +static PyObject * +gdbpy_parse_and_eval (PyObject *self, PyObject *args) +{ + char *expr_str; + struct value *result = NULL; + volatile struct gdb_exception except; + + if (!PyArg_ParseTuple (args, "s", &expr_str)) + return NULL; + + TRY_CATCH (except, RETURN_MASK_ALL) + { + result = parse_and_eval (expr_str); + } + GDB_PY_HANDLE_EXCEPTION (except); + + return value_to_value_object (result); +} + /* Threads. */ @@ -1374,6 +1394,9 @@ Note: may later change to return an object." }, { "switch_to_thread", gdbpy_switch_to_thread, METH_VARARGS, "Switch to a thread, given the thread ID." }, + { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS, + "Parse a string as an expression, evaluate it, and return the result." }, + { "write", gdbpy_write, METH_VARARGS, "Write a string using gdb's filtered stream." }, { "flush", gdbpy_flush, METH_NOARGS, hooks/post-receive -- Repository for Project Archer.