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
50 f:void:target_changed:void
51 f:void:selected_frame_level_changed:int level:level
52 f:void:selected_thread_changed:int thread_num:thread_num
60 /* User Interface Events.
62 Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
64 Contributed by Cygnus Solutions.
66 This file is part of GDB.
68 This program is free software; you can redistribute it and/or modify
69 it under the terms of the GNU General Public License as published by
70 the Free Software Foundation; either version 2 of the License, or
71 (at your option) any later version.
73 This program is distributed in the hope that it will be useful,
74 but WITHOUT ANY WARRANTY; without even the implied warranty of
75 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 GNU General Public License for more details.
78 You should have received a copy of the GNU General Public License
79 along with this program; if not, write to the Free Software
80 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
82 /* Work in progress */
84 /* This file was created with the aid of \`\`gdb-events.sh''.
86 The bourn shell script \`\`gdb-events.sh'' creates the files
87 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
88 them against the existing \`\`gdb-events.[hc]''. Any differences
91 If editing this file, please also run gdb-events.sh and merge any
92 changes into that script. Conversely, when making sweeping changes
93 to this file, modifying gdb-events.sh and using its output may
103 exec > new-gdb-events.h
111 # pointer declarations
115 /* COMPAT: pointer variables for old, unconverted events.
116 A call to set_gdb_events() will automatically update these. */
119 function_list | while eval read $read
123 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
132 /* Type definition of all hook functions.
133 Recommended pratice is to first declare each hook function using
134 the below ftype and then define it. */
137 function_list | while eval read $read
139 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
146 /* gdb-events: object. */
149 echo "struct gdb_events"
151 function_list | while eval read $read
153 echo " gdb_events_${function}_ftype *${function}${attrib};"
157 # function declarations
161 /* Interface into events functions.
162 Where a *_p() predicate is present, it must be called before
163 calling the hook proper. */
165 function_list | while eval read $read
170 echo "extern int ${function}_p (void);"
171 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
174 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
182 /* Install custom gdb-events hooks. */
183 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
185 /* Deliver any pending events. */
186 extern void gdb_events_deliver (struct gdb_events *vector);
188 /* Clear event handlers */
189 extern void clear_gdb_event_hooks (void);
196 #../move-if-change new-gdb-events.h gdb-events.h
197 if test -r gdb-events.h
199 diff -c gdb-events.h new-gdb-events.h
202 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
205 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
214 exec > new-gdb-events.c
219 #include "gdb-events.h"
222 static struct gdb_events null_event_hooks;
223 static struct gdb_events queue_event_hooks;
224 static struct gdb_events *current_event_hooks = &null_event_hooks;
226 int gdb_events_debug;
230 function_list | while eval read $read
238 ${function}_event_p (${formal})
240 return current_event_hooks->${function};
244 ${function}_event (${formal})
246 return current_events->${function} (${actual});
254 ${function}_event (${formal})
256 if (gdb_events_debug)
257 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
258 if (!current_event_hooks->${function})
260 current_event_hooks->${function} (${actual});
271 set_gdb_event_hooks (struct gdb_events *vector)
273 struct gdb_events *old_events = current_event_hooks;
275 current_event_hooks = &queue_event_hooks;
277 current_event_hooks = vector;
280 function_list | while eval read $read
284 echo " ${function}_event = hooks->${function};"
292 # Clear hooks function
296 clear_gdb_event_hooks (void)
298 set_gdb_event_hooks (&null_event_hooks);
308 function_list | while eval read $read
323 function_list | while eval read $read
329 echo "struct ${function}"
331 echo " `echo ${formal} | tr '[,]' '[;]'`;"
348 function_list | while eval read $read
354 echo " struct ${function} ${function};"
363 struct event *pending_events;
364 struct event *delivering_events;
371 append (struct event *new_event)
373 struct event **event = &pending_events;
374 while ((*event) != NULL)
375 event = &((*event)->next);
376 (*event) = new_event;
377 (*event)->next = NULL;
381 # schedule a given event
382 function_list | while eval read $read
388 echo "queue_${function} (${formal})"
390 echo " struct event *event = XMALLOC (struct event);"
391 echo " event->type = ${function};"
392 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
393 echo " event->data.${function}.${arg} = ${arg};"
395 echo " append (event);"
405 gdb_events_deliver (struct gdb_events *vector)
407 /* Just zap any events left around from last time. */
408 while (delivering_events != NULL)
410 struct event *event = delivering_events;
411 delivering_events = event->next;
414 /* Process any pending events. Because one of the deliveries could
415 bail out we move everything off of the pending queue onto an
416 in-progress queue where it can, later, be cleaned up if
418 delivering_events = pending_events;
419 pending_events = NULL;
420 while (delivering_events != NULL)
422 struct event *event = delivering_events;
426 function_list | while eval read $read
430 echo " case ${function}:"
433 echo " vector->${function}"
436 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
437 ass="${ass}${sep}event->data.${function}.${arg}"
443 echo " vector->${function} ();"
451 delivering_events = event->next;
457 # Finally the initialization
460 void _initialize_gdb_events (void);
462 _initialize_gdb_events (void)
464 struct cmd_list_element *c;
466 function_list | while eval read $read
470 echo " queue_event_hooks.${function} = queue_${function};"
476 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
477 (char *) (&gdb_events_debug), "Set event debugging.\n\\
478 When non-zero, event/notify debugging is enabled.", &setlist);
479 deprecate_cmd (c, "set debug event");
480 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
482 add_show_from_set (add_set_cmd ("event",
485 (char *) (&gdb_events_debug),
486 "Set event debugging.\n\\
487 When non-zero, event/notify debugging is enabled.", &setdebuglist),
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