GDB (API)
/home/stan/gdb/src/gdb/python/py-evts.c
Go to the documentation of this file.
00001 /* Python interface to inferior events.
00002 
00003    Copyright (C) 2009-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 #include "py-events.h"
00022 
00023 #ifdef IS_PY3K
00024 static struct PyModuleDef EventModuleDef =
00025 {
00026   PyModuleDef_HEAD_INIT,
00027   "gdb.events",
00028   NULL,
00029   -1, 
00030   NULL,
00031   NULL,
00032   NULL,
00033   NULL,
00034   NULL
00035 };
00036 #endif
00037 
00038 /* Initialize python events.  */
00039 
00040 static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
00041 add_new_registry (eventregistry_object **registryp, char *name)
00042 {
00043   int result;
00044 
00045   *registryp = create_eventregistry_object ();
00046 
00047   if (*registryp == NULL)
00048     return -1;
00049 
00050   return gdb_pymodule_addobject (gdb_py_events.module,
00051                                  name,
00052                                  (PyObject *)(*registryp));
00053 }
00054 
00055 int
00056 gdbpy_initialize_py_events (void)
00057 {
00058 #ifdef IS_PY3K
00059   gdb_py_events.module = PyModule_Create (&EventModuleDef);
00060 #else
00061   gdb_py_events.module = Py_InitModule ("events", NULL);
00062 #endif
00063 
00064   if (!gdb_py_events.module)
00065     return -1;
00066 
00067   if (add_new_registry (&gdb_py_events.stop, "stop") < 0)
00068     return -1;
00069 
00070   if (add_new_registry (&gdb_py_events.cont, "cont") < 0)
00071     return -1;
00072 
00073   if (add_new_registry (&gdb_py_events.exited, "exited") < 0)
00074     return -1;
00075 
00076   if (add_new_registry (&gdb_py_events.new_objfile, "new_objfile") < 0)
00077     return -1;
00078 
00079   if (gdb_pymodule_addobject (gdb_module,
00080                               "events",
00081                               (PyObject *) gdb_py_events.module) < 0)
00082     return -1;
00083 
00084   return 0;
00085 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines