3 # User Interface Events.
5 # Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007
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 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., 51 Franklin Street, Fifth Floor,
25 # Boston, MA 02110-1301, USA.
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 (C) 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., 51 Franklin Street, Fifth Floor,
82 Boston, MA 02110-1301, USA. */
84 /* Work in progress */
86 /* This file was created with the aid of \`\`gdb-events.sh''.
88 The bourn shell script \`\`gdb-events.sh'' creates the files
89 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
90 them against the existing \`\`gdb-events.[hc]''. Any differences
93 If editing this file, please also run gdb-events.sh and merge any
94 changes into that script. Conversely, when making sweeping changes
95 to this file, modifying gdb-events.sh and using its output may
105 exec > new-gdb-events.h
113 # pointer declarations
117 /* COMPAT: pointer variables for old, unconverted events.
118 A call to set_gdb_events() will automatically update these. */
121 function_list | while eval read $read
125 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
134 /* Type definition of all hook functions. Recommended pratice is to
135 first declare each hook function using the below ftype and then
139 function_list | while eval read $read
141 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
148 /* gdb-events: object. */
151 echo "struct gdb_events"
153 function_list | while eval read $read
155 echo " gdb_events_${function}_ftype *${function}${attrib};"
159 # function declarations
163 /* Interface into events functions.
164 Where a *_p() predicate is present, it must be called before
165 calling the hook proper. */
167 function_list | while eval read $read
172 echo "extern int ${function}_p (void);"
173 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
176 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
184 /* Install custom gdb-events hooks. */
185 extern struct gdb_events *deprecated_set_gdb_event_hooks (struct gdb_events *vector);
187 /* Deliver any pending events. */
188 extern void gdb_events_deliver (struct gdb_events *vector);
190 /* Clear event handlers. */
191 extern void clear_gdb_event_hooks (void);
198 #../move-if-change new-gdb-events.h gdb-events.h
199 if test -r gdb-events.h
201 diff -c gdb-events.h new-gdb-events.h
204 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
207 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
216 exec > new-gdb-events.c
221 #include "gdb-events.h"
224 static struct gdb_events null_event_hooks;
225 static struct gdb_events queue_event_hooks;
226 static struct gdb_events *current_event_hooks = &null_event_hooks;
228 int gdb_events_debug;
230 show_gdb_events_debug (struct ui_file *file, int from_tty,
231 struct cmd_list_element *c, const char *value)
233 fprintf_filtered (file, _("Event debugging is %s.\\n"), value);
239 function_list | while eval read $read
247 ${function}_event_p (${formal})
249 return current_event_hooks->${function};
253 ${function}_event (${formal})
255 return current_events->${function} (${actual});
263 ${function}_event (${formal})
265 if (gdb_events_debug)
266 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
267 if (!current_event_hooks->${function})
269 current_event_hooks->${function} (${actual});
280 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
282 struct gdb_events *old_events = current_event_hooks;
284 current_event_hooks = &queue_event_hooks;
286 current_event_hooks = vector;
289 function_list | while eval read $read
293 echo " ${function}_event = hooks->${function};"
301 # Clear hooks function
305 clear_gdb_event_hooks (void)
307 deprecated_set_gdb_event_hooks (&null_event_hooks);
317 function_list | while eval read $read
332 function_list | while eval read $read
338 echo "struct ${function}"
340 echo " `echo ${formal} | tr '[,]' '[;]'`;"
357 function_list | while eval read $read
363 echo " struct ${function} ${function};"
372 struct event *pending_events;
373 struct event *delivering_events;
380 append (struct event *new_event)
382 struct event **event = &pending_events;
383 while ((*event) != NULL)
384 event = &((*event)->next);
385 (*event) = new_event;
386 (*event)->next = NULL;
390 # schedule a given event
391 function_list | while eval read $read
397 echo "queue_${function} (${formal})"
399 echo " struct event *event = XMALLOC (struct event);"
400 echo " event->type = ${function};"
401 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
402 echo " event->data.${function}.${arg} = ${arg};"
404 echo " append (event);"
414 gdb_events_deliver (struct gdb_events *vector)
416 /* Just zap any events left around from last time. */
417 while (delivering_events != NULL)
419 struct event *event = delivering_events;
420 delivering_events = event->next;
423 /* Process any pending events. Because one of the deliveries could
424 bail out we move everything off of the pending queue onto an
425 in-progress queue where it can, later, be cleaned up if
427 delivering_events = pending_events;
428 pending_events = NULL;
429 while (delivering_events != NULL)
431 struct event *event = delivering_events;
435 function_list | while eval read $read
439 echo " case ${function}:"
442 echo " vector->${function}"
445 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
446 ass="${ass}${sep}event->data.${function}.${arg}"
452 echo " vector->${function} ();"
460 delivering_events = event->next;
466 # Finally the initialization
469 void _initialize_gdb_events (void);
471 _initialize_gdb_events (void)
473 struct cmd_list_element *c;
475 function_list | while eval read $read
479 echo " queue_event_hooks.${function} = queue_${function};"
485 add_setshow_zinteger_cmd ("event", class_maintenance,
486 &gdb_events_debug, _("\\
487 Set event debugging."), _("\\
488 Show event debugging."), _("\\
489 When non-zero, event/notify debugging is enabled."),
491 show_gdb_events_debug,
492 &setdebuglist, &showdebuglist);
498 #../move-if-change new-gdb-events.c gdb-events.c
499 # Replace any leading spaces with tabs
500 sed < new-gdb-events.c > tmp-gdb-events.c \
502 mv tmp-gdb-events.c new-gdb-events.c
504 if test -r gdb-events.c
506 diff -c gdb-events.c new-gdb-events.c
509 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
512 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2