1 /* User Interface Events.
3 Copyright (C) 1999, 2001, 2002, 2004, 2005, 2007
4 Free Software Foundation, Inc.
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., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
25 /* Work in progress */
27 /* This file was created with the aid of ``gdb-events.sh''.
29 The bourn shell script ``gdb-events.sh'' creates the files
30 ``new-gdb-events.c'' and ``new-gdb-events.h and then compares
31 them against the existing ``gdb-events.[hc]''. Any differences
34 If editing this file, please also run gdb-events.sh and merge any
35 changes into that script. Conversely, when making sweeping changes
36 to this file, modifying gdb-events.sh and using its output may
41 #include "gdb-events.h"
44 static struct gdb_events null_event_hooks
;
45 static struct gdb_events queue_event_hooks
;
46 static struct gdb_events
*current_event_hooks
= &null_event_hooks
;
50 show_gdb_events_debug (struct ui_file
*file
, int from_tty
,
51 struct cmd_list_element
*c
, const char *value
)
53 fprintf_filtered (file
, _("Event debugging is %s.\n"), value
);
58 breakpoint_create_event (int b
)
61 fprintf_unfiltered (gdb_stdlog
, "breakpoint_create_event\n");
62 if (!current_event_hooks
->breakpoint_create
)
64 current_event_hooks
->breakpoint_create (b
);
68 breakpoint_delete_event (int b
)
71 fprintf_unfiltered (gdb_stdlog
, "breakpoint_delete_event\n");
72 if (!current_event_hooks
->breakpoint_delete
)
74 current_event_hooks
->breakpoint_delete (b
);
78 breakpoint_modify_event (int b
)
81 fprintf_unfiltered (gdb_stdlog
, "breakpoint_modify_event\n");
82 if (!current_event_hooks
->breakpoint_modify
)
84 current_event_hooks
->breakpoint_modify (b
);
88 tracepoint_create_event (int number
)
91 fprintf_unfiltered (gdb_stdlog
, "tracepoint_create_event\n");
92 if (!current_event_hooks
->tracepoint_create
)
94 current_event_hooks
->tracepoint_create (number
);
98 tracepoint_delete_event (int number
)
100 if (gdb_events_debug
)
101 fprintf_unfiltered (gdb_stdlog
, "tracepoint_delete_event\n");
102 if (!current_event_hooks
->tracepoint_delete
)
104 current_event_hooks
->tracepoint_delete (number
);
108 tracepoint_modify_event (int number
)
110 if (gdb_events_debug
)
111 fprintf_unfiltered (gdb_stdlog
, "tracepoint_modify_event\n");
112 if (!current_event_hooks
->tracepoint_modify
)
114 current_event_hooks
->tracepoint_modify (number
);
118 architecture_changed_event (void)
120 if (gdb_events_debug
)
121 fprintf_unfiltered (gdb_stdlog
, "architecture_changed_event\n");
122 if (!current_event_hooks
->architecture_changed
)
124 current_event_hooks
->architecture_changed ();
128 deprecated_set_gdb_event_hooks (struct gdb_events
*vector
)
130 struct gdb_events
*old_events
= current_event_hooks
;
132 current_event_hooks
= &queue_event_hooks
;
134 current_event_hooks
= vector
;
139 clear_gdb_event_hooks (void)
141 deprecated_set_gdb_event_hooks (&null_event_hooks
);
152 architecture_changed
,
156 struct breakpoint_create
161 struct breakpoint_delete
166 struct breakpoint_modify
171 struct tracepoint_create
176 struct tracepoint_delete
181 struct tracepoint_modify
192 struct breakpoint_create breakpoint_create
;
193 struct breakpoint_delete breakpoint_delete
;
194 struct breakpoint_modify breakpoint_modify
;
195 struct tracepoint_create tracepoint_create
;
196 struct tracepoint_delete tracepoint_delete
;
197 struct tracepoint_modify tracepoint_modify
;
201 struct event
*pending_events
;
202 struct event
*delivering_events
;
205 append (struct event
*new_event
)
207 struct event
**event
= &pending_events
;
208 while ((*event
) != NULL
)
209 event
= &((*event
)->next
);
210 (*event
) = new_event
;
211 (*event
)->next
= NULL
;
215 queue_breakpoint_create (int b
)
217 struct event
*event
= XMALLOC (struct event
);
218 event
->type
= breakpoint_create
;
219 event
->data
.breakpoint_create
.b
= b
;
224 queue_breakpoint_delete (int b
)
226 struct event
*event
= XMALLOC (struct event
);
227 event
->type
= breakpoint_delete
;
228 event
->data
.breakpoint_delete
.b
= b
;
233 queue_breakpoint_modify (int b
)
235 struct event
*event
= XMALLOC (struct event
);
236 event
->type
= breakpoint_modify
;
237 event
->data
.breakpoint_modify
.b
= b
;
242 queue_tracepoint_create (int number
)
244 struct event
*event
= XMALLOC (struct event
);
245 event
->type
= tracepoint_create
;
246 event
->data
.tracepoint_create
.number
= number
;
251 queue_tracepoint_delete (int number
)
253 struct event
*event
= XMALLOC (struct event
);
254 event
->type
= tracepoint_delete
;
255 event
->data
.tracepoint_delete
.number
= number
;
260 queue_tracepoint_modify (int number
)
262 struct event
*event
= XMALLOC (struct event
);
263 event
->type
= tracepoint_modify
;
264 event
->data
.tracepoint_modify
.number
= number
;
269 queue_architecture_changed (void)
271 struct event
*event
= XMALLOC (struct event
);
272 event
->type
= architecture_changed
;
277 gdb_events_deliver (struct gdb_events
*vector
)
279 /* Just zap any events left around from last time. */
280 while (delivering_events
!= NULL
)
282 struct event
*event
= delivering_events
;
283 delivering_events
= event
->next
;
286 /* Process any pending events. Because one of the deliveries could
287 bail out we move everything off of the pending queue onto an
288 in-progress queue where it can, later, be cleaned up if
290 delivering_events
= pending_events
;
291 pending_events
= NULL
;
292 while (delivering_events
!= NULL
)
294 struct event
*event
= delivering_events
;
297 case breakpoint_create
:
298 vector
->breakpoint_create
299 (event
->data
.breakpoint_create
.b
);
301 case breakpoint_delete
:
302 vector
->breakpoint_delete
303 (event
->data
.breakpoint_delete
.b
);
305 case breakpoint_modify
:
306 vector
->breakpoint_modify
307 (event
->data
.breakpoint_modify
.b
);
309 case tracepoint_create
:
310 vector
->tracepoint_create
311 (event
->data
.tracepoint_create
.number
);
313 case tracepoint_delete
:
314 vector
->tracepoint_delete
315 (event
->data
.tracepoint_delete
.number
);
317 case tracepoint_modify
:
318 vector
->tracepoint_modify
319 (event
->data
.tracepoint_modify
.number
);
321 case architecture_changed
:
322 vector
->architecture_changed ();
325 delivering_events
= event
->next
;
330 void _initialize_gdb_events (void);
332 _initialize_gdb_events (void)
334 struct cmd_list_element
*c
;
335 queue_event_hooks
.breakpoint_create
= queue_breakpoint_create
;
336 queue_event_hooks
.breakpoint_delete
= queue_breakpoint_delete
;
337 queue_event_hooks
.breakpoint_modify
= queue_breakpoint_modify
;
338 queue_event_hooks
.tracepoint_create
= queue_tracepoint_create
;
339 queue_event_hooks
.tracepoint_delete
= queue_tracepoint_delete
;
340 queue_event_hooks
.tracepoint_modify
= queue_tracepoint_modify
;
341 queue_event_hooks
.architecture_changed
= queue_architecture_changed
;
343 add_setshow_zinteger_cmd ("event", class_maintenance
,
344 &gdb_events_debug
, _("\
345 Set event debugging."), _("\
346 Show event debugging."), _("\
347 When non-zero, event/notify debugging is enabled."),
349 show_gdb_events_debug
,
350 &setdebuglist
, &showdebuglist
);