diff options
author | Andrew Cagney <cagney@redhat.com> | 2004-04-15 14:29:21 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2004-04-15 14:29:21 +0000 |
commit | 0d2823c6678af43bcdf45d8aa00026ff3de1a000 (patch) | |
tree | 5896cf4b82b804641e96020cec5f55536ff5d3eb /gdb/observer.sh | |
parent | 017d459d2d4b820150363e8a95340f4de78d360c (diff) | |
download | gdb-0d2823c6678af43bcdf45d8aa00026ff3de1a000.tar.gz |
2004-04-15 Andrew Cagney <cagney@redhat.com>
* observer.c (normal_stop_subject, observer_notify_normal_stop)
(observer_normal_stop_notification_stub)
(observer_attach_normal_stop, observer_detach_normal_stop):
Delete, replaced by #include "observer.inc".
* infrun.c (normal_stop): Pass "stop_bpstat" to
observer_notify_normal_stop.
* Makefile.in (observer_inc): Define.
(observer.o): Update dependencies.
(observer.h, observer.inc): New rules.
* observer.h: Delete file.
* observer.sh: New file.
Index: doc/ChangeLog
2004-04-08 Andrew Cagney <cagney@redhat.com>
* observer.texi (GDB Observers): Rework, provide generic observer
definitions and then a list of observable events.
Diffstat (limited to 'gdb/observer.sh')
-rwxr-xr-x | gdb/observer.sh | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/gdb/observer.sh b/gdb/observer.sh new file mode 100755 index 00000000000..c67346fed3c --- /dev/null +++ b/gdb/observer.sh @@ -0,0 +1,154 @@ +#!/bin/sh -e + +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 +o=$1 ; shift +echo "Creating ${o}-tmp" 1>&2 +rm -f ${o}-tmp + +# 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 + +cat <<EOF >>${o}-tmp +/* GDB Notifications to Observers. + + Copyright 2004 Free Software Foundation, Inc. + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + -- + + This file was generated using observer.sh and observer.texi. */ + +EOF + + +case $lang in + h) cat <<EOF >>${o}-tmp +#ifndef OBSERVER_H +#define OBSERVER_H + +struct observer; +struct bpstats; +EOF + ;; +esac + + +# generate a list of events that can be observed + +IFS=: +sed -n ' +/@deftypefun void/{ + # Save original line for later processing into the actual parameter + h + # Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...) + # to event and formals: EVENT:TYPE PARAM, ...: + s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/ + s/@var{//g + s/}//g + # Switch to held + x + # Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...) + # to actuals: PARAM, ... + s/^[^{]*[{]*// + s/[}]*[^}]*$// + s/}[^{]*{/, /g + # Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into + # FUNC:TYPE PARAM, ...:PARAM, ... + H + x + s/\n/:/g + p +} +' $texi | while read event formal actual +do + case $lang in + h) cat <<EOF >>${o}-tmp + +/* ${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) + cat <<EOF >>${o}-tmp + +/* ${event} notifications. */ + +static struct observer_list *${event}_subject = NULL; + +struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; }; + +static void +observer_${event}_notification_stub (const void *data, const void *args_data) +{ + observer_${event}_ftype *notify = (observer_${event}_ftype *) data; + const struct ${event}_args *args = args_data; + notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`); +} + +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}) +{ + struct ${event}_args args; + `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`; + generic_observer_notify (${event}_subject, &args); +} +EOF + ;; + esac +done + + +case $lang in + h) cat <<EOF >>${o}-tmp + +#endif /* OBSERVER_H */ +EOF +esac + + +echo Moving ${o}-tmp to ${o} +mv ${o}-tmp ${o} |