* config/i386/tm-i386.h (PARM_BOUNDARY, CALL_DUMMY,
[deliverable/binutils-gdb.git] / gdb / gdb-events.sh
CommitLineData
104c1213
JM
1#!/bin/sh
2
3# User Interface Events.
349c5d5f 4# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
104c1213
JM
5#
6# Contributed by Cygnus Solutions.
7#
8# This file is part of GDB.
9#
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.
14#
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.
19#
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.
23
24#
25# What happens next:
26#
27
28# The gdb-events.h/gdb-events.c files this script generates are commited
29# and published.
30
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.
36
4b3cb714 37# Each of the variable events (as currently generated) is converted
104c1213
JM
38# to either a straight function call or a function call with a
39# predicate.
40
41
42IFS=:
43
44read="class returntype function formal actual attrib"
45
46function_list ()
47{
48 # category:
49 # # -> disable
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)
54 # return-type
55 # name
56 # formal argument list
57 # actual argument list
58 # attributes
59 # description
60 cat <<EOF |
61f:void:breakpoint_create:int b:b
62f:void:breakpoint_delete:int b:b
63f:void:breakpoint_modify:int b:b
ba9fe036
KS
64f:void:tracepoint_create:int number:number
65f:void:tracepoint_delete:int number:number
66f:void:tracepoint_modify:int number:number
67c2c32c 67f:void:architecture_changed:void
104c1213
JM
68#*:void:annotate_starting_hook:void
69#*:void:annotate_stopped_hook:void
70#*:void:annotate_signalled_hook:void
71#*:void:annotate_signal_hook:void
72#*:void:annotate_exited_hook:void
73##*:void:print_register_hook:int
74##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR
75##*:void:sparc_print_register_hook:int regno:regno
76#*:void:target_resume_hook:void
77#*:void:target_wait_loop_hook:void
78#*:void:init_gdb_hook:char *argv0:argv0
79#*:void:command_loop_hook:void
d9fcf2fb 80#*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
104c1213
JM
81#*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror
82#*:int:query_hook:const char *query, va_list args:query, args
83#*:void:warning_hook:const char *string, va_list args:string, args
104c1213
JM
84#*:void:target_output_hook:char *b:b
85#*:void:interactive_hook:void
86#*:void:registers_changed_hook:void
87#*:void:readline_begin_hook:char *format, ...:format
88#*:char *:readline_hook:char *prompt:prompt
89#*:void:readline_end_hook:void
90#*:void:register_changed_hook:int regno:regno
91#*:void:memory_changed_hook:CORE_ADDR addr, int len:addr, len
92#*:void:context_hook:int num:num
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
108EOF
109 grep -v '^#'
110}
111
112copyright ()
113{
114 cat <<EOF
115/* User Interface Events.
349c5d5f
AC
116
117 Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
104c1213
JM
118
119 Contributed by Cygnus Solutions.
120
afbfc876 121 This file is part of GDB.
104c1213 122
afbfc876
AC
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.
104c1213 127
afbfc876
AC
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.
104c1213 132
afbfc876
AC
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. */
104c1213
JM
136
137/* Work in progress */
138
139/* This file was created with the aid of \`\`gdb-events.sh''.
140
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.
145
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
149 prove easier. */
150
151EOF
152}
153
154#
155# The .h file
156#
157
158exec > new-gdb-events.h
159copyright
160cat <<EOF
161
162#ifndef GDB_EVENTS_H
163#define GDB_EVENTS_H
164
165#ifndef WITH_GDB_EVENTS
166#define WITH_GDB_EVENTS 1
167#endif
168EOF
169
170# pointer declarations
171echo ""
172echo ""
173cat <<EOF
174/* COMPAT: pointer variables for old, unconverted events.
175 A call to set_gdb_events() will automatically update these. */
176EOF
177echo ""
178function_list | while eval read $read
179do
180 case "${class}" in
181 "*" )
182 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
183 ;;
184 esac
185done
186
187# function typedef's
188echo ""
189echo ""
190cat <<EOF
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. */
194EOF
195echo ""
196function_list | while eval read $read
197do
198 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
199done
200
201# gdb_events object
202echo ""
203echo ""
204cat <<EOF
205/* gdb-events: object. */
206EOF
207echo ""
208echo "struct gdb_events"
209echo " {"
210function_list | while eval read $read
211do
212 echo " gdb_events_${function}_ftype *${function}${attrib};"
213done
214echo " };"
215
216# function declarations
217echo ""
218echo ""
219cat <<EOF
220/* Interface into events functions.
c4093a6a
JM
221 Where a *_p() predicate is present, it must be called before
222 calling the hook proper. */
104c1213
JM
223EOF
224function_list | while eval read $read
225do
226 case "${class}" in
227 "*" ) continue ;;
228 "?" )
229 echo "extern int ${function}_p (void);"
230 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
231 ;;
232 "f" )
233 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
234 ;;
235 esac
236done
237
238# function macros
239echo ""
240echo ""
241cat <<EOF
242/* When GDB_EVENTS are not being used, completly disable them. */
243EOF
244echo ""
245echo "#if !WITH_GDB_EVENTS"
246function_list | while eval read $read
247do
248 case "${class}" in
249 "*" ) continue ;;
250 "?" )
251 echo "#define ${function}_event_p() 0"
252 echo "#define ${function}_event(${actual}) 0"
253 ;;
254 "f" )
255 echo "#define ${function}_event(${actual}) 0"
256 ;;
257 esac
258done
259echo "#endif"
260
261# our set function
262cat <<EOF
263
264/* Install custom gdb-events hooks. */
ed9a39eb 265extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
104c1213
JM
266
267/* Deliver any pending events. */
268extern void gdb_events_deliver (struct gdb_events *vector);
269
270#if !WITH_GDB_EVENTS
271#define set_gdb_events(x) 0
272#define set_gdb_event_hooks(x) 0
273#define gdb_events_deliver(x) 0
274#endif
275EOF
276
277# close it off
278echo ""
279echo "#endif"
280exec 1>&2
281#../move-if-change new-gdb-events.h gdb-events.h
9e791099 282if test -r gdb-events.h
104c1213 283then
9e791099
KS
284 diff -c gdb-events.h new-gdb-events.h
285 if [ $? = 1 ]
286 then
287 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
288 fi
289else
104c1213 290 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
104c1213
JM
291fi
292
293
294
295#
296# C file
297#
298
299exec > new-gdb-events.c
300copyright
301cat <<EOF
302
303#include "defs.h"
304#include "gdb-events.h"
305#include "gdbcmd.h"
306
104c1213
JM
307#if WITH_GDB_EVENTS
308static struct gdb_events null_event_hooks;
309static struct gdb_events queue_event_hooks;
310static struct gdb_events *current_event_hooks = &null_event_hooks;
311#endif
312
313int gdb_events_debug;
314EOF
315
316# global pointer variables - always have this
317#echo ""
318#function_list | while eval read $read
319#do
320# case "${class}" in
321# "*" )
322# echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
323# ;;
324# esac
325#done
326
327# function bodies
328echo ""
329echo "#if WITH_GDB_EVENTS"
330function_list | while eval read $read
331do
332 case "${class}" in
333 "*" ) continue ;;
334 "?" )
9e791099
KS
335cat <<EOF
336
337int
338${function}_event_p (${formal})
339{
340 return current_event_hooks->${function};
341}
342
343${returntype}
344${function}_event (${formal})
345{
346 return current_events->${function} (${actual});
347}
348EOF
104c1213
JM
349 ;;
350 "f" )
9e791099
KS
351cat <<EOF
352
353void
354${function}_event (${formal})
355{
356 if (gdb_events_debug)
8c6ee715 357 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
9e791099
KS
358 if (!current_event_hooks->${function})
359 return;
360 current_event_hooks->${function} (${actual});
361}
362EOF
104c1213
JM
363 ;;
364 esac
365done
366echo ""
367echo "#endif"
368
369# Set hooks function
370echo ""
371cat <<EOF
372#if WITH_GDB_EVENTS
ed9a39eb 373struct gdb_events *
104c1213
JM
374set_gdb_event_hooks (struct gdb_events *vector)
375{
ed9a39eb 376 struct gdb_events *old_events = current_event_hooks;
104c1213
JM
377 if (vector == NULL)
378 current_event_hooks = &queue_event_hooks;
379 else
380 current_event_hooks = vector;
ed9a39eb 381 return old_events;
104c1213
JM
382EOF
383function_list | while eval read $read
384do
385 case "${class}" in
386 "*" )
387 echo " ${function}_event = hooks->${function};"
388 ;;
389 esac
390done
391cat <<EOF
392}
393#endif
394EOF
395
396# event type
397echo ""
398cat <<EOF
399enum gdb_event
afbfc876 400{
104c1213
JM
401EOF
402function_list | while eval read $read
403do
404 case "${class}" in
405 "f" )
afbfc876 406 echo " ${function},"
104c1213
JM
407 ;;
408 esac
409done
410cat <<EOF
afbfc876
AC
411 nr_gdb_events
412};
104c1213
JM
413EOF
414
415# event data
416echo ""
417function_list | while eval read $read
418do
419 case "${class}" in
420 "f" )
fd969be2
KS
421 if test ${actual}
422 then
423 echo "struct ${function}"
424 echo " {"
425 echo " `echo ${formal} | tr '[,]' '[;]'`;"
426 echo " };"
427 echo ""
428 fi
104c1213
JM
429 ;;
430 esac
431done
432
433# event queue
434cat <<EOF
435struct event
436 {
437 enum gdb_event type;
438 struct event *next;
439 union
440 {
441EOF
442function_list | while eval read $read
443do
444 case "${class}" in
445 "f" )
fd969be2
KS
446 if test ${actual}
447 then
448 echo " struct ${function} ${function};"
449 fi
104c1213
JM
450 ;;
451 esac
452done
453cat <<EOF
454 }
455 data;
456 };
457struct event *pending_events;
458struct event *delivering_events;
459EOF
460
461# append
462echo ""
463cat <<EOF
464static void
465append (struct event *new_event)
466{
467 struct event **event = &pending_events;
468 while ((*event) != NULL)
469 event = &((*event)->next);
470 (*event) = new_event;
471 (*event)->next = NULL;
472}
473EOF
474
475# schedule a given event
476function_list | while eval read $read
477do
478 case "${class}" in
479 "f" )
480 echo ""
481 echo "static void"
482 echo "queue_${function} (${formal})"
483 echo "{"
484 echo " struct event *event = XMALLOC (struct event);"
485 echo " event->type = ${function};"
9e791099 486 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
104c1213
JM
487 echo " event->data.${function}.${arg} = ${arg};"
488 done
489 echo " append (event);"
490 echo "}"
491 ;;
492 esac
493done
494
495# deliver
496echo ""
497cat <<EOF
498void
499gdb_events_deliver (struct gdb_events *vector)
500{
501 /* Just zap any events left around from last time. */
502 while (delivering_events != NULL)
503 {
504 struct event *event = delivering_events;
505 delivering_events = event->next;
e28f816a 506 xfree (event);
104c1213
JM
507 }
508 /* Process any pending events. Because one of the deliveries could
509 bail out we move everything off of the pending queue onto an
510 in-progress queue where it can, later, be cleaned up if
511 necessary. */
512 delivering_events = pending_events;
513 pending_events = NULL;
514 while (delivering_events != NULL)
515 {
516 struct event *event = delivering_events;
517 switch (event->type)
518 {
519EOF
520function_list | while eval read $read
521do
522 case "${class}" in
523 "f" )
524 echo " case ${function}:"
fd969be2
KS
525 if test ${actual}
526 then
527 echo " vector->${function}"
528 sep=" ("
529 ass=""
530 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
531 ass="${ass}${sep}event->data.${function}.${arg}"
532 sep=",
533 "
534 done
535 echo "${ass});"
536 else
537 echo " vector->${function} ();"
538 fi
104c1213
JM
539 echo " break;"
540 ;;
541 esac
542done
543cat <<EOF
544 }
545 delivering_events = event->next;
e28f816a 546 xfree (event);
104c1213
JM
547 }
548}
549EOF
550
551# Finally the initialization
552echo ""
553cat <<EOF
554void _initialize_gdb_events (void);
555void
556_initialize_gdb_events (void)
557{
afbfc876 558 struct cmd_list_element *c;
104c1213
JM
559#if WITH_GDB_EVENTS
560EOF
561function_list | while eval read $read
562do
563 case "${class}" in
564 "f" )
565 echo " queue_event_hooks.${function} = queue_${function};"
566 ;;
567 esac
568done
569cat <<EOF
570#endif
afbfc876
AC
571
572 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
573 (char *) (&gdb_events_debug), "Set event debugging.\n\\
574When non-zero, event/notify debugging is enabled.", &setlist);
575 deprecate_cmd (c, "set debug event");
576 deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
577
578 add_show_from_set (add_set_cmd ("event",
104c1213
JM
579 class_maintenance,
580 var_zinteger,
afbfc876 581 (char *) (&gdb_events_debug),
104c1213 582 "Set event debugging.\n\\
afbfc876
AC
583When non-zero, event/notify debugging is enabled.", &setdebuglist),
584 &showdebuglist);
104c1213
JM
585}
586EOF
587
588# close things off
589exec 1>&2
590#../move-if-change new-gdb-events.c gdb-events.c
afbfc876
AC
591# Replace any leading spaces with tabs
592sed < new-gdb-events.c > tmp-gdb-events.c \
593 -e 's/\( \)* /\1 /g'
594mv tmp-gdb-events.c new-gdb-events.c
595# Move if changed?
9e791099 596if test -r gdb-events.c
104c1213 597then
9e791099
KS
598 diff -c gdb-events.c new-gdb-events.c
599 if [ $? = 1 ]
600 then
601 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
602 fi
603else
104c1213 604 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2
104c1213 605fi
This page took 0.19179 seconds and 4 git commands to generate.