Rephrase error message in infcall.c:call_function_by_hand
[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.
c2c8d75b
AS
5LANG=C ; export LANG
6LC_ALL=C ; export LC_ALL
6e2c7fa1 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
7b6bb8da 32 Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010, 2011
4c38e0a4 33 Free Software Foundation, Inc.
7a464420
AC
34
35 This file is part of GDB.
36
37 This program is free software; you can redistribute it and/or modify
38 it under the terms of the GNU General Public License as published by
50efebf8 39 the Free Software Foundation; either version 3 of the License, or
7a464420 40 (at your option) any later version.
50efebf8 41
7a464420
AC
42 This program is distributed in the hope that it will be useful,
43 but WITHOUT ANY WARRANTY; without even the implied warranty of
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 GNU General Public License for more details.
50efebf8 46
7a464420 47 You should have received a copy of the GNU General Public License
50efebf8 48 along with this program. If not, see <http://www.gnu.org/licenses/>.
7a464420
AC
49
50 --
51
52 This file was generated using observer.sh and observer.texi. */
53
54EOF
55
56
57case $lang in
15c3c5c6 58 h) cat <<EOF >>${otmp}
7a464420
AC
59#ifndef OBSERVER_H
60#define OBSERVER_H
61
62struct observer;
63struct bpstats;
84acb35a 64struct so_list;
06d3b283 65struct objfile;
683f2885 66struct thread_info;
619cebe8 67struct inferior;
7a464420
AC
68EOF
69 ;;
70esac
71
5711a8b0
EZ
72# We are about to set IFS=:, so DOS-style file names with a drive
73# letter and a colon will be in trouble.
74
f3e25dcb 75if test -n "$DJGPP"
5711a8b0
EZ
76then
77 texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
78fi
7a464420
AC
79
80# generate a list of events that can be observed
81
82IFS=:
83sed -n '
84/@deftypefun void/{
350c2e5b 85# Save original line for later processing into the actual parameter
7a464420 86 h
350c2e5b
JB
87# Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
88# to event and formals: EVENT:TYPE PARAM, ...:
7a464420
AC
89 s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
90 s/@var{//g
91 s/}//g
350c2e5b 92# Switch to held
7a464420 93 x
350c2e5b
JB
94# Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
95# to actuals: PARAM, ...
7a464420
AC
96 s/^[^{]*[{]*//
97 s/[}]*[^}]*$//
98 s/}[^{]*{/, /g
350c2e5b
JB
99# Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
100# FUNC:TYPE PARAM, ...:PARAM, ...
7a464420
AC
101 H
102 x
103 s/\n/:/g
104 p
105}
106' $texi | while read event formal actual
107do
108 case $lang in
15c3c5c6 109 h) cat <<EOF >>${otmp}
7a464420
AC
110
111/* ${event} notifications. */
112
113typedef void (observer_${event}_ftype) (${formal});
114
115extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
116extern void observer_detach_${event} (struct observer *observer);
117extern void observer_notify_${event} (${formal});
118EOF
119 ;;
120
121 inc)
15c3c5c6 122 cat <<EOF >>${otmp}
7a464420
AC
123
124/* ${event} notifications. */
125
126static struct observer_list *${event}_subject = NULL;
127
781b42b0
TT
128EOF
129 if test "$formal" != "void"; then
130 cat<<EOF >>${otmp}
7a464420
AC
131struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
132
781b42b0
TT
133EOF
134 fi
135 cat <<EOF >>${otmp}
7a464420
AC
136static void
137observer_${event}_notification_stub (const void *data, const void *args_data)
138{
139 observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
140 const struct ${event}_args *args = args_data;
141 notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
142}
143
144struct observer *
145observer_attach_${event} (observer_${event}_ftype *f)
146{
147 return generic_observer_attach (&${event}_subject,
148 &observer_${event}_notification_stub,
149 (void *) f);
150}
151
152void
153observer_detach_${event} (struct observer *observer)
154{
155 generic_observer_detach (&${event}_subject, observer);
156}
157
158void
159observer_notify_${event} (${formal})
160{
781b42b0
TT
161EOF
162 if test "$formal" != "void"; then
163 cat<<EOF >>${otmp}
7a464420
AC
164 struct ${event}_args args;
165 `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
781b42b0
TT
166
167EOF
168 else
169 echo "char *args = NULL;" >> ${otmp}
170 fi
171 cat<<EOF >>${otmp}
2b4855ab
AC
172 if (observer_debug)
173 fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
7a464420
AC
174 generic_observer_notify (${event}_subject, &args);
175}
176EOF
177 ;;
178 esac
179done
180
181
182case $lang in
15c3c5c6 183 h) cat <<EOF >>${otmp}
7a464420
AC
184
185#endif /* OBSERVER_H */
186EOF
187esac
188
189
15c3c5c6
EZ
190echo Moving ${otmp} to ${o}
191mv ${otmp} ${o}
This page took 0.707063 seconds and 4 git commands to generate.