Add support to show the symbolic names of the MIPS CP1 registers.
[deliverable/binutils-gdb.git] / gdb / regformats / regdat.sh
CommitLineData
3cf384d4
DJ
1#!/bin/sh -u
2
3# Register protocol definitions for GDB, the GNU debugger.
0b1afbb3 4# Copyright (C) 2001-2013 Free Software Foundation, Inc.
3cf384d4
DJ
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
50efebf8 10# the Free Software Foundation; either version 3 of the License, or
3cf384d4
DJ
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
50efebf8 19# along with this program. If not, see <http://www.gnu.org/licenses/>.
3cf384d4
DJ
20
21move_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
34read="type entry"
35
36do_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}
62EOF
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
86if test ! -r $1; then
87 echo "$0: Could not open $1." 1>&2
88 exit 1
89fi
90
91copyright ()
92{
93cat <<EOF
94/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
95
96/* A register protocol for GDB, the GNU debugger.
0b1afbb3 97 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3cf384d4
DJ
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
dcf7800b 103 the Free Software Foundation; either version 3 of the License, or
3cf384d4
DJ
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
dcf7800b 112 along with this program. If not, see <http://www.gnu.org/licenses/>. */
3cf384d4
DJ
113
114/* This file was created with the aid of \`\`regdat.sh'' and \`\`$1''. */
115
116EOF
117}
118
119
120exec > new-$2
121copyright $1
219f2f23 122echo '#include "server.h"'
3cf384d4 123echo '#include "regdef.h"'
3aee8918 124echo '#include "tdesc.h"'
3cf384d4
DJ
125echo
126offset=0
127i=0
128name=x
9b4b61c8 129xmltarget=x
08d16641
PA
130xmlarch=x
131xmlosabi=x
3cf384d4
DJ
132expedite=x
133exec < $1
134while do_read
135do
136 if test "${type}" = "name"; then
137 name="${entry}"
3aee8918 138 echo "static struct reg regs_${name}[] = {"
3cf384d4 139 continue
9b4b61c8
UW
140 elif test "${type}" = "xmltarget"; then
141 xmltarget="${entry}"
142 continue
143 elif test "${type}" = "xmlarch"; then
08d16641
PA
144 xmlarch="${entry}"
145 continue
146 elif test "${type}" = "osabi"; then
147 xmlosabi="${entry}"
9b4b61c8 148 continue
3cf384d4
DJ
149 elif test "${type}" = "expedite"; then
150 expedite="${entry}"
151 continue
152 elif test "${name}" = x; then
153 echo "$0: $1 does not specify \`\`name''." 1>&2
154 exit 1
155 else
156 echo " { \"${entry}\", ${offset}, ${type} },"
157 offset=`expr ${offset} + ${type}`
158 i=`expr $i + 1`
159 fi
160done
161
162echo "};"
163echo
3aee8918 164echo "static const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };"
9b4b61c8 165if test "${xmltarget}" = x; then
08d16641 166 if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
3aee8918 167 echo "static const char *xmltarget_${name} = 0;"
08d16641 168 else
3aee8918 169 echo "static const char *xmltarget_${name} = \"@<target>\\"
08d16641
PA
170 if test "${xmlarch}" != x; then
171 echo "<architecture>${xmlarch}</architecture>\\"
172 fi
173 if test "${xmlosabi}" != x; then
174 echo "<osabi>${xmlosabi}</osabi>\\"
175 fi
176 echo "</target>\";"
177 fi
9b4b61c8 178else
3aee8918 179 echo "static const char *xmltarget_${name} = \"${xmltarget}\";"
9b4b61c8 180fi
0a30fbc4
DJ
181echo
182
183cat <<EOF
3aee8918
PA
184const struct target_desc *tdesc_${name};
185
0a30fbc4 186void
3aee8918 187init_registers_${name} (void)
0a30fbc4 188{
3aee8918
PA
189 static struct target_desc tdesc_${name}_s;
190 struct target_desc *result = &tdesc_${name}_s;
191
192 result->reg_defs = regs_${name};
193 result->num_registers = sizeof (regs_${name}) / sizeof (regs_${name}[0]);
194 result->expedite_regs = expedite_regs_${name};
195 result->xmltarget = xmltarget_${name};
196
197 init_target_desc (result);
198
199 tdesc_${name} = result;
0a30fbc4
DJ
200}
201EOF
3cf384d4
DJ
202
203# close things off
204exec 1>&2
205move_if_change $2
This page took 1.043745 seconds and 4 git commands to generate.