GDB (API)
|
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 #ifndef GDB_PY_EVENT_H 00021 #define GDB_PY_EVENT_H 00022 00023 #include "py-events.h" 00024 #include "command.h" 00025 #include "python-internal.h" 00026 #include "inferior.h" 00027 00028 /* This macro creates the following functions: 00029 00030 gdbpy_initialize_{NAME}_event 00031 Used to add the newly created event type to the gdb module. 00032 00033 and the python type data structure for the event: 00034 00035 struct PyTypeObject {NAME}_event_object_type 00036 00037 NAME is the name of the event. 00038 PY_PATH is a string representing the module and python name of 00039 the event. 00040 PY_NAME a string representing what the event should be called in 00041 python. 00042 DOC Python documentation for the new event type 00043 BASE the base event for this event usually just event_object_type. 00044 QUAL qualification for the create event usually 'static' 00045 */ 00046 00047 #define GDBPY_NEW_EVENT_TYPE(name, py_path, py_name, doc, base, qual) \ 00048 \ 00049 qual PyTypeObject name##_event_object_type \ 00050 CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \ 00051 = { \ 00052 PyVarObject_HEAD_INIT (NULL, 0) \ 00053 py_path, /* tp_name */ \ 00054 sizeof (event_object), /* tp_basicsize */ \ 00055 0, /* tp_itemsize */ \ 00056 evpy_dealloc, /* tp_dealloc */ \ 00057 0, /* tp_print */ \ 00058 0, /* tp_getattr */ \ 00059 0, /* tp_setattr */ \ 00060 0, /* tp_compare */ \ 00061 0, /* tp_repr */ \ 00062 0, /* tp_as_number */ \ 00063 0, /* tp_as_sequence */ \ 00064 0, /* tp_as_mapping */ \ 00065 0, /* tp_hash */ \ 00066 0, /* tp_call */ \ 00067 0, /* tp_str */ \ 00068 0, /* tp_getattro */ \ 00069 0, /* tp_setattro */ \ 00070 0, /* tp_as_buffer */ \ 00071 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \ 00072 doc, /* tp_doc */ \ 00073 0, /* tp_traverse */ \ 00074 0, /* tp_clear */ \ 00075 0, /* tp_richcompare */ \ 00076 0, /* tp_weaklistoffset */ \ 00077 0, /* tp_iter */ \ 00078 0, /* tp_iternext */ \ 00079 0, /* tp_methods */ \ 00080 0, /* tp_members */ \ 00081 0, /* tp_getset */ \ 00082 &base, /* tp_base */ \ 00083 0, /* tp_dict */ \ 00084 0, /* tp_descr_get */ \ 00085 0, /* tp_descr_set */ \ 00086 0, /* tp_dictoffset */ \ 00087 0, /* tp_init */ \ 00088 0 /* tp_alloc */ \ 00089 }; \ 00090 \ 00091 int \ 00092 gdbpy_initialize_##name##_event (void) \ 00093 { \ 00094 return gdbpy_initialize_event_generic (&name##_event_object_type, \ 00095 py_name); \ 00096 } 00097 00098 typedef struct 00099 { 00100 PyObject_HEAD 00101 00102 PyObject *dict; 00103 } event_object; 00104 00105 extern int emit_continue_event (ptid_t ptid); 00106 extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf); 00107 00108 extern int evpy_emit_event (PyObject *event, 00109 eventregistry_object *registry) 00110 CPYCHECKER_STEALS_REFERENCE_TO_ARG (1); 00111 00112 extern PyObject *create_event_object (PyTypeObject *py_type); 00113 extern PyObject *create_thread_event_object (PyTypeObject *py_type); 00114 extern int emit_new_objfile_event (struct objfile *objfile); 00115 00116 extern void evpy_dealloc (PyObject *self); 00117 extern int evpy_add_attribute (PyObject *event, 00118 char *name, PyObject *attr) 00119 CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; 00120 int gdbpy_initialize_event_generic (PyTypeObject *type, char *name) 00121 CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; 00122 00123 #endif /* GDB_PY_EVENT_H */