3 # User Interface Events.
4 # Copyright 1999, 2000, 2001 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 #*:void:annotate_starting_hook:void
68 #*:void:annotate_stopped_hook:void
69 #*:void:annotate_signalled_hook:void
70 #*:void:annotate_signal_hook:void
71 #*:void:annotate_exited_hook:void
72 ##*:void:print_register_hook:int
73 ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR
74 ##*:void:sparc_print_register_hook:int regno:regno
75 #*:void:target_resume_hook:void
76 #*:void:target_wait_loop_hook:void
77 #*:void:init_gdb_hook:char *argv0:argv0
78 #*:void:command_loop_hook:void
79 #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
80 #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror
81 #*:int:query_hook:const char *query, va_list args:query, args
82 #*:void:warning_hook:const char *string, va_list args:string, args
83 #*:void:target_output_hook:char *b:b
84 #*:void:interactive_hook:void
85 #*:void:registers_changed_hook:void
86 #*:void:readline_begin_hook:char *format, ...:format
87 #*:char *:readline_hook:char *prompt:prompt
88 #*:void:readline_end_hook:void
89 #*:void:register_changed_hook:int regno:regno
90 #*:void:memory_changed_hook:CORE_ADDR addr, int len:addr, len
91 #*:void:context_hook:int num:num
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.
115 Copyright 1999, 2001 Free Software Foundation, Inc.
117 Contributed by Cygnus Solutions.
119 This file is part of GDB.
121 This program is free software; you can redistribute it and/or modify
122 it under the terms of the GNU General Public License as published by
123 the Free Software Foundation; either version 2 of the License, or
124 (at your option) any later version.
126 This program is distributed in the hope that it will be useful,
127 but WITHOUT ANY WARRANTY; without even the implied warranty of
128 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129 GNU General Public License for more details.
131 You should have received a copy of the GNU General Public License
132 along with this program; if not, write to the Free Software
133 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
135 /* Work in progress */
137 /* This file was created with the aid of \`\`gdb-events.sh''.
139 The bourn shell script \`\`gdb-events.sh'' creates the files
140 \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares
141 them against the existing \`\`gdb-events.[hc]''. Any differences
142 found being reported.
144 If editing this file, please also run gdb-events.sh and merge any
145 changes into that script. Conversely, when making sweeping changes
146 to this file, modifying gdb-events.sh and using its output may
156 exec > new-gdb-events.h
163 #ifndef WITH_GDB_EVENTS
164 #define WITH_GDB_EVENTS 1
168 # pointer declarations
172 /* COMPAT: pointer variables for old, unconverted events.
173 A call to set_gdb_events() will automatically update these. */
176 function_list |
while eval read $read
180 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
189 /* Type definition of all hook functions.
190 Recommended pratice is to first declare each hook function using
191 the below ftype and then define it. */
194 function_list |
while eval read $read
196 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
203 /* gdb-events: object. */
206 echo "struct gdb_events"
208 function_list |
while eval read $read
210 echo " gdb_events_${function}_ftype *${function}${attrib};"
214 # function declarations
218 /* Interface into events functions.
219 Where a *_p() predicate is present, it must be called before
220 calling the hook proper. */
222 function_list |
while eval read $read
227 echo "extern int ${function}_p (void);"
228 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
231 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
240 /* When GDB_EVENTS are not being used, completly disable them. */
243 echo "#if !WITH_GDB_EVENTS"
244 function_list |
while eval read $read
249 echo "#define ${function}_event_p() 0"
250 echo "#define ${function}_event(${actual}) 0"
253 echo "#define ${function}_event(${actual}) 0"
262 /* Install custom gdb-events hooks. */
263 extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
265 /* Deliver any pending events. */
266 extern void gdb_events_deliver (struct gdb_events *vector);
269 #define set_gdb_events(x) 0
270 #define set_gdb_event_hooks(x) 0
271 #define gdb_events_deliver(x) 0
279 #../move-if-change new-gdb-events.h gdb-events.h
280 if test -r gdb-events.h
282 diff -c gdb-events.h new-gdb-events.h
285 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
288 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
297 exec > new-gdb-events.c
302 #include "gdb-events.h"
306 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
309 static struct gdb_events null_event_hooks;
310 static struct gdb_events queue_event_hooks;
311 static struct gdb_events *current_event_hooks = &null_event_hooks;
314 int gdb_events_debug;
317 # global pointer variables - always have this
319 #function_list | while eval read $read
323 # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
330 echo "#if WITH_GDB_EVENTS"
331 function_list |
while eval read $read
339 ${function}_event_p (${formal})
341 return current_event_hooks->${function};
345 ${function}_event (${formal})
347 return current_events->${function} (${actual});
355 ${function}_event (${formal})
357 if (gdb_events_debug)
358 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
359 if (!current_event_hooks->${function})
361 current_event_hooks->${function} (${actual});
375 set_gdb_event_hooks (struct gdb_events *vector)
377 struct gdb_events *old_events = current_event_hooks;
379 current_event_hooks = &queue_event_hooks;
381 current_event_hooks = vector;
384 function_list |
while eval read $read
388 echo " ${function}_event = hooks->${function};"
403 function_list |
while eval read $read
418 function_list |
while eval read $read
422 echo "struct ${function}"
424 echo " `echo ${formal} | tr '[,]' '[;]'`;"
440 function_list |
while eval read $read
444 echo " struct ${function} ${function};"
452 struct event *pending_events;
453 struct event *delivering_events;
460 append (struct event *new_event)
462 struct event **event = &pending_events;
463 while ((*event) != NULL)
464 event = &((*event)->next);
465 (*event) = new_event;
466 (*event)->next = NULL;
470 # schedule a given event
471 function_list |
while eval read $read
477 echo "queue_${function} (${formal})"
479 echo " struct event *event = XMALLOC (struct event);"
480 echo " event->type = ${function};"
481 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
482 echo " event->data.${function}.${arg} = ${arg};"
484 echo " append (event);"
494 gdb_events_deliver (struct gdb_events *vector)
496 /* Just zap any events left around from last time. */
497 while (delivering_events != NULL)
499 struct event *event = delivering_events;
500 delivering_events = event->next;
503 /* Process any pending events. Because one of the deliveries could
504 bail out we move everything off of the pending queue onto an
505 in-progress queue where it can, later, be cleaned up if
507 delivering_events = pending_events;
508 pending_events = NULL;
509 while (delivering_events != NULL)
511 struct event *event = delivering_events;
515 function_list |
while eval read $read
519 echo " case ${function}:"
520 echo " vector->${function}"
523 for arg
in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
524 ass
="${ass}${sep}event->data.${function}.${arg}"
535 delivering_events = event->next;
541 # Finally the initialization
544 void _initialize_gdb_events (void);
546 _initialize_gdb_events (void)
548 struct cmd_list_element *c;
551 function_list |
while eval read $read
555 echo " queue_event_hooks.${function} = queue_${function};"
562 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
563 (char *) (&gdb_events_debug), "Set event debugging.\n\\
564 When non-zero, event/notify debugging is enabled.", &setlist);
565 deprecate_cmd (c, "set debug event");
566 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
568 add_show_from_set (add_set_cmd ("event",
571 (char *) (&gdb_events_debug),
572 "Set event debugging.\n\\
573 When non-zero, event/notify debugging is enabled.", &setdebuglist),
580 #../move-if-change new-gdb-events.c gdb-events.c
581 # Replace any leading spaces with tabs
582 sed < new-gdb-events.c
> tmp-gdb-events.c \
584 mv tmp-gdb-events.c new-gdb-events.c
586 if test -r gdb-events.c
588 diff -c gdb-events.c new-gdb-events.c
591 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
594 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2