Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1415)

Unified Diff: gdb/python/py-event.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/python/py-event.h ('k') | gdb/python/py-events.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/python/py-event.c
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 4789761f2d6337c7eeb2148fb0345b8ca5ed8786..9f5134d35c948269d77b187ac4e002b074938d4a 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -1,6 +1,6 @@
/* Python interface to inferior events.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2013 Free Software Foundation, Inc.
This file is part of GDB.
@@ -17,13 +17,14 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "defs.h"
#include "py-event.h"
void
evpy_dealloc (PyObject *self)
{
Py_XDECREF (((event_object *) self)->dict);
- self->ob_type->tp_free (self);
+ Py_TYPE (self)->tp_free (self);
}
PyObject *
@@ -48,7 +49,8 @@ create_event_object (PyTypeObject *py_type)
/* Add the attribute ATTR to the event object EVENT. In
python this attribute will be accessible by the name NAME.
- returns 0 if the operation succeeds and -1 otherwise. */
+ returns 0 if the operation succeeds and -1 otherwise. This
+ function acquires a new reference to ATTR. */
int
evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
@@ -58,11 +60,11 @@ evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
/* Initialize the Python event code. */
-void
+int
gdbpy_initialize_event (void)
{
- gdbpy_initialize_event_generic (&event_object_type,
- "Event");
+ return gdbpy_initialize_event_generic (&event_object_type,
+ "Event");
}
/* Initialize the given event type. If BASE is not NULL it will
@@ -74,17 +76,9 @@ gdbpy_initialize_event_generic (PyTypeObject *type,
char *name)
{
if (PyType_Ready (type) < 0)
- goto fail;
-
- Py_INCREF (type);
- if (PyModule_AddObject (gdb_module, name, (PyObject *) type) < 0)
- goto fail;
-
- return 0;
-
- fail:
- Py_XDECREF (type);
return -1;
+
+ return gdb_pymodule_addobject (gdb_module, name, (PyObject *) type);
}
@@ -109,16 +103,23 @@ evpy_emit_event (PyObject *event,
for (i = 0; i < PyList_Size (callback_list_copy); i++)
{
PyObject *func = PyList_GetItem (callback_list_copy, i);
+ PyObject *func_result;
if (func == NULL)
goto fail;
- if (!PyObject_CallFunctionObjArgs (func, event, NULL))
+ func_result = PyObject_CallFunctionObjArgs (func, event, NULL);
+
+ if (func_result == 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 ();
}
+ else
+ {
+ Py_DECREF (func_result);
+ }
}
Py_XDECREF (callback_list_copy);
@@ -141,8 +142,7 @@ static PyGetSetDef event_object_getset[] =
PyTypeObject event_object_type =
{
- PyObject_HEAD_INIT (NULL)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT (NULL, 0)
"gdb.Event", /* tp_name */
sizeof (event_object), /* tp_basicsize */
0, /* tp_itemsize */
« no previous file with comments | « gdb/python/py-event.h ('k') | gdb/python/py-events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698