1 /* User Interface Events.
3 Copyright 1999, 2001, 2002, 2004, 2005 Free Software Foundation,
6 Contributed by Cygnus Solutions.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* Work in progress */
26 /* This file was created with the aid of ``gdb-events.sh''.
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
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
40 #include "gdb-events.h"
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
;
49 show_gdb_events_debug (struct ui_file
*file
, int from_tty
,
50 struct cmd_list_element
*c
, const char *value
)
52 fprintf_filtered (file
, _("Event debugging is %s.\n"), value
);
57 breakpoint_create_event (int b
)
60 fprintf_unfiltered (gdb_stdlog
, "breakpoint_create_event\n");
61 if (!current_event_hooks
->breakpoint_create
)
63 current_event_hooks
->breakpoint_create (b
);
67 breakpoint_delete_event (int b
)
70 fprintf_unfiltered (gdb_stdlog
, "breakpoint_delete_event\n");
71 if (!current_event_hooks
->breakpoint_delete
)
73 current_event_hooks
->breakpoint_delete (b
);
77 breakpoint_modify_event (int b
)
80 fprintf_unfiltered (gdb_stdlog
, "breakpoint_modify_event\n");
81 if (!current_event_hooks
->breakpoint_modify
)
83 current_event_hooks
->breakpoint_modify (b
);
87 tracepoint_create_event (int number
)
90 fprintf_unfiltered (gdb_stdlog
, "tracepoint_create_event\n");
91 if (!current_event_hooks
->tracepoint_create
)
93 current_event_hooks
->tracepoint_create (number
);
97 tracepoint_delete_event (int number
)
100 fprintf_unfiltered (gdb_stdlog
, "tracepoint_delete_event\n");
101 if (!current_event_hooks
->tracepoint_delete
)
103 current_event_hooks
->tracepoint_delete (number
);
107 tracepoint_modify_event (int number
)
109 if (gdb_events_debug
)
110 fprintf_unfiltered (gdb_stdlog
, "tracepoint_modify_event\n");
111 if (!current_event_hooks
->tracepoint_modify
)
113 current_event_hooks
->tracepoint_modify (number
);
117 architecture_changed_event (void)
119 if (gdb_events_debug
)
120 fprintf_unfiltered (gdb_stdlog
, "architecture_changed_event\n");
121 if (!current_event_hooks
->architecture_changed
)
123 current_event_hooks
->architecture_changed ();
127 deprecated_set_gdb_event_hooks (struct gdb_events
*vector
)
129 struct gdb_events
*old_events
= current_event_hooks
;
131 current_event_hooks
= &queue_event_hooks
;
133 current_event_hooks
= vector
;
138 clear_gdb_event_hooks (void)
140 deprecated_set_gdb_event_hooks (&null_event_hooks
);
151 architecture_changed
,
155 struct breakpoint_create
160 struct breakpoint_delete
165 struct breakpoint_modify
170 struct tracepoint_create
175 struct tracepoint_delete
180 struct tracepoint_modify
191 struct breakpoint_create breakpoint_create
;
192 struct breakpoint_delete breakpoint_delete
;
193 struct breakpoint_modify breakpoint_modify
;
194 struct tracepoint_create tracepoint_create
;
195 struct tracepoint_delete tracepoint_delete
;
196 struct tracepoint_modify tracepoint_modify
;
200 struct event
*pending_events
;
201 struct event
*delivering_events
;
204 append (struct event
*new_event
)
206 struct event
**event
= &pending_events
;
207 while ((*event
) != NULL
)
208 event
= &((*event
)->next
);
209 (*event
) = new_event
;
210 (*event
)->next
= NULL
;
214 queue_breakpoint_create (int b
)
216 struct event
*event
= XMALLOC (struct event
);
217 event
->type
= breakpoint_create
;
218 event
->data
.breakpoint_create
.b
= b
;
223 queue_breakpoint_delete (int b
)
225 struct event
*event
= XMALLOC (struct event
);
226 event
->type
= breakpoint_delete
;
227 event
->data
.breakpoint_delete
.b
= b
;
232 queue_breakpoint_modify (int b
)
234 struct event
*event
= XMALLOC (struct event
);
235 event
->type
= breakpoint_modify
;
236 event
->data
.breakpoint_modify
.b
= b
;
241 queue_tracepoint_create (int number
)
243 struct event
*event
= XMALLOC (struct event
);
244 event
->type
= tracepoint_create
;
245 event
->data
.tracepoint_create
.number
= number
;
250 queue_tracepoint_delete (int number
)
252 struct event
*event
= XMALLOC (struct event
);
253 event
->type
= tracepoint_delete
;
254 event
->data
.tracepoint_delete
.number
= number
;
259 queue_tracepoint_modify (int number
)
261 struct event
*event
= XMALLOC (struct event
);
262 event
->type
= tracepoint_modify
;
263 event
->data
.tracepoint_modify
.number
= number
;
268 queue_architecture_changed (void)
270 struct event
*event
= XMALLOC (struct event
);
271 event
->type
= architecture_changed
;
276 gdb_events_deliver (struct gdb_events
*vector
)
278 /* Just zap any events left around from last time. */
279 while (delivering_events
!= NULL
)
281 struct event
*event
= delivering_events
;
282 delivering_events
= event
->next
;
285 /* Process any pending events. Because one of the deliveries could
286 bail out we move everything off of the pending queue onto an
287 in-progress queue where it can, later, be cleaned up if
289 delivering_events
= pending_events
;
290 pending_events
= NULL
;
291 while (delivering_events
!= NULL
)
293 struct event
*event
= delivering_events
;
296 case breakpoint_create
:
297 vector
->breakpoint_create
298 (event
->data
.breakpoint_create
.b
);
300 case breakpoint_delete
:
301 vector
->breakpoint_delete
302 (event
->data
.breakpoint_delete
.b
);
304 case breakpoint_modify
:
305 vector
->breakpoint_modify
306 (event
->data
.breakpoint_modify
.b
);
308 case tracepoint_create
:
309 vector
->tracepoint_create
310 (event
->data
.tracepoint_create
.number
);
312 case tracepoint_delete
:
313 vector
->tracepoint_delete
314 (event
->data
.tracepoint_delete
.number
);
316 case tracepoint_modify
:
317 vector
->tracepoint_modify
318 (event
->data
.tracepoint_modify
.number
);
320 case architecture_changed
:
321 vector
->architecture_changed ();
324 delivering_events
= event
->next
;
329 void _initialize_gdb_events (void);
331 _initialize_gdb_events (void)
333 struct cmd_list_element
*c
;
334 queue_event_hooks
.breakpoint_create
= queue_breakpoint_create
;
335 queue_event_hooks
.breakpoint_delete
= queue_breakpoint_delete
;
336 queue_event_hooks
.breakpoint_modify
= queue_breakpoint_modify
;
337 queue_event_hooks
.tracepoint_create
= queue_tracepoint_create
;
338 queue_event_hooks
.tracepoint_delete
= queue_tracepoint_delete
;
339 queue_event_hooks
.tracepoint_modify
= queue_tracepoint_modify
;
340 queue_event_hooks
.architecture_changed
= queue_architecture_changed
;
342 add_setshow_zinteger_cmd ("event", class_maintenance
,
343 &gdb_events_debug
, _("\
344 Set event debugging."), _("\
345 Show event debugging."), _("\
346 When non-zero, event/notify debugging is enabled."),
348 show_gdb_events_debug
,
349 &setdebuglist
, &showdebuglist
);