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, USA.
26 read="class returntype function formal actual attrib"
32 # * -> compatibility - pointer variable that is initialized
33 # by set_gdb_events().
34 # ? -> Predicate and function proper.
35 # f -> always call (must have a void returntype)
38 # formal argument list
39 # actual argument list
43 f:void:breakpoint_create:int b:b
44 f:void:breakpoint_delete:int b:b
45 f:void:breakpoint_modify:int b:b
46 f:void:tracepoint_create:int number:number
47 f:void:tracepoint_delete:int number:number
48 f:void:tracepoint_modify:int number:number
49 f:void:architecture_changed:void
57 /* User Interface Events.
59 Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
61 Contributed by Cygnus Solutions.
63 This file is part of GDB.
65 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
67 the Free Software Foundation; either version 2 of the License, or
68 (at your option) any later version.
70 This program is distributed in the hope that it will be useful,
71 but WITHOUT ANY WARRANTY; without even the implied warranty of
72 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73 GNU General Public License for more details.
75 You should have received a copy of the GNU General Public License
76 along with this program; if not, write to the Free Software
77 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
79 /* Work in progress */
81 /* This file was created with the aid of \`\`gdb-events.sh''.
83 The bourn shell script \`\`gdb-events.sh'' creates the files
84 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
85 them against the existing \`\`gdb-events.[hc]''. Any differences
88 If editing this file, please also run gdb-events.sh and merge any
89 changes into that script. Conversely, when making sweeping changes
90 to this file, modifying gdb-events.sh and using its output may
100 exec > new-gdb-events.h
108 # pointer declarations
112 /* COMPAT: pointer variables for old, unconverted events.
113 A call to set_gdb_events() will automatically update these. */
116 function_list |
while eval read $read
120 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
129 /* Type definition of all hook functions.
130 Recommended pratice is to first declare each hook function using
131 the below ftype and then define it. */
134 function_list |
while eval read $read
136 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
143 /* gdb-events: object. */
146 echo "struct gdb_events"
148 function_list |
while eval read $read
150 echo " gdb_events_${function}_ftype *${function}${attrib};"
154 # function declarations
158 /* Interface into events functions.
159 Where a *_p() predicate is present, it must be called before
160 calling the hook proper. */
162 function_list |
while eval read $read
167 echo "extern int ${function}_p (void);"
168 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
171 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
179 /* Install custom gdb-events hooks. */
180 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
182 /* Deliver any pending events. */
183 extern void gdb_events_deliver (struct gdb_events *vector);
185 /* Clear event handlers */
186 extern void clear_gdb_event_hooks (void);
193 #../move-if-change new-gdb-events.h gdb-events.h
194 if test -r gdb-events.h
196 diff -c gdb-events.h new-gdb-events.h
199 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
202 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
211 exec > new-gdb-events.c
216 #include "gdb-events.h"
219 static struct gdb_events null_event_hooks;
220 static struct gdb_events queue_event_hooks;
221 static struct gdb_events *current_event_hooks = &null_event_hooks;
223 int gdb_events_debug;
227 function_list |
while eval read $read
235 ${function}_event_p (${formal})
237 return current_event_hooks->${function};
241 ${function}_event (${formal})
243 return current_events->${function} (${actual});
251 ${function}_event (${formal})
253 if (gdb_events_debug)
254 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
255 if (!current_event_hooks->${function})
257 current_event_hooks->${function} (${actual});
268 set_gdb_event_hooks (struct gdb_events *vector)
270 struct gdb_events *old_events = current_event_hooks;
272 current_event_hooks = &queue_event_hooks;
274 current_event_hooks = vector;
277 function_list |
while eval read $read
281 echo " ${function}_event = hooks->${function};"
289 # Clear hooks function
293 clear_gdb_event_hooks (void)
295 set_gdb_event_hooks (&null_event_hooks);
305 function_list |
while eval read $read
320 function_list |
while eval read $read
326 echo "struct ${function}"
328 echo " `echo ${formal} | tr '[,]' '[;]'`;"
345 function_list |
while eval read $read
351 echo " struct ${function} ${function};"
360 struct event *pending_events;
361 struct event *delivering_events;
368 append (struct event *new_event)
370 struct event **event = &pending_events;
371 while ((*event) != NULL)
372 event = &((*event)->next);
373 (*event) = new_event;
374 (*event)->next = NULL;
378 # schedule a given event
379 function_list |
while eval read $read
385 echo "queue_${function} (${formal})"
387 echo " struct event *event = XMALLOC (struct event);"
388 echo " event->type = ${function};"
389 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
390 echo " event->data.${function}.${arg} = ${arg};"
392 echo " append (event);"
402 gdb_events_deliver (struct gdb_events *vector)
404 /* Just zap any events left around from last time. */
405 while (delivering_events != NULL)
407 struct event *event = delivering_events;
408 delivering_events = event->next;
411 /* Process any pending events. Because one of the deliveries could
412 bail out we move everything off of the pending queue onto an
413 in-progress queue where it can, later, be cleaned up if
415 delivering_events = pending_events;
416 pending_events = NULL;
417 while (delivering_events != NULL)
419 struct event *event = delivering_events;
423 function_list |
while eval read $read
427 echo " case ${function}:"
430 echo " vector->${function}"
433 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
434 ass
="${ass}${sep}event->data.${function}.${arg}"
440 echo " vector->${function} ();"
448 delivering_events = event->next;
454 # Finally the initialization
457 void _initialize_gdb_events (void);
459 _initialize_gdb_events (void)
461 struct cmd_list_element *c;
463 function_list |
while eval read $read
467 echo " queue_event_hooks.${function} = queue_${function};"
473 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
474 (char *) (&gdb_events_debug), "Set event debugging.\n\\
475 When non-zero, event/notify debugging is enabled.", &setlist);
476 deprecate_cmd (c, "set debug event");
477 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
479 add_show_from_set (add_set_cmd ("event",
482 (char *) (&gdb_events_debug),
483 "Set event debugging.\n\\
484 When non-zero, event/notify debugging is enabled.", &setdebuglist),
491 #../move-if-change new-gdb-events.c gdb-events.c
492 # Replace any leading spaces with tabs
493 sed < new-gdb-events.c
> tmp-gdb-events.c \
495 mv tmp-gdb-events.c new-gdb-events.c
497 if test -r gdb-events.c
499 diff -c gdb-events.c new-gdb-events.c
502 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
505 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2