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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [regformats/] [regdat.sh] - Blame information for rev 231

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

Line No. Rev Author Line
1 227 jeremybenn
#!/bin/sh -u
2
 
3
# Register protocol definitions for GDB, the GNU debugger.
4
# Copyright 2001, 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
#
6
# This file is part of GDB.
7
#
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
21
move_if_change ()
22
{
23
    file=$1
24
    if test -r ${file} && cmp -s "${file}" new-"${file}"
25
    then
26
        echo "${file} unchanged." 1>&2
27
    else
28
        mv new-"${file}" "${file}"
29
        echo "${file} updated." 1>&2
30
    fi
31
}
32
 
33
# Format of the input files
34
read="type entry"
35
 
36
do_read ()
37
{
38
    type=""
39
    entry=""
40
    while read line
41
    do
42
        if test "${line}" = ""
43
        then
44
            continue
45
        elif test "${line}" = "#" -a "${comment}" = ""
46
        then
47
            continue
48
        elif expr "${line}" : "#" > /dev/null
49
        then
50
            comment="${comment}
51
${line}"
52
        else
53
 
54
            # The semantics of IFS varies between different SH's.  Some
55
            # treat ``::' as three fields while some treat it as just too.
56
            # Work around this by eliminating ``::'' ....
57
            line="`echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g'`"
58
 
59
            OFS="${IFS}" ; IFS="[:]"
60
            eval read ${read} <<EOF
61
${line}
62
EOF
63
            IFS="${OFS}"
64
 
65
            # .... and then going back through each field and strip out those
66
            # that ended up with just that space character.
67
            for r in ${read}
68
            do
69
                if eval test \"\${${r}}\" = \"\ \"
70
                then
71
                    eval ${r}=""
72
                fi
73
            done
74
 
75
            break
76
        fi
77
    done
78
    if [ -n "${type}" ]
79
    then
80
        true
81
    else
82
        false
83
    fi
84
}
85
 
86
if test ! -r $1; then
87
  echo "$0: Could not open $1." 1>&2
88
  exit 1
89
fi
90
 
91
copyright ()
92
{
93
cat <<EOF
94
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
95
 
96
/* A register protocol for GDB, the GNU debugger.
97
   Copyright 2001, 2002 Free Software Foundation, Inc.
98
 
99
   This file is part of GDB.
100
 
101
   This program is free software; you can redistribute it and/or modify
102
   it under the terms of the GNU General Public License as published by
103
   the Free Software Foundation; either version 3 of the License, or
104
   (at your option) any later version.
105
 
106
   This program is distributed in the hope that it will be useful,
107
   but WITHOUT ANY WARRANTY; without even the implied warranty of
108
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
109
   GNU General Public License for more details.
110
 
111
   You should have received a copy of the GNU General Public License
112
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
113
 
114
/* This file was created with the aid of \`\`regdat.sh'' and \`\`$1''.  */
115
 
116
EOF
117
}
118
 
119
 
120
exec > new-$2
121
copyright $1
122
echo '#include "regdef.h"'
123
echo '#include "regcache.h"'
124
echo
125
offset=0
126
i=0
127
name=x
128
xmltarget=x
129
xmlarch=x
130
xmlosabi=x
131
expedite=x
132
exec < $1
133
while do_read
134
do
135
  if test "${type}" = "name"; then
136
    name="${entry}"
137
    echo "struct reg regs_${name}[] = {"
138
    continue
139
  elif test "${type}" = "xmltarget"; then
140
    xmltarget="${entry}"
141
    continue
142
  elif test "${type}" = "xmlarch"; then
143
    xmlarch="${entry}"
144
    continue
145
  elif test "${type}" = "osabi"; then
146
    xmlosabi="${entry}"
147
    continue
148
  elif test "${type}" = "expedite"; then
149
    expedite="${entry}"
150
    continue
151
  elif test "${name}" = x; then
152
    echo "$0: $1 does not specify \`\`name''." 1>&2
153
    exit 1
154
  else
155
    echo "  { \"${entry}\", ${offset}, ${type} },"
156
    offset=`expr ${offset} + ${type}`
157
    i=`expr $i + 1`
158
  fi
159
done
160
 
161
echo "};"
162
echo
163
echo "const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };"
164
if test "${xmltarget}" = x; then
165
  if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
166
    echo "const char *xmltarget_${name} = 0;"
167
  else
168
    echo "const char *xmltarget_${name} = \"@<target>\\"
169
    if test "${xmlarch}" != x; then
170
      echo "<architecture>${xmlarch}</architecture>\\"
171
    fi
172
    if test "${xmlosabi}" != x; then
173
      echo "<osabi>${xmlosabi}</osabi>\\"
174
    fi
175
    echo "</target>\";"
176
  fi
177
else
178
  echo "const char *xmltarget_${name} = \"${xmltarget}\";"
179
fi
180
echo
181
 
182
cat <<EOF
183
void
184
init_registers_${name} ()
185
{
186
    set_register_cache (regs_${name},
187
                        sizeof (regs_${name}) / sizeof (regs_${name}[0]));
188
    gdbserver_expedite_regs = expedite_regs_${name};
189
    gdbserver_xmltarget = xmltarget_${name};
190
}
191
EOF
192
 
193
# close things off
194
exec 1>&2
195
move_if_change $2

powered by: WebSVN 2.1.0

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