3 # User Interface Events.
4 # Copyright 1999, 2000, 2001, 2002, 2004 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 read="class returntype function formal actual attrib"
33 # * -> compatibility - pointer variable that is initialized
34 # by set_gdb_events().
35 # ? -> Predicate and function proper.
36 # f -> always call (must have a void returntype)
39 # formal argument list
40 # actual argument list
44 f:void:breakpoint_create:int b:b
45 f:void:breakpoint_delete:int b:b
46 f:void:breakpoint_modify:int b:b
47 f:void:tracepoint_create:int number:number
48 f:void:tracepoint_delete:int number:number
49 f:void:tracepoint_modify:int number:number
50 f:void:architecture_changed:void
58 /* User Interface Events.
60 Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
62 Contributed by Cygnus Solutions.
64 This file is part of GDB.
66 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
68 the Free Software Foundation; either version 2 of the License, or
69 (at your option) any later version.
71 This program is distributed in the hope that it will be useful,
72 but WITHOUT ANY WARRANTY; without even the implied warranty of
73 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 GNU General Public License for more details.
76 You should have received a copy of the GNU General Public License
77 along with this program; if not, write to the Free Software
78 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
80 /* Work in progress */
82 /* This file was created with the aid of \`\`gdb-events.sh''.
84 The bourn shell script \`\`gdb-events.sh'' creates the files
85 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
86 them against the existing \`\`gdb-events.[hc]''. Any differences
89 If editing this file, please also run gdb-events.sh and merge any
90 changes into that script. Conversely, when making sweeping changes
91 to this file, modifying gdb-events.sh and using its output may
101 exec > new-gdb-events.h
109 # pointer declarations
113 /* COMPAT: pointer variables for old, unconverted events.
114 A call to set_gdb_events() will automatically update these. */
117 function_list |
while eval read $read
121 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
130 /* Type definition of all hook functions. Recommended pratice is to
131 first declare each hook function using the below ftype and then
135 function_list |
while eval read $read
137 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
144 /* gdb-events: object. */
147 echo "struct gdb_events"
149 function_list |
while eval read $read
151 echo " gdb_events_${function}_ftype *${function}${attrib};"
155 # function declarations
159 /* Interface into events functions.
160 Where a *_p() predicate is present, it must be called before
161 calling the hook proper. */
163 function_list |
while eval read $read
168 echo "extern int ${function}_p (void);"
169 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
172 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
180 /* Install custom gdb-events hooks. */
181 extern struct gdb_events *deprecated_set_gdb_event_hooks (struct gdb_events *vector);
183 /* Deliver any pending events. */
184 extern void gdb_events_deliver (struct gdb_events *vector);
186 /* Clear event handlers. */
187 extern void clear_gdb_event_hooks (void);
194 #../move-if-change new-gdb-events.h gdb-events.h
195 if test -r gdb-events.h
197 diff -c gdb-events.h new-gdb-events.h
200 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
203 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
212 exec > new-gdb-events.c
217 #include "gdb-events.h"
220 static struct gdb_events null_event_hooks;
221 static struct gdb_events queue_event_hooks;
222 static struct gdb_events *current_event_hooks = &null_event_hooks;
224 int gdb_events_debug;
228 function_list |
while eval read $read
236 ${function}_event_p (${formal})
238 return current_event_hooks->${function};
242 ${function}_event (${formal})
244 return current_events->${function} (${actual});
252 ${function}_event (${formal})
254 if (gdb_events_debug)
255 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
256 if (!current_event_hooks->${function})
258 current_event_hooks->${function} (${actual});
269 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
271 struct gdb_events *old_events = current_event_hooks;
273 current_event_hooks = &queue_event_hooks;
275 current_event_hooks = vector;
278 function_list |
while eval read $read
282 echo " ${function}_event = hooks->${function};"
290 # Clear hooks function
294 clear_gdb_event_hooks (void)
296 deprecated_set_gdb_event_hooks (&null_event_hooks);
306 function_list |
while eval read $read
321 function_list |
while eval read $read
327 echo "struct ${function}"
329 echo " `echo ${formal} | tr '[,]' '[;]'`;"
346 function_list |
while eval read $read
352 echo " struct ${function} ${function};"
361 struct event *pending_events;
362 struct event *delivering_events;
369 append (struct event *new_event)
371 struct event **event = &pending_events;
372 while ((*event) != NULL)
373 event = &((*event)->next);
374 (*event) = new_event;
375 (*event)->next = NULL;
379 # schedule a given event
380 function_list |
while eval read $read
386 echo "queue_${function} (${formal})"
388 echo " struct event *event = XMALLOC (struct event);"
389 echo " event->type = ${function};"
390 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
391 echo " event->data.${function}.${arg} = ${arg};"
393 echo " append (event);"
403 gdb_events_deliver (struct gdb_events *vector)
405 /* Just zap any events left around from last time. */
406 while (delivering_events != NULL)
408 struct event *event = delivering_events;
409 delivering_events = event->next;
412 /* Process any pending events. Because one of the deliveries could
413 bail out we move everything off of the pending queue onto an
414 in-progress queue where it can, later, be cleaned up if
416 delivering_events = pending_events;
417 pending_events = NULL;
418 while (delivering_events != NULL)
420 struct event *event = delivering_events;
424 function_list |
while eval read $read
428 echo " case ${function}:"
431 echo " vector->${function}"
434 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
435 ass
="${ass}${sep}event->data.${function}.${arg}"
441 echo " vector->${function} ();"
449 delivering_events = event->next;
455 # Finally the initialization
458 void _initialize_gdb_events (void);
460 _initialize_gdb_events (void)
462 struct cmd_list_element *c;
464 function_list |
while eval read $read
468 echo " queue_event_hooks.${function} = queue_${function};"
474 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
475 (char *) (&gdb_events_debug), "Set event debugging.\n\\
476 When non-zero, event/notify debugging is enabled.", &setlist);
477 deprecate_cmd (c, "set debug event");
478 deprecate_cmd (deprecated_add_show_from_set (c, &showlist),
481 deprecated_add_show_from_set (add_set_cmd ("event",
484 (char *) (&gdb_events_debug),
485 "Set event debugging.\n\\
486 When non-zero, event/notify debugging is enabled.", &setdebuglist),
493 #../move-if-change new-gdb-events.c gdb-events.c
494 # Replace any leading spaces with tabs
495 sed < new-gdb-events.c
> tmp-gdb-events.c \
497 mv tmp-gdb-events.c new-gdb-events.c
499 if test -r gdb-events.c
501 diff -c gdb-events.c new-gdb-events.c
504 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
507 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2