Commit | Line | Data |
---|---|---|
104c1213 | 1 | /* User Interface Events. |
349c5d5f | 2 | |
711cc5cd | 3 | Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc. |
104c1213 JM |
4 | |
5 | Contributed by Cygnus Solutions. | |
6 | ||
afbfc876 | 7 | This file is part of GDB. |
104c1213 | 8 | |
afbfc876 AC |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
104c1213 | 13 | |
afbfc876 AC |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
104c1213 | 18 | |
afbfc876 AC |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software | |
30867156 MS |
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
22 | USA. */ | |
104c1213 JM |
23 | |
24 | /* Work in progress */ | |
25 | ||
26 | /* This file was created with the aid of ``gdb-events.sh''. | |
27 | ||
28 | The bourn shell script ``gdb-events.sh'' creates the files | |
29 | ``new-gdb-events.c'' and ``new-gdb-events.h and then compares | |
30 | them against the existing ``gdb-events.[hc]''. Any differences | |
31 | found being reported. | |
32 | ||
33 | If editing this file, please also run gdb-events.sh and merge any | |
34 | changes into that script. Conversely, when making sweeping changes | |
35 | to this file, modifying gdb-events.sh and using its output may | |
30867156 | 36 | prove easier. */ |
104c1213 JM |
37 | |
38 | ||
39 | #include "defs.h" | |
40 | #include "gdb-events.h" | |
41 | #include "gdbcmd.h" | |
42 | ||
104c1213 JM |
43 | static struct gdb_events null_event_hooks; |
44 | static struct gdb_events queue_event_hooks; | |
45 | static struct gdb_events *current_event_hooks = &null_event_hooks; | |
104c1213 JM |
46 | |
47 | int gdb_events_debug; | |
48 | ||
104c1213 JM |
49 | void |
50 | breakpoint_create_event (int b) | |
51 | { | |
52 | if (gdb_events_debug) | |
53 | fprintf_unfiltered (gdb_stdlog, "breakpoint_create_event\n"); | |
54 | if (!current_event_hooks->breakpoint_create) | |
55 | return; | |
56 | current_event_hooks->breakpoint_create (b); | |
57 | } | |
58 | ||
59 | void | |
60 | breakpoint_delete_event (int b) | |
61 | { | |
62 | if (gdb_events_debug) | |
63 | fprintf_unfiltered (gdb_stdlog, "breakpoint_delete_event\n"); | |
64 | if (!current_event_hooks->breakpoint_delete) | |
65 | return; | |
66 | current_event_hooks->breakpoint_delete (b); | |
67 | } | |
68 | ||
69 | void | |
70 | breakpoint_modify_event (int b) | |
71 | { | |
72 | if (gdb_events_debug) | |
73 | fprintf_unfiltered (gdb_stdlog, "breakpoint_modify_event\n"); | |
74 | if (!current_event_hooks->breakpoint_modify) | |
75 | return; | |
76 | current_event_hooks->breakpoint_modify (b); | |
77 | } | |
78 | ||
ba9fe036 KS |
79 | void |
80 | tracepoint_create_event (int number) | |
81 | { | |
82 | if (gdb_events_debug) | |
83 | fprintf_unfiltered (gdb_stdlog, "tracepoint_create_event\n"); | |
84 | if (!current_event_hooks->tracepoint_create) | |
85 | return; | |
86 | current_event_hooks->tracepoint_create (number); | |
87 | } | |
88 | ||
89 | void | |
90 | tracepoint_delete_event (int number) | |
91 | { | |
92 | if (gdb_events_debug) | |
93 | fprintf_unfiltered (gdb_stdlog, "tracepoint_delete_event\n"); | |
94 | if (!current_event_hooks->tracepoint_delete) | |
95 | return; | |
96 | current_event_hooks->tracepoint_delete (number); | |
97 | } | |
98 | ||
99 | void | |
100 | tracepoint_modify_event (int number) | |
101 | { | |
102 | if (gdb_events_debug) | |
103 | fprintf_unfiltered (gdb_stdlog, "tracepoint_modify_event\n"); | |
104 | if (!current_event_hooks->tracepoint_modify) | |
105 | return; | |
106 | current_event_hooks->tracepoint_modify (number); | |
107 | } | |
108 | ||
67c2c32c KS |
109 | void |
110 | architecture_changed_event (void) | |
111 | { | |
112 | if (gdb_events_debug) | |
113 | fprintf_unfiltered (gdb_stdlog, "architecture_changed_event\n"); | |
114 | if (!current_event_hooks->architecture_changed) | |
115 | return; | |
116 | current_event_hooks->architecture_changed (); | |
117 | } | |
118 | ||
ed9a39eb | 119 | struct gdb_events * |
2726dafc | 120 | deprecated_set_gdb_event_hooks (struct gdb_events *vector) |
104c1213 | 121 | { |
ed9a39eb | 122 | struct gdb_events *old_events = current_event_hooks; |
104c1213 JM |
123 | if (vector == NULL) |
124 | current_event_hooks = &queue_event_hooks; | |
125 | else | |
126 | current_event_hooks = vector; | |
ed9a39eb | 127 | return old_events; |
104c1213 | 128 | } |
104c1213 | 129 | |
63d022e0 KS |
130 | void |
131 | clear_gdb_event_hooks (void) | |
132 | { | |
2726dafc | 133 | deprecated_set_gdb_event_hooks (&null_event_hooks); |
63d022e0 | 134 | } |
63d022e0 | 135 | |
104c1213 | 136 | enum gdb_event |
afbfc876 AC |
137 | { |
138 | breakpoint_create, | |
139 | breakpoint_delete, | |
140 | breakpoint_modify, | |
ba9fe036 KS |
141 | tracepoint_create, |
142 | tracepoint_delete, | |
143 | tracepoint_modify, | |
67c2c32c | 144 | architecture_changed, |
afbfc876 AC |
145 | nr_gdb_events |
146 | }; | |
104c1213 JM |
147 | |
148 | struct breakpoint_create | |
149 | { | |
150 | int b; | |
151 | }; | |
152 | ||
153 | struct breakpoint_delete | |
154 | { | |
155 | int b; | |
156 | }; | |
157 | ||
158 | struct breakpoint_modify | |
159 | { | |
160 | int b; | |
161 | }; | |
162 | ||
ba9fe036 KS |
163 | struct tracepoint_create |
164 | { | |
165 | int number; | |
166 | }; | |
167 | ||
168 | struct tracepoint_delete | |
169 | { | |
170 | int number; | |
171 | }; | |
172 | ||
173 | struct tracepoint_modify | |
174 | { | |
175 | int number; | |
176 | }; | |
177 | ||
104c1213 JM |
178 | struct event |
179 | { | |
180 | enum gdb_event type; | |
181 | struct event *next; | |
182 | union | |
183 | { | |
afbfc876 AC |
184 | struct breakpoint_create breakpoint_create; |
185 | struct breakpoint_delete breakpoint_delete; | |
186 | struct breakpoint_modify breakpoint_modify; | |
ba9fe036 KS |
187 | struct tracepoint_create tracepoint_create; |
188 | struct tracepoint_delete tracepoint_delete; | |
189 | struct tracepoint_modify tracepoint_modify; | |
104c1213 JM |
190 | } |
191 | data; | |
192 | }; | |
193 | struct event *pending_events; | |
194 | struct event *delivering_events; | |
195 | ||
196 | static void | |
197 | append (struct event *new_event) | |
198 | { | |
199 | struct event **event = &pending_events; | |
200 | while ((*event) != NULL) | |
201 | event = &((*event)->next); | |
202 | (*event) = new_event; | |
203 | (*event)->next = NULL; | |
204 | } | |
205 | ||
206 | static void | |
207 | queue_breakpoint_create (int b) | |
208 | { | |
209 | struct event *event = XMALLOC (struct event); | |
210 | event->type = breakpoint_create; | |
211 | event->data.breakpoint_create.b = b; | |
212 | append (event); | |
213 | } | |
214 | ||
215 | static void | |
216 | queue_breakpoint_delete (int b) | |
217 | { | |
218 | struct event *event = XMALLOC (struct event); | |
219 | event->type = breakpoint_delete; | |
220 | event->data.breakpoint_delete.b = b; | |
221 | append (event); | |
222 | } | |
223 | ||
224 | static void | |
225 | queue_breakpoint_modify (int b) | |
226 | { | |
227 | struct event *event = XMALLOC (struct event); | |
228 | event->type = breakpoint_modify; | |
229 | event->data.breakpoint_modify.b = b; | |
230 | append (event); | |
231 | } | |
232 | ||
ba9fe036 KS |
233 | static void |
234 | queue_tracepoint_create (int number) | |
235 | { | |
236 | struct event *event = XMALLOC (struct event); | |
237 | event->type = tracepoint_create; | |
238 | event->data.tracepoint_create.number = number; | |
239 | append (event); | |
240 | } | |
241 | ||
242 | static void | |
243 | queue_tracepoint_delete (int number) | |
244 | { | |
245 | struct event *event = XMALLOC (struct event); | |
246 | event->type = tracepoint_delete; | |
247 | event->data.tracepoint_delete.number = number; | |
248 | append (event); | |
249 | } | |
250 | ||
251 | static void | |
252 | queue_tracepoint_modify (int number) | |
253 | { | |
254 | struct event *event = XMALLOC (struct event); | |
255 | event->type = tracepoint_modify; | |
256 | event->data.tracepoint_modify.number = number; | |
257 | append (event); | |
258 | } | |
259 | ||
67c2c32c KS |
260 | static void |
261 | queue_architecture_changed (void) | |
262 | { | |
263 | struct event *event = XMALLOC (struct event); | |
264 | event->type = architecture_changed; | |
265 | append (event); | |
266 | } | |
267 | ||
104c1213 JM |
268 | void |
269 | gdb_events_deliver (struct gdb_events *vector) | |
270 | { | |
271 | /* Just zap any events left around from last time. */ | |
272 | while (delivering_events != NULL) | |
273 | { | |
274 | struct event *event = delivering_events; | |
275 | delivering_events = event->next; | |
b8c9b27d | 276 | xfree (event); |
104c1213 JM |
277 | } |
278 | /* Process any pending events. Because one of the deliveries could | |
279 | bail out we move everything off of the pending queue onto an | |
280 | in-progress queue where it can, later, be cleaned up if | |
281 | necessary. */ | |
282 | delivering_events = pending_events; | |
283 | pending_events = NULL; | |
284 | while (delivering_events != NULL) | |
285 | { | |
286 | struct event *event = delivering_events; | |
287 | switch (event->type) | |
afbfc876 AC |
288 | { |
289 | case breakpoint_create: | |
290 | vector->breakpoint_create | |
291 | (event->data.breakpoint_create.b); | |
292 | break; | |
293 | case breakpoint_delete: | |
294 | vector->breakpoint_delete | |
295 | (event->data.breakpoint_delete.b); | |
296 | break; | |
297 | case breakpoint_modify: | |
298 | vector->breakpoint_modify | |
299 | (event->data.breakpoint_modify.b); | |
300 | break; | |
ba9fe036 KS |
301 | case tracepoint_create: |
302 | vector->tracepoint_create | |
303 | (event->data.tracepoint_create.number); | |
304 | break; | |
305 | case tracepoint_delete: | |
306 | vector->tracepoint_delete | |
307 | (event->data.tracepoint_delete.number); | |
308 | break; | |
309 | case tracepoint_modify: | |
310 | vector->tracepoint_modify | |
311 | (event->data.tracepoint_modify.number); | |
312 | break; | |
67c2c32c KS |
313 | case architecture_changed: |
314 | vector->architecture_changed (); | |
315 | break; | |
afbfc876 | 316 | } |
104c1213 | 317 | delivering_events = event->next; |
b8c9b27d | 318 | xfree (event); |
104c1213 JM |
319 | } |
320 | } | |
321 | ||
322 | void _initialize_gdb_events (void); | |
323 | void | |
324 | _initialize_gdb_events (void) | |
325 | { | |
5d161b24 | 326 | struct cmd_list_element *c; |
104c1213 JM |
327 | queue_event_hooks.breakpoint_create = queue_breakpoint_create; |
328 | queue_event_hooks.breakpoint_delete = queue_breakpoint_delete; | |
329 | queue_event_hooks.breakpoint_modify = queue_breakpoint_modify; | |
ba9fe036 KS |
330 | queue_event_hooks.tracepoint_create = queue_tracepoint_create; |
331 | queue_event_hooks.tracepoint_delete = queue_tracepoint_delete; | |
332 | queue_event_hooks.tracepoint_modify = queue_tracepoint_modify; | |
67c2c32c | 333 | queue_event_hooks.architecture_changed = queue_architecture_changed; |
5d161b24 | 334 | |
afbfc876 AC |
335 | c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger, |
336 | (char *) (&gdb_events_debug), "Set event debugging.\n\ | |
5d161b24 | 337 | When non-zero, event/notify debugging is enabled.", &setlist); |
afbfc876 | 338 | deprecate_cmd (c, "set debug event"); |
cb1a6d5f AC |
339 | deprecate_cmd (deprecated_add_show_from_set (c, &showlist), |
340 | "show debug event"); | |
341 | ||
30867156 MS |
342 | deprecated_add_show_from_set (add_set_cmd ("event", |
343 | class_maintenance, | |
344 | var_zinteger, | |
345 | (char *) (&gdb_events_debug), | |
346 | "Set event debugging.\n\ | |
347 | When non-zero, event/notify debugging is enabled.", | |
348 | &setdebuglist), | |
349 | &showdebuglist); | |
104c1213 | 350 | } |