]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/observer.sh
3 # Make certain that the script is not running in an internationalized
6 LC_ALL
=c
; export LC_ALL
10 echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
21 otmp
="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift
22 echo "Creating ${otmp}" 1>&2
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
30 /* GDB Notifications to Observers.
32 Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
34 This file is part of GDB.
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.
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.
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
48 Foundation, Inc., 51 Franklin Street, Fifth Floor,
49 Boston, MA 02110-1301, USA.
53 This file was generated using observer.sh and observer.texi. */
59 h
) cat <<EOF >>${otmp}
70 # We are about to set IFS=:, so DOS-style file names with a drive
71 # letter and a colon will be in trouble.
75 texi
=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
78 # generate a list of events that can be observed
83 # Save original line for later processing into the actual parameter
85 # Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
86 # to event and formals: EVENT:TYPE PARAM, ...:
87 s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
92 # Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
93 # to actuals: PARAM, ...
97 # Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
98 # FUNC:TYPE PARAM, ...:PARAM, ...
104 ' $texi |
while read event formal actual
107 h
) cat <<EOF >>${otmp}
109 /* ${event} notifications. */
111 typedef void (observer_${event}_ftype) (${formal});
113 extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
114 extern void observer_detach_${event} (struct observer *observer);
115 extern void observer_notify_${event} (${formal});
122 /* ${event} notifications. */
124 static struct observer_list *${event}_subject = NULL;
126 struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
129 observer_${event}_notification_stub (const void *data, const void *args_data)
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'`);
137 observer_attach_${event} (observer_${event}_ftype *f)
139 return generic_observer_attach (&${event}_subject,
140 &observer_${event}_notification_stub,
145 observer_detach_${event} (struct observer *observer)
147 generic_observer_detach (&${event}_subject, observer);
151 observer_notify_${event} (${formal})
153 struct ${event}_args args;
154 `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
156 fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
157 generic_observer_notify (${event}_subject, &args);
166 h
) cat <<EOF >>${otmp}
168 #endif /* OBSERVER_H */
173 echo Moving
${otmp} to
${o}