]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/python/py-event.h
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / python / py-event.h
CommitLineData
c17a9e46
HZ
1/* Python interface to inferior events.
2
618f726f 3 Copyright (C) 2009-2016 Free Software Foundation, Inc.
c17a9e46
HZ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef GDB_PY_EVENT_H
21#define GDB_PY_EVENT_H
22
c17a9e46
HZ
23#include "py-events.h"
24#include "command.h"
25#include "python-internal.h"
26#include "inferior.h"
27
28/* This macro creates the following functions:
29
30 gdbpy_initialize_{NAME}_event
31 Used to add the newly created event type to the gdb module.
32
33 and the python type data structure for the event:
34
35 struct PyTypeObject {NAME}_event_object_type
36
37 NAME is the name of the event.
38 PY_PATH is a string representing the module and python name of
39 the event.
40 PY_NAME a string representing what the event should be called in
41 python.
42 DOC Python documentation for the new event type
43 BASE the base event for this event usually just event_object_type.
c17a9e46
HZ
44*/
45
e36122e9 46#define GDBPY_NEW_EVENT_TYPE(name, py_path, py_name, doc, base) \
c17a9e46 47\
e36122e9 48 PyTypeObject name##_event_object_type \
62eec1a5
TT
49 CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \
50 = { \
9a27f2c6 51 PyVarObject_HEAD_INIT (NULL, 0) \
c17a9e46
HZ
52 py_path, /* tp_name */ \
53 sizeof (event_object), /* tp_basicsize */ \
54 0, /* tp_itemsize */ \
55 evpy_dealloc, /* tp_dealloc */ \
56 0, /* tp_print */ \
57 0, /* tp_getattr */ \
58 0, /* tp_setattr */ \
59 0, /* tp_compare */ \
60 0, /* tp_repr */ \
61 0, /* tp_as_number */ \
62 0, /* tp_as_sequence */ \
63 0, /* tp_as_mapping */ \
64 0, /* tp_hash */ \
65 0, /* tp_call */ \
66 0, /* tp_str */ \
67 0, /* tp_getattro */ \
68 0, /* tp_setattro */ \
69 0, /* tp_as_buffer */ \
70 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \
71 doc, /* tp_doc */ \
72 0, /* tp_traverse */ \
73 0, /* tp_clear */ \
74 0, /* tp_richcompare */ \
75 0, /* tp_weaklistoffset */ \
76 0, /* tp_iter */ \
77 0, /* tp_iternext */ \
78 0, /* tp_methods */ \
79 0, /* tp_members */ \
80 0, /* tp_getset */ \
81 &base, /* tp_base */ \
82 0, /* tp_dict */ \
83 0, /* tp_descr_get */ \
84 0, /* tp_descr_set */ \
85 0, /* tp_dictoffset */ \
86 0, /* tp_init */ \
87 0 /* tp_alloc */ \
88 }; \
89\
999633ed 90int \
c17a9e46
HZ
91gdbpy_initialize_##name##_event (void) \
92{ \
999633ed
TT
93 return gdbpy_initialize_event_generic (&name##_event_object_type, \
94 py_name); \
c17a9e46
HZ
95}
96
97typedef struct
98{
99 PyObject_HEAD
100
101 PyObject *dict;
102} event_object;
103
104extern int emit_continue_event (ptid_t ptid);
cb6be26b 105extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf);
c17a9e46 106
162078c8
NB
107/* For inferior function call events, discriminate whether event is
108 before or after the call. */
109
110typedef enum
111{
112 /* Before the call */
113 INFERIOR_CALL_PRE,
114 /* after the call */
115 INFERIOR_CALL_POST,
116} inferior_call_kind;
117
118extern int emit_inferior_call_event (inferior_call_kind kind,
119 ptid_t thread, CORE_ADDR addr);
120extern int emit_register_changed_event (struct frame_info *frame,
121 int regnum);
122extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len);
c17a9e46 123extern int evpy_emit_event (PyObject *event,
9b08f225
TT
124 eventregistry_object *registry)
125 CPYCHECKER_STEALS_REFERENCE_TO_ARG (1);
c17a9e46
HZ
126
127extern PyObject *create_event_object (PyTypeObject *py_type);
128extern PyObject *create_thread_event_object (PyTypeObject *py_type);
20c168b5 129extern int emit_new_objfile_event (struct objfile *objfile);
4ffbba72 130extern int emit_clear_objfiles_event (void);
c17a9e46
HZ
131
132extern void evpy_dealloc (PyObject *self);
133extern int evpy_add_attribute (PyObject *event,
5d153bd1
TT
134 char *name, PyObject *attr)
135 CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
136int gdbpy_initialize_event_generic (PyTypeObject *type, char *name)
137 CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
c17a9e46
HZ
138
139#endif /* GDB_PY_EVENT_H */