dma: beautify queue listing output
[dragonfly.git] / contrib / gdb-6.2.1 / gdb / gdb-events.c
blobe0916d8706f5c9919564bf20d943a51ff50e91b7
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
30 found being reported.
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
35 prove easier. */
38 #include "defs.h"
39 #include "gdb-events.h"
40 #include "gdbcmd.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;
46 int gdb_events_debug;
48 void
49 breakpoint_create_event (int b)
51 if (gdb_events_debug)
52 fprintf_unfiltered (gdb_stdlog, "breakpoint_create_event\n");
53 if (!current_event_hooks->breakpoint_create)
54 return;
55 current_event_hooks->breakpoint_create (b);
58 void
59 breakpoint_delete_event (int b)
61 if (gdb_events_debug)
62 fprintf_unfiltered (gdb_stdlog, "breakpoint_delete_event\n");
63 if (!current_event_hooks->breakpoint_delete)
64 return;
65 current_event_hooks->breakpoint_delete (b);
68 void
69 breakpoint_modify_event (int b)
71 if (gdb_events_debug)
72 fprintf_unfiltered (gdb_stdlog, "breakpoint_modify_event\n");
73 if (!current_event_hooks->breakpoint_modify)
74 return;
75 current_event_hooks->breakpoint_modify (b);
78 void
79 tracepoint_create_event (int number)
81 if (gdb_events_debug)
82 fprintf_unfiltered (gdb_stdlog, "tracepoint_create_event\n");
83 if (!current_event_hooks->tracepoint_create)
84 return;
85 current_event_hooks->tracepoint_create (number);
88 void
89 tracepoint_delete_event (int number)
91 if (gdb_events_debug)
92 fprintf_unfiltered (gdb_stdlog, "tracepoint_delete_event\n");
93 if (!current_event_hooks->tracepoint_delete)
94 return;
95 current_event_hooks->tracepoint_delete (number);
98 void
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)
104 return;
105 current_event_hooks->tracepoint_modify (number);
108 void
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)
114 return;
115 current_event_hooks->architecture_changed ();
118 struct gdb_events *
119 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
121 struct gdb_events *old_events = current_event_hooks;
122 if (vector == NULL)
123 current_event_hooks = &queue_event_hooks;
124 else
125 current_event_hooks = vector;
126 return old_events;
129 void
130 clear_gdb_event_hooks (void)
132 deprecated_set_gdb_event_hooks (&null_event_hooks);
135 enum gdb_event
137 breakpoint_create,
138 breakpoint_delete,
139 breakpoint_modify,
140 tracepoint_create,
141 tracepoint_delete,
142 tracepoint_modify,
143 architecture_changed,
144 nr_gdb_events
147 struct breakpoint_create
149 int b;
152 struct breakpoint_delete
154 int b;
157 struct breakpoint_modify
159 int b;
162 struct tracepoint_create
164 int number;
167 struct tracepoint_delete
169 int number;
172 struct tracepoint_modify
174 int number;
177 struct event
179 enum gdb_event type;
180 struct event *next;
181 union
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;
190 data;
192 struct event *pending_events;
193 struct event *delivering_events;
195 static void
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;
205 static void
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;
211 append (event);
214 static void
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;
220 append (event);
223 static void
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;
229 append (event);
232 static void
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;
238 append (event);
241 static void
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;
247 append (event);
250 static void
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;
256 append (event);
259 static void
260 queue_architecture_changed (void)
262 struct event *event = XMALLOC (struct event);
263 event->type = architecture_changed;
264 append (event);
267 void
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;
275 xfree (event);
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
280 necessary. */
281 delivering_events = pending_events;
282 pending_events = NULL;
283 while (delivering_events != NULL)
285 struct event *event = delivering_events;
286 switch (event->type)
288 case breakpoint_create:
289 vector->breakpoint_create
290 (event->data.breakpoint_create.b);
291 break;
292 case breakpoint_delete:
293 vector->breakpoint_delete
294 (event->data.breakpoint_delete.b);
295 break;
296 case breakpoint_modify:
297 vector->breakpoint_modify
298 (event->data.breakpoint_modify.b);
299 break;
300 case tracepoint_create:
301 vector->tracepoint_create
302 (event->data.tracepoint_create.number);
303 break;
304 case tracepoint_delete:
305 vector->tracepoint_delete
306 (event->data.tracepoint_delete.number);
307 break;
308 case tracepoint_modify:
309 vector->tracepoint_modify
310 (event->data.tracepoint_modify.number);
311 break;
312 case architecture_changed:
313 vector->architecture_changed ();
314 break;
316 delivering_events = event->next;
317 xfree (event);
321 void _initialize_gdb_events (void);
322 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",
341 class_maintenance,
342 var_zinteger,
343 (char *) (&gdb_events_debug),
344 "Set event debugging.\n\
345 When non-zero, event/notify debugging is enabled.", &setdebuglist),
346 &showdebuglist);