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 f:void:selected_thread_changed:int thread_num:thread_num
71 #*:void:annotate_starting_hook:void
72 #*:void:annotate_stopped_hook:void
73 #*:void:annotate_signalled_hook:void
74 #*:void:annotate_signal_hook:void
75 #*:void:annotate_exited_hook:void
76 ##*:void:print_register_hook:int
77 ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR
78 ##*:void:sparc_print_register_hook:int regno:regno
79 #*:void:target_resume_hook:void
80 #*:void:target_wait_loop_hook:void
81 #*:void:init_gdb_hook:char *argv0:argv0
82 #*:void:command_loop_hook:void
83 #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
84 #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror
85 #*:int:query_hook:const char *query, va_list args:query, args
86 #*:void:warning_hook:const char *string, va_list args:string, args
87 #*:void:target_output_hook:char *b:b
88 #*:void:interactive_hook:void
89 #*:void:registers_changed_hook:void
90 #*:void:readline_begin_hook:char *format, ...:format
91 #*:char *:readline_hook:char *prompt:prompt
92 #*:void:readline_end_hook:void
93 #*:int:target_wait_hook:int pid, struct target_waitstatus *status:pid, status
94 #*:void:call_command_hook:struct cmd_list_element *c, char *cmd, int from_tty:c, cmd, from_tty
95 #*:NORETURN void:error_hook:void:: ATTR_NORETURN
96 #*:void:error_begin_hook:void
97 ##*:int:target_architecture_hook:const struct bfd_arch_info *
98 #*:void:exec_file_display_hook:char *filename:filename
99 #*:void:file_changed_hook:char *filename:filename
100 ##*:void:specify_exec_file_hook:
101 #*:int:gdb_load_progress_hook:char *section, unsigned long num:section, num
102 #*:void:pre_add_symbol_hook:char *name:name
103 #*:void:post_add_symbol_hook:void
104 #*:void:selected_frame_level_changed_hook:int level:level
105 #*:int:gdb_loop_hook:int signo:signo
106 ##*:void:solib_create_inferior_hook:void
107 ##*:void:xcoff_relocate_symtab_hook:unsigned int
115 /* User Interface Events.
117 Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
119 Contributed by Cygnus Solutions.
121 This file is part of GDB.
123 This program is free software; you can redistribute it and/or modify
124 it under the terms of the GNU General Public License as published by
125 the Free Software Foundation; either version 2 of the License, or
126 (at your option) any later version.
128 This program is distributed in the hope that it will be useful,
129 but WITHOUT ANY WARRANTY; without even the implied warranty of
130 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131 GNU General Public License for more details.
133 You should have received a copy of the GNU General Public License
134 along with this program; if not, write to the Free Software
135 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
137 /* Work in progress */
139 /* This file was created with the aid of \`\`gdb-events.sh''.
141 The bourn shell script \`\`gdb-events.sh'' creates the files
142 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
143 them against the existing \`\`gdb-events.[hc]''. Any differences
144 found being reported.
146 If editing this file, please also run gdb-events.sh and merge any
147 changes into that script. Conversely, when making sweeping changes
148 to this file, modifying gdb-events.sh and using its output may
158 exec > new-gdb-events.h
165 #ifndef WITH_GDB_EVENTS
166 #define WITH_GDB_EVENTS 1
170 # pointer declarations
174 /* COMPAT: pointer variables for old, unconverted events.
175 A call to set_gdb_events() will automatically update these. */
178 function_list |
while eval read $read
182 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
191 /* Type definition of all hook functions.
192 Recommended pratice is to first declare each hook function using
193 the below ftype and then define it. */
196 function_list |
while eval read $read
198 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
205 /* gdb-events: object. */
208 echo "struct gdb_events"
210 function_list |
while eval read $read
212 echo " gdb_events_${function}_ftype *${function}${attrib};"
216 # function declarations
220 /* Interface into events functions.
221 Where a *_p() predicate is present, it must be called before
222 calling the hook proper. */
224 function_list |
while eval read $read
229 echo "extern int ${function}_p (void);"
230 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
233 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
242 /* When GDB_EVENTS are not being used, completly disable them. */
245 echo "#if !WITH_GDB_EVENTS"
246 function_list |
while eval read $read
251 echo "#define ${function}_event_p() 0"
252 echo "#define ${function}_event(${actual}) 0"
255 echo "#define ${function}_event(${actual}) 0"
264 /* Install custom gdb-events hooks. */
265 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
267 /* Deliver any pending events. */
268 extern void gdb_events_deliver (struct gdb_events *vector);
270 /* Clear event handlers */
271 extern void clear_gdb_event_hooks (void);
274 #define set_gdb_events(x) 0
275 #define set_gdb_event_hooks(x) 0
276 #define gdb_events_deliver(x) 0
284 #../move-if-change new-gdb-events.h gdb-events.h
285 if test -r gdb-events.h
287 diff -c gdb-events.h new-gdb-events.h
290 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
293 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
302 exec > new-gdb-events.c
307 #include "gdb-events.h"
311 static struct gdb_events null_event_hooks;
312 static struct gdb_events queue_event_hooks;
313 static struct gdb_events *current_event_hooks = &null_event_hooks;
316 int gdb_events_debug;
319 # global pointer variables - always have this
321 #function_list | while eval read $read
325 # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
332 echo "#if WITH_GDB_EVENTS"
333 function_list |
while eval read $read
341 ${function}_event_p (${formal})
343 return current_event_hooks->${function};
347 ${function}_event (${formal})
349 return current_events->${function} (${actual});
357 ${function}_event (${formal})
359 if (gdb_events_debug)
360 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
361 if (!current_event_hooks->${function})
363 current_event_hooks->${function} (${actual});
377 set_gdb_event_hooks (struct gdb_events *vector)
379 struct gdb_events *old_events = current_event_hooks;
381 current_event_hooks = &queue_event_hooks;
383 current_event_hooks = vector;
386 function_list |
while eval read $read
390 echo " ${function}_event = hooks->${function};"
399 # Clear hooks function
404 clear_gdb_event_hooks (void)
406 set_gdb_event_hooks (&null_event_hooks);
417 function_list |
while eval read $read
432 function_list |
while eval read $read
438 echo "struct ${function}"
440 echo " `echo ${formal} | tr '[,]' '[;]'`;"
457 function_list |
while eval read $read
463 echo " struct ${function} ${function};"
472 struct event *pending_events;
473 struct event *delivering_events;
480 append (struct event *new_event)
482 struct event **event = &pending_events;
483 while ((*event) != NULL)
484 event = &((*event)->next);
485 (*event) = new_event;
486 (*event)->next = NULL;
490 # schedule a given event
491 function_list |
while eval read $read
497 echo "queue_${function} (${formal})"
499 echo " struct event *event = XMALLOC (struct event);"
500 echo " event->type = ${function};"
501 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
502 echo " event->data.${function}.${arg} = ${arg};"
504 echo " append (event);"
514 gdb_events_deliver (struct gdb_events *vector)
516 /* Just zap any events left around from last time. */
517 while (delivering_events != NULL)
519 struct event *event = delivering_events;
520 delivering_events = event->next;
523 /* Process any pending events. Because one of the deliveries could
524 bail out we move everything off of the pending queue onto an
525 in-progress queue where it can, later, be cleaned up if
527 delivering_events = pending_events;
528 pending_events = NULL;
529 while (delivering_events != NULL)
531 struct event *event = delivering_events;
535 function_list |
while eval read $read
539 echo " case ${function}:"
542 echo " vector->${function}"
545 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
546 ass
="${ass}${sep}event->data.${function}.${arg}"
552 echo " vector->${function} ();"
560 delivering_events = event->next;
566 # Finally the initialization
569 void _initialize_gdb_events (void);
571 _initialize_gdb_events (void)
573 struct cmd_list_element *c;
576 function_list |
while eval read $read
580 echo " queue_event_hooks.${function} = queue_${function};"
587 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
588 (char *) (&gdb_events_debug), "Set event debugging.\n\\
589 When non-zero, event/notify debugging is enabled.", &setlist);
590 deprecate_cmd (c, "set debug event");
591 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
593 add_show_from_set (add_set_cmd ("event",
596 (char *) (&gdb_events_debug),
597 "Set event debugging.\n\\
598 When non-zero, event/notify debugging is enabled.", &setdebuglist),
605 #../move-if-change new-gdb-events.c gdb-events.c
606 # Replace any leading spaces with tabs
607 sed < new-gdb-events.c
> tmp-gdb-events.c \
609 mv tmp-gdb-events.c new-gdb-events.c
611 if test -r gdb-events.c
613 diff -c gdb-events.c new-gdb-events.c
616 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
619 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2