public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: jkratoch@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-jankratochvil-python: Merge commit 'origin/archer-tromey-python' into archer-jankratochvil-python
Date: Mon, 30 Mar 2009 17:22:00 -0000	[thread overview]
Message-ID: <20090330172222.11987.qmail@sourceware.org> (raw)

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)
 \f
 
 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" "\\(<gdb.Frame object at 0x\[\[:xdigit:\]\]+>, <g
 gdb_py_test_silent_cmd "python f0 = frames\[0\]" "get first frame" 0
 gdb_py_test_silent_cmd "python f1 = frames\[1\]" "get second frame" 0
 
-gdb_test "python print 'result =', f0.equals (f1)" " = False" "test equals (false)"
-gdb_test "python print 'result =', f0.equals (f0)" " = True" "test equals (true)"
+gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)"
+gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)"
 gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid"
 gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name"
 gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type"
@@ -79,14 +79,14 @@ gdb_test "python print 'result =', f0.unwind_stop_reason () == gdb.FRAME_UNWIND_
 gdb_test "python print 'result =', gdb.frame_stop_reason_string (gdb.FRAME_UNWIND_INNER_ID)" " = previous frame inner to this frame \\(corrupt stack\\?\\)" "test gdb.frame_stop_reason_string"
 gdb_test "python print 'result =', f0.pc ()" " = \[0-9\]+" "test Frame.pc"
 gdb_test "python print 'result =', f0.function ()" " = symbol for f2" "test Frame.function"
-gdb_test "python print 'result =', f0.older ().equals (f1)" " = True" "test Frame.older"
-gdb_test "python print 'result =', f1.newer ().equals (f0)" " = True" "test Frame.newer"
+gdb_test "python print 'result =', f0.older () == f1" " = True" "test Frame.older"
+gdb_test "python print 'result =', f1.newer () == f0" " = True" "test Frame.newer"
 gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_exist')" \
   "ValueError: variable 'variable_which_surely_doesnt_exist' not found.*Error while executing Python code." \
   "test Frame.read_var - error"
 gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success"
 
-gdb_test "python print 'result =', gdb.newest_frame ().equals (f0)" " = True" "test gdb.newest_frame"
-gdb_test "python print 'result =', gdb.selected_frame ().equals (f1)" " = True" "test gdb.selected_frame"
+gdb_test "python print 'result =', gdb.newest_frame () == f0" " = True" "test gdb.newest_frame"
+gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame"
 
 gdb_test "python print 'result =', f0.block ()" "<gdb.Block object at 0x\[\[:xdigit:\]\]+>" "test Frame.block"


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2009-03-30 17:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30 17:22 jkratoch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-06-26 13:51 jkratoch
2009-03-29 22:42 jkratoch
2009-03-27  0:35 jkratoch
2009-03-25 19:00 jkratoch
2009-03-24 17:33 jkratoch
2009-03-09 17:05 jkratoch
2009-03-06 16:59 jkratoch
2009-03-06 14:26 jkratoch
2009-03-05 21:53 jkratoch
2009-03-05 21:15 jkratoch
2009-03-04 23:54 jkratoch
2009-03-04 22:34 jkratoch
2009-03-04 15:02 jkratoch
2009-03-03 21:46 jkratoch
2009-03-03 21:45 jkratoch
2009-03-02 20:46 jkratoch
2009-03-01 14:38 jkratoch
2009-02-28 19:26 jkratoch
2009-02-26 23:01 jkratoch

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=20090330172222.11987.qmail@sourceware.org \
    --to=jkratoch@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: link
Be 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).