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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [observer.sh] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
#!/bin/sh -e
2
 
3
# Make certain that the script is not running in an internationalized
4
# environment.
5
LANG=C ; export LANG
6
LC_ALL=C ; export LC_ALL
7
 
8
if test $# -ne 3
9
then
10
    echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
11
    exit 0
12
fi
13
 
14
lang=$1 ; shift
15
texi=$1 ; shift
16
o=$1
17
case $lang in
18
  h) tmp=htmp ;;
19
  inc) tmp=itmp ;;
20
esac
21
otmp="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift
22
echo "Creating ${otmp}" 1>&2
23
rm -f ${otmp}
24
 
25
# Can use any of the following: cat cmp cp diff echo egrep expr false
26
# grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar
27
# test touch true
28
 
29
cat <<EOF >>${otmp}
30
/* GDB Notifications to Observers.
31
 
32
   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
33
   Free Software Foundation, Inc.
34
 
35
   This file is part of GDB.
36
 
37
   This program is free software; you can redistribute it and/or modify
38
   it under the terms of the GNU General Public License as published by
39
   the Free Software Foundation; either version 3 of the License, or
40
   (at your option) any later version.
41
 
42
   This program is distributed in the hope that it will be useful,
43
   but WITHOUT ANY WARRANTY; without even the implied warranty of
44
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45
   GNU General Public License for more details.
46
 
47
   You should have received a copy of the GNU General Public License
48
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
49
 
50
   --
51
 
52
   This file was generated using observer.sh and observer.texi.  */
53
 
54
EOF
55
 
56
 
57
case $lang in
58
    h) cat <<EOF >>${otmp}
59
#ifndef OBSERVER_H
60
#define OBSERVER_H
61
 
62
struct observer;
63
struct bpstats;
64
struct so_list;
65
struct objfile;
66
struct thread_info;
67
EOF
68
        ;;
69
esac
70
 
71
# We are about to set IFS=:, so DOS-style file names with a drive
72
# letter and a colon will be in trouble.
73
 
74
if test -n "$DJGPP"
75
then
76
     texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
77
fi
78
 
79
# generate a list of events that can be observed
80
 
81
IFS=:
82
sed -n '
83
/@deftypefun void/{
84
# Save original line for later processing into the actual parameter
85
    h
86
# Convert from: @deftypefun void EVENT (TYPE @var{PARAM},...)
87
# to event and formals: EVENT:TYPE PARAM, ...:
88
    s/^.* void \([a-z_][a-z_]*\) (\(.*\))$/\1:\2/
89
    s/@var{//g
90
    s/}//g
91
# Switch to held
92
    x
93
# Convert from: @deftypefun void FUNC (TYPE @var{PARAM},...)
94
# to actuals: PARAM, ...
95
    s/^[^{]*[{]*//
96
    s/[}]*[^}]*$//
97
    s/}[^{]*{/, /g
98
# Combine held (EVENT:TYPE PARAM, ...:) and pattern (PARAM, ...) into
99
# FUNC:TYPE PARAM, ...:PARAM, ...
100
    H
101
    x
102
    s/\n/:/g
103
    p
104
}
105
' $texi | while read event formal actual
106
do
107
  case $lang in
108
      h) cat <<EOF >>${otmp}
109
 
110
/* ${event} notifications.  */
111
 
112
typedef void (observer_${event}_ftype) (${formal});
113
 
114
extern struct observer *observer_attach_${event} (observer_${event}_ftype *f);
115
extern void observer_detach_${event} (struct observer *observer);
116
extern void observer_notify_${event} (${formal});
117
EOF
118
        ;;
119
 
120
      inc)
121
        cat <<EOF >>${otmp}
122
 
123
/* ${event} notifications.  */
124
 
125
static struct observer_list *${event}_subject = NULL;
126
 
127
EOF
128
        if test "$formal" != "void"; then
129
            cat<<EOF >>${otmp}
130
struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
131
 
132
EOF
133
        fi
134
        cat <<EOF >>${otmp}
135
static void
136
observer_${event}_notification_stub (const void *data, const void *args_data)
137
{
138
  observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
139
  const struct ${event}_args *args = args_data;
140
  notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
141
}
142
 
143
struct observer *
144
observer_attach_${event} (observer_${event}_ftype *f)
145
{
146
  return generic_observer_attach (&${event}_subject,
147
                                  &observer_${event}_notification_stub,
148
                                  (void *) f);
149
}
150
 
151
void
152
observer_detach_${event} (struct observer *observer)
153
{
154
  generic_observer_detach (&${event}_subject, observer);
155
}
156
 
157
void
158
observer_notify_${event} (${formal})
159
{
160
EOF
161
        if test "$formal" != "void"; then
162
            cat<<EOF >>${otmp}
163
  struct ${event}_args args;
164
  `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
165
 
166
EOF
167
        else
168
            echo "char *args = NULL;" >> ${otmp}
169
        fi
170
        cat<<EOF >>${otmp}
171
  if (observer_debug)
172
    fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
173
  generic_observer_notify (${event}_subject, &args);
174
}
175
EOF
176
        ;;
177
    esac
178
done
179
 
180
 
181
case $lang in
182
    h) cat <<EOF >>${otmp}
183
 
184
#endif /* OBSERVER_H */
185
EOF
186
esac
187
 
188
 
189
echo Moving ${otmp} to ${o}
190
mv ${otmp} ${o}

powered by: WebSVN 2.1.0

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