From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12099 invoked by alias); 30 Mar 2009 17:22:23 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 12016 invoked by uid 9674); 30 Mar 2009 17:22:23 -0000 Date: Mon, 30 Mar 2009 17:22:00 -0000 Message-ID: <20090330172222.11987.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-python: Merge commit 'origin/archer-tromey-python' into archer-jankratochvil-python X-Git-Refname: refs/heads/archer-jankratochvil-python X-Git-Reftype: branch X-Git-Oldrev: a99d5b6c1c3f8667b833b186eefe5f94dc1f6c22 X-Git-Newrev: 0adf45a975c950b336e60ae9b6707a03b214cb08 X-SW-Source: 2009-q1/txt/msg00400.txt.bz2 List-Id: The branch, archer-jankratochvil-python has been updated via 0adf45a975c950b336e60ae9b6707a03b214cb08 (commit) via 4cbedfdc756e827c0cad49a43e68917487988b3c (commit) via 823ab34a0473db7f19cf665998afbb8763533ff1 (commit) from a99d5b6c1c3f8667b833b186eefe5f94dc1f6c22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: gdb/doc/gdb.texinfo | 41 ++++++++++---------- gdb/python/python-frame.c | 59 ++++++++++++++--------------- gdb/testsuite/gdb.python/python-frame.exp | 12 +++--- 3 files changed, 55 insertions(+), 57 deletions(-) First 500 lines of diff: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 3eb5854..2dc5a3e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19575,32 +19575,36 @@ separated by newlines. If there are no commands, this attribute is @cindex frames in python @tindex gdb.Frame @tindex Frame -When the debugged program stops, @value{GDBN} is able to analyse its call +When the debugged program stops, @value{GDBN} is able to analyze its call stack (@pxref{Frames,,Stack frames}). The @code{gdb.Frame} class represents a frame in the stack. A @code{gdb.Frame} object is only valid while its corresponding frame exists in the inferior's stack. If you try -to use an invalid frame object, a @code{RuntimeError} exception will be -thrown. +to use an invalid frame object, @value{GDBN} will throw a @code{RuntimeError} +exception. + +Two @code{gdb.Frame} objects can be compared for equality with the @code{==} +operator, like: + +@smallexample +(@value{GDBP}) python print gdb.newest_frame() == gdb.selected_frame () +True +@end smallexample The following frame-related functions are available in the @code{gdb} module: -@findex gdb.frames @defun frames Return a tuple containing all frame objects. @end defun -@findex gdb.newest_frame @defun newest_frame Return the newest frame object. @end defun -@findex gdb.selected_frame @defun selected_frame Return the selected frame object. (@pxref{Selection,,Selecting a Frame}). @end defun -@findex gdb.frame_stop_reason_string -@defun frame_stop_reason_string @var{reason} +@defun frame_stop_reason_string reason Return a string explaining the reason why @value{GDBN} stopped unwinding frames, as expressed by the given @var{reason} code (an integer, see the @code{unwind_stop_reason} method further down in this section). @@ -19609,15 +19613,11 @@ frames, as expressed by the given @var{reason} code (an integer, see the A @code{gdb.Frame} object has the following methods: @table @code -@defmethod Frame equals @code{frame} -Compare frames. -@end defmethod - @defmethod Frame is_valid Returns true if the @code{gdb.Frame} object is valid, false if not. A frame object can become invalid if the frame it refers to doesn't exist anymore in the inferior. All @code{gdb.Frame} methods will throw -an exception if it is invalid at the time the method call is made. +an exception if it is invalid at the time the method is called. @end defmethod @defmethod Frame name @@ -19626,15 +19626,16 @@ obtained. @end defmethod @defmethod Frame type -Returns the type of the frame. The value can be one of +Returns the type of the frame. The value can be one of @code{gdb.NORMAL_FRAME}, @code{gdb.DUMMY_FRAME}, @code{gdb.SIGTRAMP_FRAME} or @code{gdb.SENTINEL_FRAME}. @end defmethod @defmethod Frame unwind_stop_reason Return an integer representing the reason why it's not possible to find -frames older than this. Use @code{gdb.frame_stop_reason_string} to convert -the value returned by this function to a string. +more frames toward the outermost frame. Use +@code{gdb.frame_stop_reason_string} to convert the value returned by this +function to a string. @end defmethod @defmethod Frame pc @@ -19650,19 +19651,19 @@ Returns the symbol for the function corresponding to this frame. @c (@pxref{Symb @end defmethod @defmethod Frame older -Return the frame immediately older (outer) to this frame. +Return the frame that called this frame. @end defmethod @defmethod Frame newer -Return the frame immediately newer (inner) to this frame. +Return the frame called by this frame. @end defmethod @defmethod Frame find_sal Return the frame's symtab and line object. @c (@pxref{Symtab_and_line,, Symtab and line}). @end defmethod -@defmethod Frame read_var @var{variable} -Return the value of the given variable in this frame. @code{variable} can be +@defmethod Frame read_var variable +Return the value of the given variable in this frame. @var{variable} can be either a string or a @code{gdb.Symbol} object. @c (@pxref{Symbols In Python}). @end defmethod @end table diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index 4b76709..6c33e65 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -109,31 +109,6 @@ frapy_is_valid (PyObject *self, PyObject *args) Py_RETURN_TRUE; } -/* Implementation of gdb.Frame.equals (self, other) -> Boolean. */ - -static PyObject * -frapy_equal_p (PyObject *self, PyObject *args) -{ - int equalp = 0; /* Initialize to appease gcc warning. */ - frame_object *self_frame = (frame_object *) self; - frame_object *other; - volatile struct gdb_exception except; - - if (!PyArg_ParseTuple (args, "O!", &frame_object_type, &other)) - return NULL; - - TRY_CATCH (except, RETURN_MASK_ALL) - { - equalp = frame_id_eq (self_frame->frame_id, other->frame_id); - } - GDB_PY_HANDLE_EXCEPTION (except); - - if (equalp) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; -} - /* Implementation of gdb.Frame.name (self) -> String. Returns the name of the function corresponding to this frame. */ @@ -581,6 +556,31 @@ gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args) return PyUnicode_Decode (str, strlen (str), host_charset (), NULL); } +/* Implements the equality comparison for Frame objects. + All other comparison operators will throw a TypeError Python exception, + as they aren't valid for frames. */ + +static PyObject * +frapy_richcompare (PyObject *self, PyObject *other, int op) +{ + if (!PyObject_TypeCheck (other, &frame_object_type)) + { + PyErr_SetString (PyExc_TypeError, "Frame object expected in comparison."); + return NULL; + } + else if (op != Py_EQ) + { + PyErr_SetString (PyExc_TypeError, "Invalid comparison for gdb.Frame."); + return NULL; + } + + if (frame_id_eq (((frame_object *) self)->frame_id, + ((frame_object *) other)->frame_id)) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; +} + /* Sets up the Frame API in the gdb module. */ void @@ -616,9 +616,6 @@ gdbpy_initialize_frames (void) static PyMethodDef frame_object_methods[] = { - { "equals", frapy_equal_p, METH_VARARGS, - "equals (frame) -> Boolean.\n\ -Compare this frame to the given frame." }, { "is_valid", frapy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\ Return true if this frame is valid, false if not." }, @@ -642,10 +639,10 @@ Return the frame's code block." }, Returns the symbol for the function corresponding to this frame." }, { "older", frapy_older, METH_NOARGS, "older () -> gdb.Frame.\n\ -Return the frame immediately older (outer) to this frame." }, +Return the frame that called this frame." }, { "newer", frapy_newer, METH_NOARGS, "newer () -> gdb.Frame.\n\ -Return the frame immetidaely newer (inner) to this frame." }, +Return the frame called by this frame." }, { "find_sal", frapy_find_sal, METH_NOARGS, "find_sal () -> gdb.Symtab_and_line.\n\ Return the frame's symtab and line." }, @@ -680,7 +677,7 @@ static PyTypeObject frame_object_type = { "GDB frame object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + frapy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ diff --git a/gdb/testsuite/gdb.python/python-frame.exp b/gdb/testsuite/gdb.python/python-frame.exp index 93a3d21..cbf1095 100644 --- a/gdb/testsuite/gdb.python/python-frame.exp +++ b/gdb/testsuite/gdb.python/python-frame.exp @@ -70,8 +70,8 @@ gdb_test "python print frames" "\\(,