1c50c785cSJohn Marino /* Python interface to inferior events. 2c50c785cSJohn Marino 3*ef5ccd6cSJohn Marino Copyright (C) 2009-2013 Free Software Foundation, Inc. 4c50c785cSJohn Marino 5c50c785cSJohn Marino This file is part of GDB. 6c50c785cSJohn Marino 7c50c785cSJohn Marino This program is free software; you can redistribute it and/or modify 8c50c785cSJohn Marino it under the terms of the GNU General Public License as published by 9c50c785cSJohn Marino the Free Software Foundation; either version 3 of the License, or 10c50c785cSJohn Marino (at your option) any later version. 11c50c785cSJohn Marino 12c50c785cSJohn Marino This program is distributed in the hope that it will be useful, 13c50c785cSJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 14c50c785cSJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15c50c785cSJohn Marino GNU General Public License for more details. 16c50c785cSJohn Marino 17c50c785cSJohn Marino You should have received a copy of the GNU General Public License 18c50c785cSJohn Marino along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19c50c785cSJohn Marino 20c50c785cSJohn Marino #ifndef GDB_PY_EVENT_H 21c50c785cSJohn Marino #define GDB_PY_EVENT_H 22c50c785cSJohn Marino 23c50c785cSJohn Marino #include "py-events.h" 24c50c785cSJohn Marino #include "command.h" 25c50c785cSJohn Marino #include "python-internal.h" 26c50c785cSJohn Marino #include "inferior.h" 27c50c785cSJohn Marino 28c50c785cSJohn Marino /* This macro creates the following functions: 29c50c785cSJohn Marino 30c50c785cSJohn Marino gdbpy_initialize_{NAME}_event 31c50c785cSJohn Marino Used to add the newly created event type to the gdb module. 32c50c785cSJohn Marino 33c50c785cSJohn Marino and the python type data structure for the event: 34c50c785cSJohn Marino 35c50c785cSJohn Marino struct PyTypeObject {NAME}_event_object_type 36c50c785cSJohn Marino 37c50c785cSJohn Marino NAME is the name of the event. 38c50c785cSJohn Marino PY_PATH is a string representing the module and python name of 39c50c785cSJohn Marino the event. 40c50c785cSJohn Marino PY_NAME a string representing what the event should be called in 41c50c785cSJohn Marino python. 42c50c785cSJohn Marino DOC Python documentation for the new event type 43c50c785cSJohn Marino BASE the base event for this event usually just event_object_type. 44c50c785cSJohn Marino QUAL qualification for the create event usually 'static' 45c50c785cSJohn Marino */ 46c50c785cSJohn Marino 47c50c785cSJohn Marino #define GDBPY_NEW_EVENT_TYPE(name, py_path, py_name, doc, base, qual) \ 48c50c785cSJohn Marino \ 49c50c785cSJohn Marino qual PyTypeObject name##_event_object_type = \ 50c50c785cSJohn Marino { \ 51*ef5ccd6cSJohn Marino PyVarObject_HEAD_INIT (NULL, 0) \ 52c50c785cSJohn Marino py_path, /* tp_name */ \ 53c50c785cSJohn Marino sizeof (event_object), /* tp_basicsize */ \ 54c50c785cSJohn Marino 0, /* tp_itemsize */ \ 55c50c785cSJohn Marino evpy_dealloc, /* tp_dealloc */ \ 56c50c785cSJohn Marino 0, /* tp_print */ \ 57c50c785cSJohn Marino 0, /* tp_getattr */ \ 58c50c785cSJohn Marino 0, /* tp_setattr */ \ 59c50c785cSJohn Marino 0, /* tp_compare */ \ 60c50c785cSJohn Marino 0, /* tp_repr */ \ 61c50c785cSJohn Marino 0, /* tp_as_number */ \ 62c50c785cSJohn Marino 0, /* tp_as_sequence */ \ 63c50c785cSJohn Marino 0, /* tp_as_mapping */ \ 64c50c785cSJohn Marino 0, /* tp_hash */ \ 65c50c785cSJohn Marino 0, /* tp_call */ \ 66c50c785cSJohn Marino 0, /* tp_str */ \ 67c50c785cSJohn Marino 0, /* tp_getattro */ \ 68c50c785cSJohn Marino 0, /* tp_setattro */ \ 69c50c785cSJohn Marino 0, /* tp_as_buffer */ \ 70c50c785cSJohn Marino Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \ 71c50c785cSJohn Marino doc, /* tp_doc */ \ 72c50c785cSJohn Marino 0, /* tp_traverse */ \ 73c50c785cSJohn Marino 0, /* tp_clear */ \ 74c50c785cSJohn Marino 0, /* tp_richcompare */ \ 75c50c785cSJohn Marino 0, /* tp_weaklistoffset */ \ 76c50c785cSJohn Marino 0, /* tp_iter */ \ 77c50c785cSJohn Marino 0, /* tp_iternext */ \ 78c50c785cSJohn Marino 0, /* tp_methods */ \ 79c50c785cSJohn Marino 0, /* tp_members */ \ 80c50c785cSJohn Marino 0, /* tp_getset */ \ 81c50c785cSJohn Marino &base, /* tp_base */ \ 82c50c785cSJohn Marino 0, /* tp_dict */ \ 83c50c785cSJohn Marino 0, /* tp_descr_get */ \ 84c50c785cSJohn Marino 0, /* tp_descr_set */ \ 85c50c785cSJohn Marino 0, /* tp_dictoffset */ \ 86c50c785cSJohn Marino 0, /* tp_init */ \ 87c50c785cSJohn Marino 0 /* tp_alloc */ \ 88c50c785cSJohn Marino }; \ 89c50c785cSJohn Marino \ 90c50c785cSJohn Marino void \ 91c50c785cSJohn Marino gdbpy_initialize_##name##_event (void) \ 92c50c785cSJohn Marino { \ 93c50c785cSJohn Marino gdbpy_initialize_event_generic (&name##_event_object_type, \ 94c50c785cSJohn Marino py_name); \ 95c50c785cSJohn Marino } 96c50c785cSJohn Marino 97c50c785cSJohn Marino typedef struct 98c50c785cSJohn Marino { 99c50c785cSJohn Marino PyObject_HEAD 100c50c785cSJohn Marino 101c50c785cSJohn Marino PyObject *dict; 102c50c785cSJohn Marino } event_object; 103c50c785cSJohn Marino 104c50c785cSJohn Marino extern int emit_continue_event (ptid_t ptid); 105a45ae5f8SJohn Marino extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf); 106c50c785cSJohn Marino 107c50c785cSJohn Marino extern int evpy_emit_event (PyObject *event, 108c50c785cSJohn Marino eventregistry_object *registry); 109c50c785cSJohn Marino 110c50c785cSJohn Marino extern PyObject *create_event_object (PyTypeObject *py_type); 111c50c785cSJohn Marino extern PyObject *create_thread_event_object (PyTypeObject *py_type); 112a45ae5f8SJohn Marino extern int emit_new_objfile_event (struct objfile *objfile); 113c50c785cSJohn Marino 114c50c785cSJohn Marino extern void evpy_dealloc (PyObject *self); 115c50c785cSJohn Marino extern int evpy_add_attribute (PyObject *event, 116c50c785cSJohn Marino char *name, PyObject *attr); 117c50c785cSJohn Marino int gdbpy_initialize_event_generic (PyTypeObject *type, char *name); 118c50c785cSJohn Marino 119c50c785cSJohn Marino 120c50c785cSJohn Marino #endif /* GDB_PY_EVENT_H */ 121