2004-04-15 22:29:21 +08:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2006-07-13 02:04:30 +08:00
|
|
|
# Make certain that the script is not running in an internationalized
|
|
|
|
# environment.
|
2009-03-29 21:36:27 +08:00
|
|
|
LANG=C ; export LANG
|
|
|
|
LC_ALL=C ; export LC_ALL
|
2006-07-13 02:04:30 +08:00
|
|
|
|
2004-04-15 22:29:21 +08:00
|
|
|
if test $# -ne 3
|
|
|
|
then
|
|
|
|
echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
lang=$1 ; shift
|
|
|
|
texi=$1 ; shift
|
2005-05-12 23:44:19 +08:00
|
|
|
o=$1
|
2005-07-07 21:11:16 +08:00
|
|
|
case $lang in
|
|
|
|
h) tmp=htmp ;;
|
|
|
|
inc) tmp=itmp ;;
|
|
|
|
esac
|
|
|
|
otmp="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift
|
2005-05-12 23:44:19 +08:00
|
|
|
echo "Creating ${otmp}" 1>&2
|
|
|
|
rm -f ${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
# Can use any of the following: cat cmp cp diff echo egrep expr false
|
|
|
|
# grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar
|
|
|
|
# test touch true
|
|
|
|
|
2005-05-12 23:44:19 +08:00
|
|
|
cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
/* GDB Notifications to Observers.
|
|
|
|
|
2015-01-01 17:32:14 +08:00
|
|
|
Copyright (C) 2004-2015 Free Software Foundation, Inc.
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:19:51 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2004-04-15 22:29:21 +08:00
|
|
|
(at your option) any later version.
|
2007-08-24 02:19:51 +08:00
|
|
|
|
2004-04-15 22:29:21 +08:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-08-24 02:19:51 +08:00
|
|
|
|
2004-04-15 22:29:21 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:19:51 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
This file was generated using observer.sh and observer.texi. */
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
case $lang in
|
2005-05-12 23:44:19 +08:00
|
|
|
h) cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
#ifndef OBSERVER_H
|
|
|
|
#define OBSERVER_H
|
|
|
|
|
|
|
|
struct observer;
|
|
|
|
struct bpstats;
|
2004-09-02 02:00:29 +08:00
|
|
|
struct so_list;
|
2007-05-12 03:55:20 +08:00
|
|
|
struct objfile;
|
2008-03-15 01:21:08 +08:00
|
|
|
struct thread_info;
|
2011-05-28 02:39:49 +08:00
|
|
|
struct inferior;
|
2013-02-06 22:45:20 +08:00
|
|
|
struct trace_state_variable;
|
2004-04-15 22:29:21 +08:00
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2005-05-13 04:38:51 +08:00
|
|
|
# We are about to set IFS=:, so DOS-style file names with a drive
|
|
|
|
# letter and a colon will be in trouble.
|
|
|
|
|
2005-05-16 06:05:35 +08:00
|
|
|
if test -n "$DJGPP"
|
2005-05-13 04:38:51 +08:00
|
|
|
then
|
|
|
|
texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
|
|
|
|
fi
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
# generate a list of events that can be observed
|
|
|
|
|
|
|
|
IFS=:
|
|
|
|
sed -n '
|
|
|
|
/@deftypefun void/{
|
2004-04-17 12:45:32 +08:00
|
|
|
# Save original line for later processing into the actual parameter
|
2004-04-15 22:29:21 +08:00
|
|
|
h
|
2004-04-17 12:45:32 +08:00
|
|
|
# Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
|
|
|
|
# to event and formals: EVENT:TYPE PARAM, ...:
|
2004-04-15 22:29:21 +08:00
|
|
|
s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
|
|
|
|
s/@var{//g
|
|
|
|
s/}//g
|
2004-04-17 12:45:32 +08:00
|
|
|
# Switch to held
|
2004-04-15 22:29:21 +08:00
|
|
|
x
|
2004-04-17 12:45:32 +08:00
|
|
|
# Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
|
|
|
|
# to actuals: PARAM, ...
|
2004-04-15 22:29:21 +08:00
|
|
|
s/^[^{]*[{]*//
|
|
|
|
s/[}]*[^}]*$//
|
|
|
|
s/}[^{]*{/, /g
|
2004-04-17 12:45:32 +08:00
|
|
|
# Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
|
|
|
|
# FUNC:TYPE PARAM, ...:PARAM, ...
|
2004-04-15 22:29:21 +08:00
|
|
|
H
|
|
|
|
x
|
|
|
|
s/\n/:/g
|
|
|
|
p
|
|
|
|
}
|
|
|
|
' $texi | while read event formal actual
|
|
|
|
do
|
|
|
|
case $lang in
|
2005-05-12 23:44:19 +08:00
|
|
|
h) cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
/* ${event} notifications. */
|
|
|
|
|
|
|
|
typedef void (observer_${event}_ftype) (${formal});
|
|
|
|
|
|
|
|
extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
|
|
|
|
extern void observer_detach_${event} (struct observer *observer);
|
|
|
|
extern void observer_notify_${event} (${formal});
|
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
|
|
|
|
inc)
|
2005-05-12 23:44:19 +08:00
|
|
|
cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
/* ${event} notifications. */
|
|
|
|
|
|
|
|
static struct observer_list *${event}_subject = NULL;
|
|
|
|
|
2008-07-22 00:47:11 +08:00
|
|
|
EOF
|
|
|
|
if test "$formal" != "void"; then
|
|
|
|
cat<<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
|
|
|
|
|
2008-07-22 00:47:11 +08:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
static void
|
|
|
|
observer_${event}_notification_stub (const void *data, const void *args_data)
|
|
|
|
{
|
|
|
|
observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
|
2012-04-25 02:10:31 +08:00
|
|
|
EOF
|
|
|
|
|
|
|
|
notify_args=`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`
|
|
|
|
|
|
|
|
if test ! -z "${notify_args}"; then
|
|
|
|
cat<<EOF >>${otmp}
|
2015-10-24 04:58:13 +08:00
|
|
|
const struct ${event}_args *args = (const struct ${event}_args *) args_data;
|
2012-04-25 02:10:31 +08:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
cat <<EOF >>${otmp}
|
|
|
|
notify (${notify_args});
|
2004-04-15 22:29:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct observer *
|
|
|
|
observer_attach_${event} (observer_${event}_ftype *f)
|
|
|
|
{
|
|
|
|
return generic_observer_attach (&${event}_subject,
|
|
|
|
&observer_${event}_notification_stub,
|
|
|
|
(void *) f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
observer_detach_${event} (struct observer *observer)
|
|
|
|
{
|
|
|
|
generic_observer_detach (&${event}_subject, observer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
observer_notify_${event} (${formal})
|
|
|
|
{
|
2008-07-22 00:47:11 +08:00
|
|
|
EOF
|
|
|
|
if test "$formal" != "void"; then
|
|
|
|
cat<<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
struct ${event}_args args;
|
|
|
|
`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
|
2008-07-22 00:47:11 +08:00
|
|
|
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
echo "char *args = NULL;" >> ${otmp}
|
|
|
|
fi
|
|
|
|
cat<<EOF >>${otmp}
|
2004-05-08 06:51:55 +08:00
|
|
|
if (observer_debug)
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
|
2004-04-15 22:29:21 +08:00
|
|
|
generic_observer_notify (${event}_subject, &args);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
case $lang in
|
2005-05-12 23:44:19 +08:00
|
|
|
h) cat <<EOF >>${otmp}
|
2004-04-15 22:29:21 +08:00
|
|
|
|
|
|
|
#endif /* OBSERVER_H */
|
|
|
|
EOF
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
2005-05-12 23:44:19 +08:00
|
|
|
echo Moving ${otmp} to ${o}
|
|
|
|
mv ${otmp} ${o}
|