Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / gdb-events.c
blobe2ce9638f70d575b9a4b30ee2a9e4a40e15389e5
1 /* User Interface Events.
3 Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation,
4 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
32 found being reported.
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
37 prove easier. */
40 #include "defs.h"
41 #include "gdb-events.h"
42 #include "gdbcmd.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;
48 int gdb_events_debug;
49 static void
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);
57 void
58 breakpoint_create_event (int b)
60 if (gdb_events_debug)
61 fprintf_unfiltered (gdb_stdlog, "breakpoint_create_event\n");
62 if (!current_event_hooks->breakpoint_create)
63 return;
64 current_event_hooks->breakpoint_create (b);
67 void
68 breakpoint_delete_event (int b)
70 if (gdb_events_debug)
71 fprintf_unfiltered (gdb_stdlog, "breakpoint_delete_event\n");
72 if (!current_event_hooks->breakpoint_delete)
73 return;
74 current_event_hooks->breakpoint_delete (b);
77 void
78 breakpoint_modify_event (int b)
80 if (gdb_events_debug)
81 fprintf_unfiltered (gdb_stdlog, "breakpoint_modify_event\n");
82 if (!current_event_hooks->breakpoint_modify)
83 return;
84 current_event_hooks->breakpoint_modify (b);
87 void
88 tracepoint_create_event (int number)
90 if (gdb_events_debug)
91 fprintf_unfiltered (gdb_stdlog, "tracepoint_create_event\n");
92 if (!current_event_hooks->tracepoint_create)
93 return;
94 current_event_hooks->tracepoint_create (number);
97 void
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)
103 return;
104 current_event_hooks->tracepoint_delete (number);
107 void
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)
113 return;
114 current_event_hooks->tracepoint_modify (number);
117 void
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)
123 return;
124 current_event_hooks->architecture_changed ();
127 struct gdb_events *
128 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
130 struct gdb_events *old_events = current_event_hooks;
131 if (vector == NULL)
132 current_event_hooks = &queue_event_hooks;
133 else
134 current_event_hooks = vector;
135 return old_events;
138 void
139 clear_gdb_event_hooks (void)
141 deprecated_set_gdb_event_hooks (&null_event_hooks);
144 enum gdb_event
146 breakpoint_create,
147 breakpoint_delete,
148 breakpoint_modify,
149 tracepoint_create,
150 tracepoint_delete,
151 tracepoint_modify,
152 architecture_changed,
153 nr_gdb_events
156 struct breakpoint_create
158 int b;
161 struct breakpoint_delete
163 int b;
166 struct breakpoint_modify
168 int b;
171 struct tracepoint_create
173 int number;
176 struct tracepoint_delete
178 int number;
181 struct tracepoint_modify
183 int number;
186 struct event
188 enum gdb_event type;
189 struct event *next;
190 union
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;
199 data;
201 struct event *pending_events;
202 struct event *delivering_events;
204 static void
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;
214 static void
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;
220 append (event);
223 static void
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;
229 append (event);
232 static void
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;
238 append (event);
241 static void
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;
247 append (event);
250 static void
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;
256 append (event);
259 static void
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;
265 append (event);
268 static void
269 queue_architecture_changed (void)
271 struct event *event = XMALLOC (struct event);
272 event->type = architecture_changed;
273 append (event);
276 void
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;
284 xfree (event);
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
289 necessary. */
290 delivering_events = pending_events;
291 pending_events = NULL;
292 while (delivering_events != NULL)
294 struct event *event = delivering_events;
295 switch (event->type)
297 case breakpoint_create:
298 vector->breakpoint_create
299 (event->data.breakpoint_create.b);
300 break;
301 case breakpoint_delete:
302 vector->breakpoint_delete
303 (event->data.breakpoint_delete.b);
304 break;
305 case breakpoint_modify:
306 vector->breakpoint_modify
307 (event->data.breakpoint_modify.b);
308 break;
309 case tracepoint_create:
310 vector->tracepoint_create
311 (event->data.tracepoint_create.number);
312 break;
313 case tracepoint_delete:
314 vector->tracepoint_delete
315 (event->data.tracepoint_delete.number);
316 break;
317 case tracepoint_modify:
318 vector->tracepoint_modify
319 (event->data.tracepoint_modify.number);
320 break;
321 case architecture_changed:
322 vector->architecture_changed ();
323 break;
325 delivering_events = event->next;
326 xfree (event);
330 void _initialize_gdb_events (void);
331 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."),
348 NULL,
349 show_gdb_events_debug,
350 &setdebuglist, &showdebuglist);