/* Python interface to inferior events.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
This file is part of GDB.
/* 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
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);
}
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);