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