3 # User Interface Events.
4 # Copyright 1999-2000 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 converteded
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 #*:void:annotate_starting_hook:void
65 #*:void:annotate_stopped_hook:void
66 #*:void:annotate_signalled_hook:void
67 #*:void:annotate_signal_hook:void
68 #*:void:annotate_exited_hook:void
69 ##*:void:print_register_hook:int
70 ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR
71 ##*:void:sparc_print_register_hook:int regno:regno
72 #*:void:target_resume_hook:void
73 #*:void:target_wait_loop_hook:void
74 #*:void:init_gdb_hook:char *argv0:argv0
75 #*:void:command_loop_hook:void
76 #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
77 #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror
78 #*:int:query_hook:const char *query, va_list args:query, args
79 #*:void:warning_hook:const char *string, va_list args:string, args
80 #*:void:target_output_hook:char *b:b
81 #*:void:interactive_hook:void
82 #*:void:registers_changed_hook:void
83 #*:void:readline_begin_hook:char *format, ...:format
84 #*:char *:readline_hook:char *prompt:prompt
85 #*:void:readline_end_hook:void
86 #*:void:register_changed_hook:int regno:regno
87 #*:void:memory_changed_hook:CORE_ADDR addr, int len:addr, len
88 #*:void:context_hook:int num:num
89 #*:int:target_wait_hook:int pid, struct target_waitstatus *status:pid, status
90 #*:void:call_command_hook:struct cmd_list_element *c, char *cmd, int from_tty:c, cmd, from_tty
91 #*:NORETURN void:error_hook:void:: ATTR_NORETURN
92 #*:void:error_begin_hook:void
93 ##*:int:target_architecture_hook:const struct bfd_arch_info *
94 #*:void:exec_file_display_hook:char *filename:filename
95 #*:void:file_changed_hook:char *filename:filename
96 ##*:void:specify_exec_file_hook:
97 #*:int:gdb_load_progress_hook:char *section, unsigned long num:section, num
98 #*:void:pre_add_symbol_hook:char *name:name
99 #*:void:post_add_symbol_hook:void
100 #*:void:selected_frame_level_changed_hook:int level:level
101 #*:int:gdb_loop_hook:int signo:signo
102 ##*:void:solib_create_inferior_hook:void
103 ##*:void:xcoff_relocate_symtab_hook:unsigned int
111 /* User Interface Events.
112 Copyright 1999 Free Software Foundation, Inc.
114 Contributed by Cygnus Solutions.
116 This file is part of GDB.
118 This program is free software; you can redistribute it and/or modify
119 it under the terms of the GNU General Public License as published by
120 the Free Software Foundation; either version 2 of the License, or
121 (at your option) any later version.
123 This program is distributed in the hope that it will be useful,
124 but WITHOUT ANY WARRANTY; without even the implied warranty of
125 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126 GNU General Public License for more details.
128 You should have received a copy of the GNU General Public License
129 along with this program; if not, write to the Free Software
130 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
132 /* Work in progress */
134 /* This file was created with the aid of \`\`gdb-events.sh''.
136 The bourn shell script \`\`gdb-events.sh'' creates the files
137 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
138 them against the existing \`\`gdb-events.[hc]''. Any differences
139 found being reported.
141 If editing this file, please also run gdb-events.sh and merge any
142 changes into that script. Conversely, when making sweeping changes
143 to this file, modifying gdb-events.sh and using its output may
153 exec > new-gdb-events.h
160 #ifndef WITH_GDB_EVENTS
161 #define WITH_GDB_EVENTS 1
165 # pointer declarations
169 /* COMPAT: pointer variables for old, unconverted events.
170 A call to set_gdb_events() will automatically update these. */
173 function_list |
while eval read $read
177 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
186 /* Type definition of all hook functions.
187 Recommended pratice is to first declare each hook function using
188 the below ftype and then define it. */
191 function_list |
while eval read $read
193 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
200 /* gdb-events: object. */
203 echo "struct gdb_events"
205 function_list |
while eval read $read
207 echo " gdb_events_${function}_ftype *${function}${attrib};"
211 # function declarations
215 /* Interface into events functions.
216 Where a *_p() predicate is present, it must be called before
217 calling the hook proper. */
219 function_list |
while eval read $read
224 echo "extern int ${function}_p (void);"
225 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
228 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
237 /* When GDB_EVENTS are not being used, completly disable them. */
240 echo "#if !WITH_GDB_EVENTS"
241 function_list |
while eval read $read
246 echo "#define ${function}_event_p() 0"
247 echo "#define ${function}_event(${actual}) 0"
250 echo "#define ${function}_event(${actual}) 0"
259 /* Install custom gdb-events hooks. */
260 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
262 /* Deliver any pending events. */
263 extern void gdb_events_deliver (struct gdb_events *vector);
266 #define set_gdb_events(x) 0
267 #define set_gdb_event_hooks(x) 0
268 #define gdb_events_deliver(x) 0
276 #../move-if-change new-gdb-events.h gdb-events.h
277 if ! test -r gdb-events.h
279 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
280 elif ! diff -c gdb-events.h new-gdb-events.h
282 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
291 exec > new-gdb-events.c
296 #include "gdb-events.h"
300 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
303 static struct gdb_events null_event_hooks;
304 static struct gdb_events queue_event_hooks;
305 static struct gdb_events *current_event_hooks = &null_event_hooks;
308 int gdb_events_debug;
311 # global pointer variables - always have this
313 #function_list | while eval read $read
317 # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
324 echo "#if WITH_GDB_EVENTS"
325 function_list |
while eval read $read
332 echo "${function}_event_p (${formal})"
334 echo " return current_event_hooks->${function};"
338 echo "${function}_event (${formal})"
340 echo " return current_events->${function} (${actual});"
346 echo "${function}_event (${formal})"
348 echo " if (gdb_events_debug)"
349 echo " fprintf_unfiltered (gdb_stdlog, \"${function}_event\\n\");"
350 echo " if (!current_event_hooks->${function})"
352 echo " current_event_hooks->${function} (${actual});"
365 set_gdb_event_hooks (struct gdb_events *vector)
367 struct gdb_events *old_events = current_event_hooks;
369 current_event_hooks = &queue_event_hooks;
371 current_event_hooks = vector;
374 function_list |
while eval read $read
378 echo " ${function}_event = hooks->${function};"
393 function_list |
while eval read $read
408 function_list |
while eval read $read
412 echo "struct ${function}"
414 echo " `echo ${formal} | tr '[,]' '[;]'`;"
430 function_list |
while eval read $read
434 echo " struct ${function} ${function};"
442 struct event *pending_events;
443 struct event *delivering_events;
450 append (struct event *new_event)
452 struct event **event = &pending_events;
453 while ((*event) != NULL)
454 event = &((*event)->next);
455 (*event) = new_event;
456 (*event)->next = NULL;
460 # schedule a given event
461 function_list |
while eval read $read
467 echo "queue_${function} (${formal})"
469 echo " struct event *event = XMALLOC (struct event);"
470 echo " event->type = ${function};"
471 for arg
in `echo ${actual} | tr '[,]' '[ ]'`; do
472 echo " event->data.${function}.${arg} = ${arg};"
474 echo " append (event);"
484 gdb_events_deliver (struct gdb_events *vector)
486 /* Just zap any events left around from last time. */
487 while (delivering_events != NULL)
489 struct event *event = delivering_events;
490 delivering_events = event->next;
493 /* Process any pending events. Because one of the deliveries could
494 bail out we move everything off of the pending queue onto an
495 in-progress queue where it can, later, be cleaned up if
497 delivering_events = pending_events;
498 pending_events = NULL;
499 while (delivering_events != NULL)
501 struct event *event = delivering_events;
505 function_list |
while eval read $read
509 echo " case ${function}:"
510 echo " vector->${function}"
513 for arg
in `echo ${actual} | tr '[,]' '[ ]'`; do
514 ass
="${ass}${sep}event->data.${function}.${arg}"
525 delivering_events = event->next;
531 # Finally the initialization
534 void _initialize_gdb_events (void);
536 _initialize_gdb_events (void)
538 struct cmd_list_element *c;
541 function_list |
while eval read $read
545 echo " queue_event_hooks.${function} = queue_${function};"
552 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
553 (char *) (&gdb_events_debug), "Set event debugging.\n\\
554 When non-zero, event/notify debugging is enabled.", &setlist);
555 deprecate_cmd (c, "set debug event");
556 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
558 add_show_from_set (add_set_cmd ("event",
561 (char *) (&gdb_events_debug),
562 "Set event debugging.\n\\
563 When non-zero, event/notify debugging is enabled.", &setdebuglist),
570 #../move-if-change new-gdb-events.c gdb-events.c
571 # Replace any leading spaces with tabs
572 sed < new-gdb-events.c
> tmp-gdb-events.c \
574 mv tmp-gdb-events.c new-gdb-events.c
576 if ! test -r gdb-events.c
578 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2
579 elif ! diff -c gdb-events.c new-gdb-events.c
581 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2