public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: tromey@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-swagiaal-oguz: cleanups in copy_py_list
Date: Wed, 15 Dec 2010 16:34:00 -0000	[thread overview]
Message-ID: <20101215163406.31062.qmail@sourceware.org> (raw)

The branch, archer-swagiaal-oguz has been updated
       via  7508a202caa1d05f6ebb0df3c359f27f7ff2ce14 (commit)
       via  f9d1f4aa50e70b9ef16ea9a3596cb2758b2516fb (commit)
       via  b1bc690c3e0ab48e62c6d6617358f0cdcc1b234d (commit)
       via  68a784af97eec629ccdf59fd7020e3141b4ce736 (commit)
      from  cfe32b5303f8a09ce72bb46de3297e64316b9c07 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 7508a202caa1d05f6ebb0df3c359f27f7ff2ce14
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Dec 15 09:33:25 2010 -0700

    cleanups in copy_py_list

commit f9d1f4aa50e70b9ef16ea9a3596cb2758b2516fb
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Dec 15 09:32:12 2010 -0700

    fix for gdbpy_selected_thread from master

commit b1bc690c3e0ab48e62c6d6617358f0cdcc1b234d
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Dec 15 09:31:26 2010 -0700

    fix for find_thread_object from master

commit 68a784af97eec629ccdf59fd7020e3141b4ce736
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Dec 15 09:22:20 2010 -0700

    clean up evpy_emit_event

-----------------------------------------------------------------------

Summary of changes:
 gdb/python/py-event.c     |   31 +++++++++++++++++++++++--------
 gdb/python/py-inferior.c  |    3 +++
 gdb/python/py-infthread.c |    7 -------
 gdb/python/python.c       |   11 ++++++++---
 4 files changed, 34 insertions(+), 18 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 65ac3f5..2c84be9 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -124,9 +124,8 @@ gdbpy_initialize_event (void)
 void
 evpy_emit_event (event_object *event)
 {
-  PyObject *callback_list;
-  PyObject *callback_list_copy;
-  PyObject *args_tuple;
+  PyObject *callback_list, *event_obj = (PyObject *) event;
+  PyObject *callback_list_copy = NULL;
   Py_ssize_t i;
 
   callback_list = (PyObject *) (event->registry->callbacks);
@@ -137,15 +136,31 @@ evpy_emit_event (event_object *event)
      a notification.  */
   callback_list_copy = copy_py_list (callback_list);
   if (!callback_list_copy)
-    error(_("Cannot copy callback list."));
-
-  args_tuple = PyTuple_New ((Py_ssize_t) 1);
-  PyTuple_SetItem (args_tuple, (Py_ssize_t) 0, (PyObject *) event);
+    goto fail;
 
   for (i = 0; i < PyList_Size (callback_list_copy); i++)
     {
-      PyObject_CallObject (PyList_GET_ITEM (callback_list_copy, i), args_tuple);
+      PyObject *func = PyList_GetItem (callback_list_copy, i);
+
+      if (func == NULL)
+	goto fail;
+
+      if (!PyObject_CallFunctionObjArgs (func, event_obj, NULL))
+	{
+	  /* Print the trace here, but keep going -- we want to try to
+	     call all of the callbacks even if one is broken.  */
+	  gdbpy_print_stack ();
+	}
     }
+
+  Py_XDECREF (callback_list_copy);
+  Py_XDECREF (event_obj);
+  return;
+
+ fail:
+  gdbpy_print_stack ();
+  Py_XDECREF (callback_list_copy);
+  Py_XDECREF (event_obj);
 }
 
 static PyGetSetDef event_object_getset[] =
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index c277335..e14b5da 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -206,6 +206,9 @@ find_thread_object (ptid_t ptid)
   PyObject *inf_obj;
 
   pid = PIDGET (ptid);
+  if (pid == 0)
+    return NULL;
+
   inf_obj = find_inferior_object (pid);
 
   if (inf_obj)
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 64f0a21..3e76519 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -173,13 +173,6 @@ gdbpy_selected_thread (PyObject *self, PyObject *args)
 {
   PyObject *thread_obj;
 
-  if (inferior_ptid.pid == 0)
-    {
-      PyErr_SetString (PyExc_RuntimeError,
-                       _("No thread is currently selected."));
-      return NULL;
-    }
-
   thread_obj = (PyObject *) find_thread_object (inferior_ptid);
   if (thread_obj)
     {
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 7c686d3..6f13a1e 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -163,10 +163,11 @@ compute_python_string (struct command_line *l)
 }
 
 /* Returns a a copy of the give LIST.
-   Creates a new reference which must be handeld by the caller.  */
+   Creates a new reference which must be handled by the caller.  */
 
 PyObject *
-copy_py_list (PyObject *list){
+copy_py_list (PyObject *list)
+{
   int i;
 
   PyObject *new_list = PyList_New (0);
@@ -174,7 +175,11 @@ copy_py_list (PyObject *list){
     return NULL;
 
   for (i = 0; i < PyList_Size (list); i++)
-    PyList_Append (new_list, PyList_GET_ITEM (list, i));
+    if (PyList_Append (new_list, PyList_GET_ITEM (list, i)) < 0)
+      {
+	Py_DECREF (new_list);
+	return NULL;
+      }
 
   return new_list;
 }


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


                 reply	other threads:[~2010-12-15 16:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20101215163406.31062.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: 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).