Don't emit symbols seen only in dynamic object, don't read duplicate
[deliverable/binutils-gdb.git] / gdb / observer.sh
CommitLineData
7a464420
AC
1#!/bin/sh -e
2
6e2c7fa1
DJ
3# Make certain that the script is not running in an internationalized
4# environment.
5LANG=c ; export LANG
6LC_ALL=c ; export LC_ALL
7
7a464420
AC
8if test $# -ne 3
9then
10 echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
11 exit 0
12fi
13
14lang=$1 ; shift
15texi=$1 ; shift
15c3c5c6 16o=$1
99efcb59
AS
17case $lang in
18 h) tmp=htmp ;;
19 inc) tmp=itmp ;;
20esac
21otmp="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift
15c3c5c6
EZ
22echo "Creating ${otmp}" 1>&2
23rm -f ${otmp}
7a464420
AC
24
25# Can use any of the following: cat cmp cp diff echo egrep expr false
26# grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar
27# test touch true
28
15c3c5c6 29cat <<EOF >>${otmp}
7a464420
AC
30/* GDB Notifications to Observers.
31
197e01b6 32 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
7a464420
AC
33
34 This file is part of GDB.
35
36 This program is free software; you can redistribute it and/or modify
37 it under the terms of the GNU General Public License as published by
38 the Free Software Foundation; either version 2 of the License, or
39 (at your option) any later version.
40
41 This program is distributed in the hope that it will be useful,
42 but WITHOUT ANY WARRANTY; without even the implied warranty of
43 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 GNU General Public License for more details.
45
46 You should have received a copy of the GNU General Public License
47 along with this program; if not, write to the Free Software
197e01b6
EZ
48 Foundation, Inc., 51 Franklin Street, Fifth Floor,
49 Boston, MA 02110-1301, USA.
7a464420
AC
50
51 --
52
53 This file was generated using observer.sh and observer.texi. */
54
55EOF
56
57
58case $lang in
15c3c5c6 59 h) cat <<EOF >>${otmp}
7a464420
AC
60#ifndef OBSERVER_H
61#define OBSERVER_H
62
63struct observer;
64struct bpstats;
84acb35a 65struct so_list;
7a464420
AC
66EOF
67 ;;
68esac
69
5711a8b0
EZ
70# We are about to set IFS=:, so DOS-style file names with a drive
71# letter and a colon will be in trouble.
72
f3e25dcb 73if test -n "$DJGPP"
5711a8b0
EZ
74then
75 texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
76fi
7a464420
AC
77
78# generate a list of events that can be observed
79
80IFS=:
81sed -n '
82/@deftypefun void/{
350c2e5b 83# Save original line for later processing into the actual parameter
7a464420 84 h
350c2e5b
JB
85# Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
86# to event and formals: EVENT:TYPE PARAM, ...:
7a464420
AC
87 s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
88 s/@var{//g
89 s/}//g
350c2e5b 90# Switch to held
7a464420 91 x
350c2e5b
JB
92# Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
93# to actuals: PARAM, ...
7a464420
AC
94 s/^[^{]*[{]*//
95 s/[}]*[^}]*$//
96 s/}[^{]*{/, /g
350c2e5b
JB
97# Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
98# FUNC:TYPE PARAM, ...:PARAM, ...
7a464420
AC
99 H
100 x
101 s/\n/:/g
102 p
103}
104' $texi | while read event formal actual
105do
106 case $lang in
15c3c5c6 107 h) cat <<EOF >>${otmp}
7a464420
AC
108
109/* ${event} notifications. */
110
111typedef void (observer_${event}_ftype) (${formal});
112
113extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
114extern void observer_detach_${event} (struct observer *observer);
115extern void observer_notify_${event} (${formal});
116EOF
117 ;;
118
119 inc)
15c3c5c6 120 cat <<EOF >>${otmp}
7a464420
AC
121
122/* ${event} notifications. */
123
124static struct observer_list *${event}_subject = NULL;
125
126struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
127
128static void
129observer_${event}_notification_stub (const void *data, const void *args_data)
130{
131 observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
132 const struct ${event}_args *args = args_data;
133 notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
134}
135
136struct observer *
137observer_attach_${event} (observer_${event}_ftype *f)
138{
139 return generic_observer_attach (&${event}_subject,
140 &observer_${event}_notification_stub,
141 (void *) f);
142}
143
144void
145observer_detach_${event} (struct observer *observer)
146{
147 generic_observer_detach (&${event}_subject, observer);
148}
149
150void
151observer_notify_${event} (${formal})
152{
153 struct ${event}_args args;
154 `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
2b4855ab
AC
155 if (observer_debug)
156 fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
7a464420
AC
157 generic_observer_notify (${event}_subject, &args);
158}
159EOF
160 ;;
161 esac
162done
163
164
165case $lang in
15c3c5c6 166 h) cat <<EOF >>${otmp}
7a464420
AC
167
168#endif /* OBSERVER_H */
169EOF
170esac
171
172
15c3c5c6
EZ
173echo Moving ${otmp} to ${o}
174mv ${otmp} ${o}
This page took 0.219059 seconds and 4 git commands to generate.