From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20268 invoked by alias); 8 Apr 2004 21:09:36 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 20232 invoked from network); 8 Apr 2004 21:09:34 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 8 Apr 2004 21:09:34 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i38L9YME023184 for ; Thu, 8 Apr 2004 17:09:34 -0400 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i38L9Xj10872; Thu, 8 Apr 2004 17:09:33 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 9C5492B9C; Thu, 8 Apr 2004 17:09:34 -0400 (EDT) Message-ID: <4075BF8E.9080706@gnu.org> Date: Thu, 08 Apr 2004 21:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch/rfc] Generate observer.[hc] Content-Type: multipart/mixed; boundary="------------050609020902030001000702" X-SW-Source: 2004-04/txt/msg00193.txt.bz2 This is a multi-part message in MIME format. --------------050609020902030001000702 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 445 Hello, The attached adds the script observer.sh that can be used to generate: observer.h observer.ch (#included by observer.c) aat build time using doc/observer.texi as the input. While this is more ambitious than gdbarch.* (which are explicitly generated and then committed to CVS) I suspect it is prefered. Comments? Once this is in I can add a few observers, and start deleting all those hooks and events. Andrew (only a year late) --------------050609020902030001000702 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 10616 2004-04-08 Andrew Cagney * 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.ch". * infrun.c (normal_stop): Pass "stop_bpstat" to observer_notify_normal_stop. * Makefile.in (observer_ch): Define. (observer.o): Update dependencies. (observer.h, observer.ch): New rules. * observer.h: Delete file. * observer.sh: New file. Index: doc/ChangeLog 2004-04-08 Andrew Cagney * observer.texi (GDB Observers): Rework, provide generic observer definitions and then a list of observable events. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.534 diff -u -r1.534 Makefile.in --- Makefile.in 7 Apr 2004 00:04:28 -0000 1.534 +++ Makefile.in 8 Apr 2004 20:49:30 -0000 @@ -587,6 +587,7 @@ 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_ch = observer.ch # # $BUILD/ headers @@ -1281,6 +1282,15 @@ mv version.c-tmp version.c version.o: version.c $(version_h) +observer.h: observer.sh doc/observer.texi + rm -f observer.h-tmp + ${srcdir}/observer.sh h ${srcdir}/doc/observer.texi > observer.h-tmp + mv observer.h-tmp observer.h + +observer.ch: observer.sh doc/observer.texi + rm -f observer.ch-tmp + ${srcdir}/observer.sh c ${srcdir}/doc/observer.texi > observer.ch-tmp + mv observer.ch-tmp observer.ch lint: $(LINTFILES) $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) \ @@ -2109,7 +2119,7 @@ $(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_ch) 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) Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.145 diff -u -r1.145 infrun.c --- infrun.c 2 Apr 2004 22:38:43 -0000 1.145 +++ infrun.c 8 Apr 2004 20:49:31 -0000 @@ -3276,7 +3276,7 @@ done: annotate_stopped (); - observer_notify_normal_stop (); + observer_notify_normal_stop (stop_bpstat); } static int Index: observer.c =================================================================== RCS file: /cvs/src/src/gdb/observer.c,v retrieving revision 1.4 diff -u -r1.4 observer.c --- observer.c 12 Dec 2003 16:14:26 -0000 1.4 +++ observer.c 8 Apr 2004 20:49:31 -0000 @@ -159,37 +159,6 @@ } } -/* 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_observer++; } +#include "observer.ch" Index: observer.h =================================================================== RCS file: observer.h diff -N observer.h --- observer.h 28 Feb 2003 07:08:51 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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 */ Index: observer.sh =================================================================== RCS file: observer.sh diff -N observer.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ observer.sh 8 Apr 2004 20:49:31 -0000 @@ -0,0 +1,142 @@ +#!/bin/sh + +if test $# -ne 2 +then + echo "Usage: $0 [h|c] observer.texi" 1>&2 + exit 0 +fi + +lang=$1 ; shift +texi=$1 ; shift + +# 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 <\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 <