* elf64-mips.c (mips_elf64_be_swap_reloca_out): Handle type2 and type3.
[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
e23792cc 68f:void:target_changed:void
55970da6 69f:void:selected_frame_level_changed:int level:level
104c1213
JM
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
d9fcf2fb 82#*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream
104c1213
JM
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
104c1213
JM
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
104c1213
JM
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
107EOF
108 grep -v '^#'
109}
110
111copyright ()
112{
113 cat <<EOF
114/* User Interface Events.
349c5d5f
AC
115
116 Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
104c1213
JM
117
118 Contributed by Cygnus Solutions.
119
afbfc876 120 This file is part of GDB.
104c1213 121
afbfc876
AC
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.
104c1213 126
afbfc876
AC
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.
104c1213 131
afbfc876
AC
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. */
104c1213
JM
135
136/* Work in progress */
137
138/* This file was created with the aid of \`\`gdb-events.sh''.
139
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.
144
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
148 prove easier. */
149
150EOF
151}
152
153#
154# The .h file
155#
156
157exec > new-gdb-events.h
158copyright
159cat <<EOF
160
161#ifndef GDB_EVENTS_H
162#define GDB_EVENTS_H
163
164#ifndef WITH_GDB_EVENTS
165#define WITH_GDB_EVENTS 1
166#endif
167EOF
168
169# pointer declarations
170echo ""
171echo ""
172cat <<EOF
173/* COMPAT: pointer variables for old, unconverted events.
174 A call to set_gdb_events() will automatically update these. */
175EOF
176echo ""
177function_list | while eval read $read
178do
179 case "${class}" in
180 "*" )
181 echo "extern ${returntype} (*${function}_event) (${formal})${attrib};"
182 ;;
183 esac
184done
185
186# function typedef's
187echo ""
188echo ""
189cat <<EOF
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. */
193EOF
194echo ""
195function_list | while eval read $read
196do
197 echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});"
198done
199
200# gdb_events object
201echo ""
202echo ""
203cat <<EOF
204/* gdb-events: object. */
205EOF
206echo ""
207echo "struct gdb_events"
208echo " {"
209function_list | while eval read $read
210do
211 echo " gdb_events_${function}_ftype *${function}${attrib};"
212done
213echo " };"
214
215# function declarations
216echo ""
217echo ""
218cat <<EOF
219/* Interface into events functions.
c4093a6a
JM
220 Where a *_p() predicate is present, it must be called before
221 calling the hook proper. */
104c1213
JM
222EOF
223function_list | while eval read $read
224do
225 case "${class}" in
226 "*" ) continue ;;
227 "?" )
228 echo "extern int ${function}_p (void);"
229 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
230 ;;
231 "f" )
232 echo "extern ${returntype} ${function}_event (${formal})${attrib};"
233 ;;
234 esac
235done
236
237# function macros
238echo ""
239echo ""
240cat <<EOF
241/* When GDB_EVENTS are not being used, completly disable them. */
242EOF
243echo ""
244echo "#if !WITH_GDB_EVENTS"
245function_list | while eval read $read
246do
247 case "${class}" in
248 "*" ) continue ;;
249 "?" )
250 echo "#define ${function}_event_p() 0"
251 echo "#define ${function}_event(${actual}) 0"
252 ;;
253 "f" )
254 echo "#define ${function}_event(${actual}) 0"
255 ;;
256 esac
257done
258echo "#endif"
259
260# our set function
261cat <<EOF
262
263/* Install custom gdb-events hooks. */
ed9a39eb 264extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector);
104c1213
JM
265
266/* Deliver any pending events. */
267extern void gdb_events_deliver (struct gdb_events *vector);
268
63d022e0
KS
269/* Clear event handlers */
270extern void clear_gdb_event_hooks (void);
271
104c1213
JM
272#if !WITH_GDB_EVENTS
273#define set_gdb_events(x) 0
274#define set_gdb_event_hooks(x) 0
275#define gdb_events_deliver(x) 0
276#endif
277EOF
278
279# close it off
280echo ""
281echo "#endif"
282exec 1>&2
283#../move-if-change new-gdb-events.h gdb-events.h
9e791099 284if test -r gdb-events.h
104c1213 285then
9e791099
KS
286 diff -c gdb-events.h new-gdb-events.h
287 if [ $? = 1 ]
288 then
289 echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2
290 fi
291else
104c1213 292 echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2
104c1213
JM
293fi
294
295
296
297#
298# C file
299#
300
301exec > new-gdb-events.c
302copyright
303cat <<EOF
304
305#include "defs.h"
306#include "gdb-events.h"
307#include "gdbcmd.h"
308
104c1213
JM
309#if WITH_GDB_EVENTS
310static struct gdb_events null_event_hooks;
311static struct gdb_events queue_event_hooks;
312static struct gdb_events *current_event_hooks = &null_event_hooks;
313#endif
314
315int gdb_events_debug;
316EOF
317
318# global pointer variables - always have this
319#echo ""
320#function_list | while eval read $read
321#do
322# case "${class}" in
323# "*" )
324# echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;"
325# ;;
326# esac
327#done
328
329# function bodies
330echo ""
331echo "#if WITH_GDB_EVENTS"
332function_list | while eval read $read
333do
334 case "${class}" in
335 "*" ) continue ;;
336 "?" )
9e791099
KS
337cat <<EOF
338
339int
340${function}_event_p (${formal})
341{
342 return current_event_hooks->${function};
343}
344
345${returntype}
346${function}_event (${formal})
347{
348 return current_events->${function} (${actual});
349}
350EOF
104c1213
JM
351 ;;
352 "f" )
9e791099
KS
353cat <<EOF
354
355void
356${function}_event (${formal})
357{
358 if (gdb_events_debug)
8c6ee715 359 fprintf_unfiltered (gdb_stdlog, "${function}_event\n");
9e791099
KS
360 if (!current_event_hooks->${function})
361 return;
362 current_event_hooks->${function} (${actual});
363}
364EOF
104c1213
JM
365 ;;
366 esac
367done
368echo ""
369echo "#endif"
370
371# Set hooks function
372echo ""
373cat <<EOF
374#if WITH_GDB_EVENTS
ed9a39eb 375struct gdb_events *
104c1213
JM
376set_gdb_event_hooks (struct gdb_events *vector)
377{
ed9a39eb 378 struct gdb_events *old_events = current_event_hooks;
104c1213
JM
379 if (vector == NULL)
380 current_event_hooks = &queue_event_hooks;
381 else
382 current_event_hooks = vector;
ed9a39eb 383 return old_events;
104c1213
JM
384EOF
385function_list | while eval read $read
386do
387 case "${class}" in
388 "*" )
389 echo " ${function}_event = hooks->${function};"
390 ;;
391 esac
392done
393cat <<EOF
394}
395#endif
396EOF
397
63d022e0
KS
398# Clear hooks function
399echo ""
400cat <<EOF
401#if WITH_GDB_EVENTS
402void
403clear_gdb_event_hooks (void)
404{
405 set_gdb_event_hooks (&null_event_hooks);
406}
407#endif
408EOF
409
104c1213
JM
410# event type
411echo ""
412cat <<EOF
413enum gdb_event
afbfc876 414{
104c1213
JM
415EOF
416function_list | while eval read $read
417do
418 case "${class}" in
419 "f" )
afbfc876 420 echo " ${function},"
104c1213
JM
421 ;;
422 esac
423done
424cat <<EOF
afbfc876
AC
425 nr_gdb_events
426};
104c1213
JM
427EOF
428
429# event data
430echo ""
431function_list | while eval read $read
432do
433 case "${class}" in
434 "f" )
fd969be2
KS
435 if test ${actual}
436 then
437 echo "struct ${function}"
438 echo " {"
439 echo " `echo ${formal} | tr '[,]' '[;]'`;"
440 echo " };"
441 echo ""
442 fi
104c1213
JM
443 ;;
444 esac
445done
446
447# event queue
448cat <<EOF
449struct event
450 {
451 enum gdb_event type;
452 struct event *next;
453 union
454 {
455EOF
456function_list | while eval read $read
457do
458 case "${class}" in
459 "f" )
fd969be2
KS
460 if test ${actual}
461 then
462 echo " struct ${function} ${function};"
463 fi
104c1213
JM
464 ;;
465 esac
466done
467cat <<EOF
468 }
469 data;
470 };
471struct event *pending_events;
472struct event *delivering_events;
473EOF
474
475# append
476echo ""
477cat <<EOF
478static void
479append (struct event *new_event)
480{
481 struct event **event = &pending_events;
482 while ((*event) != NULL)
483 event = &((*event)->next);
484 (*event) = new_event;
485 (*event)->next = NULL;
486}
487EOF
488
489# schedule a given event
490function_list | while eval read $read
491do
492 case "${class}" in
493 "f" )
494 echo ""
495 echo "static void"
496 echo "queue_${function} (${formal})"
497 echo "{"
498 echo " struct event *event = XMALLOC (struct event);"
499 echo " event->type = ${function};"
9e791099 500 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
104c1213
JM
501 echo " event->data.${function}.${arg} = ${arg};"
502 done
503 echo " append (event);"
504 echo "}"
505 ;;
506 esac
507done
508
509# deliver
510echo ""
511cat <<EOF
512void
513gdb_events_deliver (struct gdb_events *vector)
514{
515 /* Just zap any events left around from last time. */
516 while (delivering_events != NULL)
517 {
518 struct event *event = delivering_events;
519 delivering_events = event->next;
e28f816a 520 xfree (event);
104c1213
JM
521 }
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
525 necessary. */
526 delivering_events = pending_events;
527 pending_events = NULL;
528 while (delivering_events != NULL)
529 {
530 struct event *event = delivering_events;
531 switch (event->type)
532 {
533EOF
534function_list | while eval read $read
535do
536 case "${class}" in
537 "f" )
538 echo " case ${function}:"
fd969be2
KS
539 if test ${actual}
540 then
541 echo " vector->${function}"
542 sep=" ("
543 ass=""
544 for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do
545 ass="${ass}${sep}event->data.${function}.${arg}"
546 sep=",
547 "
548 done
549 echo "${ass});"
550 else
551 echo " vector->${function} ();"
552 fi
104c1213
JM
553 echo " break;"
554 ;;
555 esac
556done
557cat <<EOF
558 }
559 delivering_events = event->next;
e28f816a 560 xfree (event);
104c1213
JM
561 }
562}
563EOF
564
565# Finally the initialization
566echo ""
567cat <<EOF
568void _initialize_gdb_events (void);
569void
570_initialize_gdb_events (void)
571{
afbfc876 572 struct cmd_list_element *c;
104c1213
JM
573#if WITH_GDB_EVENTS
574EOF
575function_list | while eval read $read
576do
577 case "${class}" in
578 "f" )
579 echo " queue_event_hooks.${function} = queue_${function};"
580 ;;
581 esac
582done
583cat <<EOF
584#endif
afbfc876
AC
585
586 c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
587 (char *) (&gdb_events_debug), "Set event debugging.\n\\
588When 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");
591
592 add_show_from_set (add_set_cmd ("event",
104c1213
JM
593 class_maintenance,
594 var_zinteger,
afbfc876 595 (char *) (&gdb_events_debug),
104c1213 596 "Set event debugging.\n\\
afbfc876
AC
597When non-zero, event/notify debugging is enabled.", &setdebuglist),
598 &showdebuglist);
104c1213
JM
599}
600EOF
601
602# close things off
603exec 1>&2
604#../move-if-change new-gdb-events.c gdb-events.c
afbfc876
AC
605# Replace any leading spaces with tabs
606sed < new-gdb-events.c > tmp-gdb-events.c \
607 -e 's/\( \)* /\1 /g'
608mv tmp-gdb-events.c new-gdb-events.c
609# Move if changed?
9e791099 610if test -r gdb-events.c
104c1213 611then
9e791099
KS
612 diff -c gdb-events.c new-gdb-events.c
613 if [ $? = 1 ]
614 then
615 echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2
616 fi
617else
104c1213 618 echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2
104c1213 619fi
This page took 0.204641 seconds and 4 git commands to generate.