3 # User Interface Events.
4 # Copyright 1999, 2000, 2001, 2002 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.
28 # The gdb-events.h/gdb-events.c files this script generates are commited
31 # Any UI module that is installing events is changed so that the
32 # events are installed using the ``set_gdb_events()'' and
33 # ``gdb_event_hooks()'' interfaces. There could prove to be an issue
34 # here with respect to annotate. We might need to accomodate a hook
35 # stack that allows several ui blocks to install their own events.
37 # Each of the variable events (as currently generated) is converted
38 # to either a straight function call or a function call with a
44 read="class returntype function formal actual attrib"
50 # * -> compatibility - pointer variable that is initialized
51 # by set_gdb_events().
52 # ? -> Predicate and function proper.
53 # f -> always call (must have a void returntype)
56 # formal argument list
57 # actual argument list
61 f:void:breakpoint_create:int b:b
62 f:void:breakpoint_delete:int b:b
63 f:void:breakpoint_modify:int b:b
64 f:void:tracepoint_create:int number:number
65 f:void:tracepoint_delete:int number:number
66 f:void:tracepoint_modify:int number:number
67 f:void:architecture_changed:void
68 f:void:target_changed:void
69 f:void:selected_frame_level_changed:int level:level
70 #*:void:annotate_starting_hook:void
71 #*:void:annotate_stopped_hook:void
72 #*:void:annotate_signalled_hook:void
73 #*:void:annotate_signal_hook:void
74 #*:void:annotate_exited_hook:void
75 ##*:void:print_register_hook:int
76 ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR
77 ##*:void:sparc_print_register_hook:int regno:regno
78 #*:void:target_resume_hook:void
79 #*:void:target_wait_loop_hook:void
80 #*:void:init_gdb_hook:char *argv0:argv0
81 #*:void:command_loop_hook:void
82 #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
83 #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror
84 #*:int:query_hook:const char *query, va_list args:query, args
85 #*:void:warning_hook:const char *string, va_list args:string, args
86 #*:void:target_output_hook:char *b:b
87 #*:void:interactive_hook:void
88 #*:void:registers_changed_hook:void
89 #*:void:readline_begin_hook:char *format, ...:format
90 #*:char *:readline_hook:char *prompt:prompt
91 #*:void:readline_end_hook:void
92 #*:int:target_wait_hook:int pid, struct target_waitstatus *status:pid, status
93 #*:void:call_command_hook:struct cmd_list_element *c, char *cmd, int from_tty:c, cmd, from_tty
94 #*:NORETURN void:error_hook:void:: ATTR_NORETURN
95 #*:void:error_begin_hook:void
96 ##*:int:target_architecture_hook:const struct bfd_arch_info *
97 #*:void:exec_file_display_hook:char *filename:filename
98 #*:void:file_changed_hook:char *filename:filename
99 ##*:void:specify_exec_file_hook:
100 #*:int:gdb_load_progress_hook:char *section, unsigned long num:section, num
101 #*:void:pre_add_symbol_hook:char *name:name
102 #*:void:post_add_symbol_hook:void
103 #*:void:selected_frame_level_changed_hook:int level:level
104 #*:int:gdb_loop_hook:int signo:signo
105 ##*:void:solib_create_inferior_hook:void
106 ##*:void:xcoff_relocate_symtab_hook:unsigned int
114 /* User Interface Events.
116 Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
118 Contributed by Cygnus Solutions.
120 This file is part of GDB.
122 This program is free software; you can redistribute it and/or modify
123 it under the terms of the GNU General Public License as published by
124 the Free Software Foundation; either version 2 of the License, or
125 (at your option) any later version.
127 This program is distributed in the hope that it will be useful,
128 but WITHOUT ANY WARRANTY; without even the implied warranty of
129 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130 GNU General Public License for more details.
132 You should have received a copy of the GNU General Public License
133 along with this program; if not, write to the Free Software
134 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
136 /* Work in progress */
138 /* This file was created with the aid of \`\`gdb-events.sh''.
140 The bourn shell script \`\`gdb-events.sh'' creates the files
141 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
142 them against the existing \`\`gdb-events.[hc]''. Any differences
143 found being reported.
145 If editing this file, please also run gdb-events.sh and merge any
146 changes into that script. Conversely, when making sweeping changes
147 to this file, modifying gdb-events.sh and using its output may
157 exec > new-gdb-events.h
164 #ifndef WITH_GDB_EVENTS
165 #define WITH_GDB_EVENTS 1
169 # pointer declarations
173 /* COMPAT: pointer variables for old, unconverted events.
174 A call to set_gdb_events() will automatically update these. */
177 function_list |
while eval read $read
181 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
190 /* Type definition of all hook functions.
191 Recommended pratice is to first declare each hook function using
192 the below ftype and then define it. */
195 function_list |
while eval read $read
197 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
204 /* gdb-events: object. */
207 echo "struct gdb_events"
209 function_list |
while eval read $read
211 echo " gdb_events_${function}_ftype *${function}${attrib};"
215 # function declarations
219 /* Interface into events functions.
220 Where a *_p() predicate is present, it must be called before
221 calling the hook proper. */
223 function_list |
while eval read $read
228 echo "extern int ${function}_p (void);"
229 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
232 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
241 /* When GDB_EVENTS are not being used, completly disable them. */
244 echo "#if !WITH_GDB_EVENTS"
245 function_list |
while eval read $read
250 echo "#define ${function}_event_p() 0"
251 echo "#define ${function}_event(${actual}) 0"
254 echo "#define ${function}_event(${actual}) 0"
263 /* Install custom gdb-events hooks. */
264 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
266 /* Deliver any pending events. */
267 extern void gdb_events_deliver (struct gdb_events *vector);
269 /* Clear event handlers */
270 extern void clear_gdb_event_hooks (void);
273 #define set_gdb_events(x) 0
274 #define set_gdb_event_hooks(x) 0
275 #define gdb_events_deliver(x) 0
283 #../move-if-change new-gdb-events.h gdb-events.h
284 if test -r gdb-events.h
286 diff -c gdb-events.h new-gdb-events.h
289 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
292 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
301 exec > new-gdb-events.c
306 #include "gdb-events.h"
310 static struct gdb_events null_event_hooks;
311 static struct gdb_events queue_event_hooks;
312 static struct gdb_events *current_event_hooks = &null_event_hooks;
315 int gdb_events_debug;
318 # global pointer variables - always have this
320 #function_list | while eval read $read
324 # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
331 echo "#if WITH_GDB_EVENTS"
332 function_list |
while eval read $read
340 ${function}_event_p (${formal})
342 return current_event_hooks->${function};
346 ${function}_event (${formal})
348 return current_events->${function} (${actual});
356 ${function}_event (${formal})
358 if (gdb_events_debug)
359 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
360 if (!current_event_hooks->${function})
362 current_event_hooks->${function} (${actual});
376 set_gdb_event_hooks (struct gdb_events *vector)
378 struct gdb_events *old_events = current_event_hooks;
380 current_event_hooks = &queue_event_hooks;
382 current_event_hooks = vector;
385 function_list |
while eval read $read
389 echo " ${function}_event = hooks->${function};"
398 # Clear hooks function
403 clear_gdb_event_hooks (void)
405 set_gdb_event_hooks (&null_event_hooks);
416 function_list |
while eval read $read
431 function_list |
while eval read $read
437 echo "struct ${function}"
439 echo " `echo ${formal} | tr '[,]' '[;]'`;"
456 function_list |
while eval read $read
462 echo " struct ${function} ${function};"
471 struct event *pending_events;
472 struct event *delivering_events;
479 append (struct event *new_event)
481 struct event **event = &pending_events;
482 while ((*event) != NULL)
483 event = &((*event)->next);
484 (*event) = new_event;
485 (*event)->next = NULL;
489 # schedule a given event
490 function_list |
while eval read $read
496 echo "queue_${function} (${formal})"
498 echo " struct event *event = XMALLOC (struct event);"
499 echo " event->type = ${function};"
500 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
501 echo " event->data.${function}.${arg} = ${arg};"
503 echo " append (event);"
513 gdb_events_deliver (struct gdb_events *vector)
515 /* Just zap any events left around from last time. */
516 while (delivering_events != NULL)
518 struct event *event = delivering_events;
519 delivering_events = event->next;
522 /* Process any pending events. Because one of the deliveries could
523 bail out we move everything off of the pending queue onto an
524 in-progress queue where it can, later, be cleaned up if
526 delivering_events = pending_events;
527 pending_events = NULL;
528 while (delivering_events != NULL)
530 struct event *event = delivering_events;
534 function_list |
while eval read $read
538 echo " case ${function}:"
541 echo " vector->${function}"
544 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
545 ass
="${ass}${sep}event->data.${function}.${arg}"
551 echo " vector->${function} ();"
559 delivering_events = event->next;
565 # Finally the initialization
568 void _initialize_gdb_events (void);
570 _initialize_gdb_events (void)
572 struct cmd_list_element *c;
575 function_list |
while eval read $read
579 echo " queue_event_hooks.${function} = queue_${function};"
586 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
587 (char *) (&gdb_events_debug), "Set event debugging.\n\\
588 When non-zero, event/notify debugging is enabled.", &setlist);
589 deprecate_cmd (c, "set debug event");
590 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
592 add_show_from_set (add_set_cmd ("event",
595 (char *) (&gdb_events_debug),
596 "Set event debugging.\n\\
597 When non-zero, event/notify debugging is enabled.", &setdebuglist),
604 #../move-if-change new-gdb-events.c gdb-events.c
605 # Replace any leading spaces with tabs
606 sed < new-gdb-events.c
> tmp-gdb-events.c \
608 mv tmp-gdb-events.c new-gdb-events.c
610 if test -r gdb-events.c
612 diff -c gdb-events.c new-gdb-events.c
615 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
618 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2