3 # User Interface Events.
5 # Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software
8 # Contributed by Cygnus Solutions.
10 # This file is part of GDB.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 read="class returntype function formal actual attrib"
35 # * -> compatibility - pointer variable that is initialized
36 # by set_gdb_events().
37 # ? -> Predicate and function proper.
38 # f -> always call (must have a void returntype)
41 # formal argument list
42 # actual argument list
46 f:void:breakpoint_create:int b:b
47 f:void:breakpoint_delete:int b:b
48 f:void:breakpoint_modify:int b:b
49 f:void:tracepoint_create:int number:number
50 f:void:tracepoint_delete:int number:number
51 f:void:tracepoint_modify:int number:number
52 f:void:architecture_changed:void
60 /* User Interface Events.
62 Copyright 1999, 2001, 2002, 2004, 2005 Free Software Foundation,
65 Contributed by Cygnus Solutions.
67 This file is part of GDB.
69 This program is free software; you can redistribute it and/or modify
70 it under the terms of the GNU General Public License as published by
71 the Free Software Foundation; either version 2 of the License, or
72 (at your option) any later version.
74 This program is distributed in the hope that it will be useful,
75 but WITHOUT ANY WARRANTY; without even the implied warranty of
76 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77 GNU General Public License for more details.
79 You should have received a copy of the GNU General Public License
80 along with this program; if not, write to the Free Software
81 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
83 /* Work in progress */
85 /* This file was created with the aid of \`\`gdb-events.sh''.
87 The bourn shell script \`\`gdb-events.sh'' creates the files
88 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
89 them against the existing \`\`gdb-events.[hc]''. Any differences
92 If editing this file, please also run gdb-events.sh and merge any
93 changes into that script. Conversely, when making sweeping changes
94 to this file, modifying gdb-events.sh and using its output may
104 exec > new-gdb-events.h
112 # pointer declarations
116 /* COMPAT: pointer variables for old, unconverted events.
117 A call to set_gdb_events() will automatically update these. */
120 function_list |
while eval read $read
124 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
133 /* Type definition of all hook functions. Recommended pratice is to
134 first declare each hook function using the below ftype and then
138 function_list |
while eval read $read
140 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
147 /* gdb-events: object. */
150 echo "struct gdb_events"
152 function_list |
while eval read $read
154 echo " gdb_events_${function}_ftype *${function}${attrib};"
158 # function declarations
162 /* Interface into events functions.
163 Where a *_p() predicate is present, it must be called before
164 calling the hook proper. */
166 function_list |
while eval read $read
171 echo "extern int ${function}_p (void);"
172 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
175 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
183 /* Install custom gdb-events hooks. */
184 extern struct gdb_events *deprecated_set_gdb_event_hooks (struct gdb_events *vector);
186 /* Deliver any pending events. */
187 extern void gdb_events_deliver (struct gdb_events *vector);
189 /* Clear event handlers. */
190 extern void clear_gdb_event_hooks (void);
197 #../move-if-change new-gdb-events.h gdb-events.h
198 if test -r gdb-events.h
200 diff -c gdb-events.h new-gdb-events.h
203 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
206 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
215 exec > new-gdb-events.c
220 #include "gdb-events.h"
223 static struct gdb_events null_event_hooks;
224 static struct gdb_events queue_event_hooks;
225 static struct gdb_events *current_event_hooks = &null_event_hooks;
227 int gdb_events_debug;
229 show_gdb_events_debug (struct ui_file *file, int from_tty,
230 struct cmd_list_element *c, const char *value)
232 fprintf_filtered (file, _("Event debugging is %s.\\n"), value);
238 function_list |
while eval read $read
246 ${function}_event_p (${formal})
248 return current_event_hooks->${function};
252 ${function}_event (${formal})
254 return current_events->${function} (${actual});
262 ${function}_event (${formal})
264 if (gdb_events_debug)
265 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
266 if (!current_event_hooks->${function})
268 current_event_hooks->${function} (${actual});
279 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
281 struct gdb_events *old_events = current_event_hooks;
283 current_event_hooks = &queue_event_hooks;
285 current_event_hooks = vector;
288 function_list |
while eval read $read
292 echo " ${function}_event = hooks->${function};"
300 # Clear hooks function
304 clear_gdb_event_hooks (void)
306 deprecated_set_gdb_event_hooks (&null_event_hooks);
316 function_list |
while eval read $read
331 function_list |
while eval read $read
337 echo "struct ${function}"
339 echo " `echo ${formal} | tr '[,]' '[;]'`;"
356 function_list |
while eval read $read
362 echo " struct ${function} ${function};"
371 struct event *pending_events;
372 struct event *delivering_events;
379 append (struct event *new_event)
381 struct event **event = &pending_events;
382 while ((*event) != NULL)
383 event = &((*event)->next);
384 (*event) = new_event;
385 (*event)->next = NULL;
389 # schedule a given event
390 function_list |
while eval read $read
396 echo "queue_${function} (${formal})"
398 echo " struct event *event = XMALLOC (struct event);"
399 echo " event->type = ${function};"
400 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
401 echo " event->data.${function}.${arg} = ${arg};"
403 echo " append (event);"
413 gdb_events_deliver (struct gdb_events *vector)
415 /* Just zap any events left around from last time. */
416 while (delivering_events != NULL)
418 struct event *event = delivering_events;
419 delivering_events = event->next;
422 /* Process any pending events. Because one of the deliveries could
423 bail out we move everything off of the pending queue onto an
424 in-progress queue where it can, later, be cleaned up if
426 delivering_events = pending_events;
427 pending_events = NULL;
428 while (delivering_events != NULL)
430 struct event *event = delivering_events;
434 function_list |
while eval read $read
438 echo " case ${function}:"
441 echo " vector->${function}"
444 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
445 ass
="${ass}${sep}event->data.${function}.${arg}"
451 echo " vector->${function} ();"
459 delivering_events = event->next;
465 # Finally the initialization
468 void _initialize_gdb_events (void);
470 _initialize_gdb_events (void)
472 struct cmd_list_element *c;
474 function_list |
while eval read $read
478 echo " queue_event_hooks.${function} = queue_${function};"
484 add_setshow_zinteger_cmd ("event", class_maintenance,
485 &gdb_events_debug, _("\\
486 Set event debugging."), _("\\
487 Show event debugging."), _("\\
488 When non-zero, event/notify debugging is enabled."),
490 show_gdb_events_debug,
491 &setdebuglist, &showdebuglist);
497 #../move-if-change new-gdb-events.c gdb-events.c
498 # Replace any leading spaces with tabs
499 sed < new-gdb-events.c
> tmp-gdb-events.c \
501 mv tmp-gdb-events.c new-gdb-events.c
503 if test -r gdb-events.c
505 diff -c gdb-events.c new-gdb-events.c
508 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
511 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2