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;
231 function_list | while eval read $read
239 ${function}_event_p (${formal})
241 return current_event_hooks->${function};
245 ${function}_event (${formal})
247 return current_events->${function} (${actual});
255 ${function}_event (${formal})
257 if (gdb_events_debug)
258 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
259 if (!current_event_hooks->${function})
261 current_event_hooks->${function} (${actual});
272 deprecated_set_gdb_event_hooks (struct gdb_events *vector)
274 struct gdb_events *old_events = current_event_hooks;
276 current_event_hooks = &queue_event_hooks;
278 current_event_hooks = vector;
281 function_list | while eval read $read
285 echo " ${function}_event = hooks->${function};"
293 # Clear hooks function
297 clear_gdb_event_hooks (void)
299 deprecated_set_gdb_event_hooks (&null_event_hooks);
309 function_list | while eval read $read
324 function_list | while eval read $read
330 echo "struct ${function}"
332 echo " `echo ${formal} | tr '[,]' '[;]'`;"
349 function_list | while eval read $read
355 echo " struct ${function} ${function};"
364 struct event *pending_events;
365 struct event *delivering_events;
372 append (struct event *new_event)
374 struct event **event = &pending_events;
375 while ((*event) != NULL)
376 event = &((*event)->next);
377 (*event) = new_event;
378 (*event)->next = NULL;
382 # schedule a given event
383 function_list | while eval read $read
389 echo "queue_${function} (${formal})"
391 echo " struct event *event = XMALLOC (struct event);"
392 echo " event->type = ${function};"
393 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
394 echo " event->data.${function}.${arg} = ${arg};"
396 echo " append (event);"
406 gdb_events_deliver (struct gdb_events *vector)
408 /* Just zap any events left around from last time. */
409 while (delivering_events != NULL)
411 struct event *event = delivering_events;
412 delivering_events = event->next;
415 /* Process any pending events. Because one of the deliveries could
416 bail out we move everything off of the pending queue onto an
417 in-progress queue where it can, later, be cleaned up if
419 delivering_events = pending_events;
420 pending_events = NULL;
421 while (delivering_events != NULL)
423 struct event *event = delivering_events;
427 function_list | while eval read $read
431 echo " case ${function}:"
434 echo " vector->${function}"
437 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
438 ass="${ass}${sep}event->data.${function}.${arg}"
444 echo " vector->${function} ();"
452 delivering_events = event->next;
458 # Finally the initialization
461 void _initialize_gdb_events (void);
463 _initialize_gdb_events (void)
465 struct cmd_list_element *c;
467 function_list | while eval read $read
471 echo " queue_event_hooks.${function} = queue_${function};"
477 deprecated_add_show_from_set (add_set_cmd ("event",
480 (char *) (&gdb_events_debug),
481 "Set event debugging.\n\\
482 When non-zero, event/notify debugging is enabled.", &setdebuglist),
489 #../move-if-change new-gdb-events.c gdb-events.c
490 # Replace any leading spaces with tabs
491 sed < new-gdb-events.c > tmp-gdb-events.c \
493 mv tmp-gdb-events.c new-gdb-events.c
495 if test -r gdb-events.c
497 diff -c gdb-events.c new-gdb-events.c
500 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
503 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2