OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [observer.sh] - Diff between revs 834 and 842

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.