1 /* User Interface Events.
3 Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
5 Contributed by Cygnus Solutions.
7 This file is part of GDB.
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.
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.
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
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 /* Work in progress */
25 /* This file was created with the aid of ``gdb-events.sh''.
27 The bourn shell script ``gdb-events.sh'' creates the files
28 ``new-gdb-events.c'' and ``new-gdb-events.h and then compares
29 them against the existing ``gdb-events.[hc]''. Any differences
32 If editing this file, please also run gdb-events.sh and merge any
33 changes into that script. Conversely, when making sweeping changes
34 to this file, modifying gdb-events.sh and using its output may
39 #include "gdb-events.h"
42 static struct gdb_events null_event_hooks
;
43 static struct gdb_events queue_event_hooks
;
44 static struct gdb_events
*current_event_hooks
= &null_event_hooks
;
49 breakpoint_create_event (int b
)
52 fprintf_unfiltered (gdb_stdlog
, "breakpoint_create_event\n");
53 if (!current_event_hooks
->breakpoint_create
)
55 current_event_hooks
->breakpoint_create (b
);
59 breakpoint_delete_event (int b
)
62 fprintf_unfiltered (gdb_stdlog
, "breakpoint_delete_event\n");
63 if (!current_event_hooks
->breakpoint_delete
)
65 current_event_hooks
->breakpoint_delete (b
);
69 breakpoint_modify_event (int b
)
72 fprintf_unfiltered (gdb_stdlog
, "breakpoint_modify_event\n");
73 if (!current_event_hooks
->breakpoint_modify
)
75 current_event_hooks
->breakpoint_modify (b
);
79 tracepoint_create_event (int number
)
82 fprintf_unfiltered (gdb_stdlog
, "tracepoint_create_event\n");
83 if (!current_event_hooks
->tracepoint_create
)
85 current_event_hooks
->tracepoint_create (number
);
89 tracepoint_delete_event (int number
)
92 fprintf_unfiltered (gdb_stdlog
, "tracepoint_delete_event\n");
93 if (!current_event_hooks
->tracepoint_delete
)
95 current_event_hooks
->tracepoint_delete (number
);
99 tracepoint_modify_event (int number
)
101 if (gdb_events_debug
)
102 fprintf_unfiltered (gdb_stdlog
, "tracepoint_modify_event\n");
103 if (!current_event_hooks
->tracepoint_modify
)
105 current_event_hooks
->tracepoint_modify (number
);
109 architecture_changed_event (void)
111 if (gdb_events_debug
)
112 fprintf_unfiltered (gdb_stdlog
, "architecture_changed_event\n");
113 if (!current_event_hooks
->architecture_changed
)
115 current_event_hooks
->architecture_changed ();
119 deprecated_set_gdb_event_hooks (struct gdb_events
*vector
)
121 struct gdb_events
*old_events
= current_event_hooks
;
123 current_event_hooks
= &queue_event_hooks
;
125 current_event_hooks
= vector
;
130 clear_gdb_event_hooks (void)
132 deprecated_set_gdb_event_hooks (&null_event_hooks
);
143 architecture_changed
,
147 struct breakpoint_create
152 struct breakpoint_delete
157 struct breakpoint_modify
162 struct tracepoint_create
167 struct tracepoint_delete
172 struct tracepoint_modify
183 struct breakpoint_create breakpoint_create
;
184 struct breakpoint_delete breakpoint_delete
;
185 struct breakpoint_modify breakpoint_modify
;
186 struct tracepoint_create tracepoint_create
;
187 struct tracepoint_delete tracepoint_delete
;
188 struct tracepoint_modify tracepoint_modify
;
192 struct event
*pending_events
;
193 struct event
*delivering_events
;
196 append (struct event
*new_event
)
198 struct event
**event
= &pending_events
;
199 while ((*event
) != NULL
)
200 event
= &((*event
)->next
);
201 (*event
) = new_event
;
202 (*event
)->next
= NULL
;
206 queue_breakpoint_create (int b
)
208 struct event
*event
= XMALLOC (struct event
);
209 event
->type
= breakpoint_create
;
210 event
->data
.breakpoint_create
.b
= b
;
215 queue_breakpoint_delete (int b
)
217 struct event
*event
= XMALLOC (struct event
);
218 event
->type
= breakpoint_delete
;
219 event
->data
.breakpoint_delete
.b
= b
;
224 queue_breakpoint_modify (int b
)
226 struct event
*event
= XMALLOC (struct event
);
227 event
->type
= breakpoint_modify
;
228 event
->data
.breakpoint_modify
.b
= b
;
233 queue_tracepoint_create (int number
)
235 struct event
*event
= XMALLOC (struct event
);
236 event
->type
= tracepoint_create
;
237 event
->data
.tracepoint_create
.number
= number
;
242 queue_tracepoint_delete (int number
)
244 struct event
*event
= XMALLOC (struct event
);
245 event
->type
= tracepoint_delete
;
246 event
->data
.tracepoint_delete
.number
= number
;
251 queue_tracepoint_modify (int number
)
253 struct event
*event
= XMALLOC (struct event
);
254 event
->type
= tracepoint_modify
;
255 event
->data
.tracepoint_modify
.number
= number
;
260 queue_architecture_changed (void)
262 struct event
*event
= XMALLOC (struct event
);
263 event
->type
= architecture_changed
;
268 gdb_events_deliver (struct gdb_events
*vector
)
270 /* Just zap any events left around from last time. */
271 while (delivering_events
!= NULL
)
273 struct event
*event
= delivering_events
;
274 delivering_events
= event
->next
;
277 /* Process any pending events. Because one of the deliveries could
278 bail out we move everything off of the pending queue onto an
279 in-progress queue where it can, later, be cleaned up if
281 delivering_events
= pending_events
;
282 pending_events
= NULL
;
283 while (delivering_events
!= NULL
)
285 struct event
*event
= delivering_events
;
288 case breakpoint_create
:
289 vector
->breakpoint_create
290 (event
->data
.breakpoint_create
.b
);
292 case breakpoint_delete
:
293 vector
->breakpoint_delete
294 (event
->data
.breakpoint_delete
.b
);
296 case breakpoint_modify
:
297 vector
->breakpoint_modify
298 (event
->data
.breakpoint_modify
.b
);
300 case tracepoint_create
:
301 vector
->tracepoint_create
302 (event
->data
.tracepoint_create
.number
);
304 case tracepoint_delete
:
305 vector
->tracepoint_delete
306 (event
->data
.tracepoint_delete
.number
);
308 case tracepoint_modify
:
309 vector
->tracepoint_modify
310 (event
->data
.tracepoint_modify
.number
);
312 case architecture_changed
:
313 vector
->architecture_changed ();
316 delivering_events
= event
->next
;
321 void _initialize_gdb_events (void);
323 _initialize_gdb_events (void)
325 struct cmd_list_element
*c
;
326 queue_event_hooks
.breakpoint_create
= queue_breakpoint_create
;
327 queue_event_hooks
.breakpoint_delete
= queue_breakpoint_delete
;
328 queue_event_hooks
.breakpoint_modify
= queue_breakpoint_modify
;
329 queue_event_hooks
.tracepoint_create
= queue_tracepoint_create
;
330 queue_event_hooks
.tracepoint_delete
= queue_tracepoint_delete
;
331 queue_event_hooks
.tracepoint_modify
= queue_tracepoint_modify
;
332 queue_event_hooks
.architecture_changed
= queue_architecture_changed
;
334 c
= add_set_cmd ("eventdebug", class_maintenance
, var_zinteger
,
335 (char *) (&gdb_events_debug
), "Set event debugging.\n\
336 When non-zero, event/notify debugging is enabled.", &setlist
);
337 deprecate_cmd (c
, "set debug event");
338 deprecate_cmd (add_show_from_set (c
, &showlist
), "show debug event");
340 add_show_from_set (add_set_cmd ("event",
343 (char *) (&gdb_events_debug
),
344 "Set event debugging.\n\
345 When non-zero, event/notify debugging is enabled.", &setdebuglist
),