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 | 7a46442073403bcb8560c4763768aecee620846b (patch) | |
tree | 7804ba214359560a69ce42a7d5723e3bc0102d8f /gdb | |
parent | e36ad5279939b02e2506528bcd786f94480549b2 (diff) | |
download | gdb-7a46442073403bcb8560c4763768aecee620846b.zip gdb-7a46442073403bcb8560c4763768aecee620846b.tar.gz gdb-7a46442073403bcb8560c4763768aecee620846b.tar.bz2 |
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')
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/Makefile.in | 8 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/observer.texi | 23 | ||||
-rw-r--r-- | gdb/infrun.c | 2 | ||||
-rw-r--r-- | gdb/observer.c | 32 | ||||
-rw-r--r-- | gdb/observer.h | 35 | ||||
-rwxr-xr-x | gdb/observer.sh | 154 |
8 files changed, 196 insertions, 77 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index eecdae5..4db9782 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +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. + 2004-04-15 Mark Kettenis <kettenis@gnu.org> * vax-tdep.c (vax_frame_cache): Fix typo. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index fd440fe..f5c9ef6 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -587,6 +587,7 @@ gdb_sim_d10v_h = $(INCLUDE_DIR)/gdb/sim-d10v.h gdb_sim_frv_h = $(INCLUDE_DIR)/gdb/sim-frv.h gdb_sim_sh_h = $(INCLUDE_DIR)/gdb/sim-sh.h splay_tree_h = $(INCLUDE_DIR)/splay-tree.h +observer_inc = observer.inc # # $BUILD/ headers @@ -1281,6 +1282,11 @@ version.c: Makefile version.in mv version.c-tmp version.c version.o: version.c $(version_h) +observer.h: observer.sh doc/observer.texi + ${srcdir}/observer.sh h ${srcdir}/doc/observer.texi observer.h + +observer.inc: observer.sh doc/observer.texi + ${srcdir}/observer.sh inc ${srcdir}/doc/observer.texi observer.inc lint: $(LINTFILES) $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) \ @@ -2112,7 +2118,7 @@ objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \ $(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(gdb_assert_h) \ $(gdb_stat_h) $(gdb_obstack_h) $(gdb_string_h) $(hashtab_h) \ $(breakpoint_h) $(block_h) $(dictionary_h) -observer.o: observer.c $(defs_h) $(observer_h) +observer.o: observer.c $(defs_h) $(observer_h) $(observer_inc) ocd.o: ocd.c $(defs_h) $(gdbcore_h) $(gdb_string_h) $(frame_h) $(inferior_h) \ $(bfd_h) $(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) \ $(gdb_stabs_h) $(serial_h) $(ocd_h) $(regcache_h) diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 5f1f332..6e99d31 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2004-04-08 Andrew Cagney <cagney@redhat.com> + + * observer.texi (GDB Observers): Rework, provide generic observer + definitions and then a list of observable events. + 2004-04-04 Andrew Cagney <cagney@redhat.com> * gdbint.texinfo (Host Definition): Delete reference to diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi index de48a19..ee5ab34 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -50,21 +50,26 @@ a condition that is not met. If the breakpoint has any associated commands list, the commands are executed after the notification is emitted. -The following interface is available to manage @code{normal_stop} -observers: +The following interfaces are available to manage observers: -@deftypefun extern struct observer *observer_attach_normal_stop (observer_normal_stop_ftype *@var{f}) -Attach the given @code{normal_stop} callback function @var{f} and -return the associated observer. +@deftypefun extern struct observer *observer_attach_@var{event} (observer_@var{event}_ftype *@var{f}) +Using the function @var{f}, create an observer that is notified when +ever @var{event} occures, return the observer. @end deftypefun -@deftypefun extern void observer_detach_normal_stop (struct observer *@var{observer}); +@deftypefun extern void observer_detach_@var{event} (struct observer *@var{observer}); Remove @var{observer} from the list of observers to be notified when -a @code{normal_stop} event occurs. +@var{event} occurs. @end deftypefun -@deftypefun extern void observer_notify_normal_stop (void); -Send a notification to all @code{normal_stop} observers. +@deftypefun extern void observer_notify_@var{event} (void); +Send a notification to all @var{event} observers. @end deftypefun +The following observable events are defined: +@c note: all events must take at least one parameter. + +@deftypefun void normal_stop (struct bpstats *@var{bs}) +The inferior has stopped for real. +@end deftypefun diff --git a/gdb/infrun.c b/gdb/infrun.c index b64325a..611a8f4 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3276,7 +3276,7 @@ normal_stop (void) done: annotate_stopped (); - observer_notify_normal_stop (); + observer_notify_normal_stop (stop_bpstat); } static int diff --git a/gdb/observer.c b/gdb/observer.c index fce5f92..20bc8aa 100644 --- a/gdb/observer.c +++ b/gdb/observer.c @@ -159,37 +159,6 @@ generic_observer_notify (struct observer_list *subject, const void *args) } } -/* normal_stop notifications. */ - -static struct observer_list *normal_stop_subject = NULL; - -static void -observer_normal_stop_notification_stub (const void *data, - const void *unused_args) -{ - observer_normal_stop_ftype *notify = (observer_normal_stop_ftype *) data; - (*notify) (); -} - -struct observer * -observer_attach_normal_stop (observer_normal_stop_ftype *f) -{ - return generic_observer_attach (&normal_stop_subject, - &observer_normal_stop_notification_stub, - (void *) f); -} - -void -observer_detach_normal_stop (struct observer *observer) -{ - generic_observer_detach (&normal_stop_subject, observer); -} - -void -observer_notify_normal_stop (void) -{ - generic_observer_notify (normal_stop_subject, NULL); -} /* The following code is only used to unit-test the observers from our testsuite. DO NOT USE IT within observer.c (or anywhere else for @@ -220,3 +189,4 @@ observer_test_third_notification_function (void) observer_test_third_observer++; } +#include "observer.inc" diff --git a/gdb/observer.h b/gdb/observer.h deleted file mode 100644 index 8b9a6db..0000000 --- a/gdb/observer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* GDB Notifications to Observers. - Copyright 2003 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. */ - -#ifndef OBSERVER_H -#define OBSERVER_H - -struct observer; - -/* normal_stop notifications. */ - -typedef void (observer_normal_stop_ftype) (void); - -extern struct observer * - observer_attach_normal_stop (observer_normal_stop_ftype *f); -extern void observer_detach_normal_stop (struct observer *observer); -extern void observer_notify_normal_stop (void); - -#endif /* OBSERVER_H */ diff --git a/gdb/observer.sh b/gdb/observer.sh new file mode 100755 index 0000000..c67346f --- /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} |