3 # User Interface Events.
5 # Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008
6 # Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
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 (C) 1999, 2001, 2002, 2004, 2005, 2007
61 Free Software Foundation, Inc.
63 Contributed by Cygnus Solutions.
65 This file is part of GDB.
67 This program is free software; you can redistribute it and/or modify
68 it under the terms of the GNU General Public License as published by
69 the Free Software Foundation; either version 3 of the License, or
70 (at your option) any later version.
72 This program is distributed in the hope that it will be useful,
73 but WITHOUT ANY WARRANTY; without even the implied warranty of
74 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
75 GNU General Public License for more details.
77 You should have received a copy of the GNU General Public License
78 along with this program. If not, see <http://www.gnu.org/licenses/>. */
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;
226 show_gdb_events_debug (struct ui_file *file, int from_tty,
227 struct cmd_list_element *c, const char *value)
229 fprintf_filtered (file, _("Event debugging is %s.\\n"), value);
235 function_list |
while eval read $read
243 ${function}_event_p (${formal})
245 return current_event_hooks->${function};
249 ${function}_event (${formal})
251 return current_events->${function} (${actual});
259 ${function}_event (${formal})
261 if (gdb_events_debug)
262 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
263 if (!current_event_hooks->${function})
265 current_event_hooks->${function} (${actual});
276 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
278 struct gdb_events *old_events = current_event_hooks;
280 current_event_hooks = &queue_event_hooks;
282 current_event_hooks = vector;
285 function_list |
while eval read $read
289 echo " ${function}_event = hooks->${function};"
297 # Clear hooks function
301 clear_gdb_event_hooks (void)
303 deprecated_set_gdb_event_hooks (&null_event_hooks);
313 function_list |
while eval read $read
328 function_list |
while eval read $read
334 echo "struct ${function}"
336 echo " `echo ${formal} | tr '[,]' '[;]'`;"
353 function_list |
while eval read $read
359 echo " struct ${function} ${function};"
368 struct event *pending_events;
369 struct event *delivering_events;
376 append (struct event *new_event)
378 struct event **event = &pending_events;
379 while ((*event) != NULL)
380 event = &((*event)->next);
381 (*event) = new_event;
382 (*event)->next = NULL;
386 # schedule a given event
387 function_list |
while eval read $read
393 echo "queue_${function} (${formal})"
395 echo " struct event *event = XMALLOC (struct event);"
396 echo " event->type = ${function};"
397 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
398 echo " event->data.${function}.${arg} = ${arg};"
400 echo " append (event);"
410 gdb_events_deliver (struct gdb_events *vector)
412 /* Just zap any events left around from last time. */
413 while (delivering_events != NULL)
415 struct event *event = delivering_events;
416 delivering_events = event->next;
419 /* Process any pending events. Because one of the deliveries could
420 bail out we move everything off of the pending queue onto an
421 in-progress queue where it can, later, be cleaned up if
423 delivering_events = pending_events;
424 pending_events = NULL;
425 while (delivering_events != NULL)
427 struct event *event = delivering_events;
431 function_list |
while eval read $read
435 echo " case ${function}:"
438 echo " vector->${function}"
441 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
442 ass
="${ass}${sep}event->data.${function}.${arg}"
448 echo " vector->${function} ();"
456 delivering_events = event->next;
462 # Finally the initialization
465 void _initialize_gdb_events (void);
467 _initialize_gdb_events (void)
469 struct cmd_list_element *c;
471 function_list |
while eval read $read
475 echo " queue_event_hooks.${function} = queue_${function};"
481 add_setshow_zinteger_cmd ("event", class_maintenance,
482 &gdb_events_debug, _("\\
483 Set event debugging."), _("\\
484 Show event debugging."), _("\\
485 When non-zero, event/notify debugging is enabled."),
487 show_gdb_events_debug,
488 &setdebuglist, &showdebuglist);
494 #../move-if-change new-gdb-events.c gdb-events.c
495 # Replace any leading spaces with tabs
496 sed < new-gdb-events.c
> tmp-gdb-events.c \
498 mv tmp-gdb-events.c new-gdb-events.c
500 if test -r gdb-events.c
502 diff -c gdb-events.c new-gdb-events.c
505 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
508 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2