#!/bin/sh -u
# Register protocol definitions for GDB, the GNU debugger.
# Copyright (C) 2001-2016 Free Software Foundation, Inc.
#
# This file is part of GDB.
#
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# Format of the input files
read="type entry"
do_read ()
{
type=""
entry=""
while read line
do
if test "${line}" = ""
then
continue
elif test "${line}" = "#" -a "${comment}" = ""
then
continue
elif expr "${line}" : "#" > /dev/null
then
comment="${comment}
${line}"
else
# The semantics of IFS varies between different SH's. Some
# treat ``::' as three fields while some treat it as just too.
# Work around this by eliminating ``::'' ....
line="`echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g'`"
OFS="${IFS}" ; IFS="[:]"
eval read ${read} <&2
exit 1
fi
copyright ()
{
cat <. */
/* This file was created with the aid of \`\`regdat.sh'' and \`\`$1''. */
EOF
}
exec > new-$2
copyright $1
echo '#include "server.h"'
echo '#include "regdef.h"'
echo '#include "tdesc.h"'
echo
offset=0
i=0
name=x
xmltarget=x
xmlarch=x
xmlosabi=x
expedite=x
exec < $1
while do_read
do
if test "${type}" = "name"; then
name="${entry}"
echo "static struct reg regs_${name}[] = {"
continue
elif test "${type}" = "xmltarget"; then
xmltarget="${entry}"
continue
elif test "${type}" = "xmlarch"; then
xmlarch="${entry}"
continue
elif test "${type}" = "osabi"; then
xmlosabi="${entry}"
continue
elif test "${type}" = "expedite"; then
expedite="${entry}"
continue
elif test "${name}" = x; then
echo "$0: $1 does not specify \`\`name''." 1>&2
exit 1
else
echo " { \"${entry}\", ${offset}, ${type} },"
offset=`expr ${offset} + ${type}`
i=`expr $i + 1`
fi
done
echo "};"
echo
echo "static const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };"
if test "${xmltarget}" = x; then
if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
echo "static const char *xmltarget_${name} = 0;"
else
echo "static const char *xmltarget_${name} = \"@\\"
if test "${xmlarch}" != x; then
echo "${xmlarch}\\"
fi
if test "${xmlosabi}" != x; then
echo "${xmlosabi}\\"
fi
echo "\";"
fi
else
echo "static const char *xmltarget_${name} = \"${xmltarget}\";"
fi
echo
cat <reg_defs = regs_${name};
result->num_registers = sizeof (regs_${name}) / sizeof (regs_${name}[0]);
result->expedite_regs = expedite_regs_${name};
result->xmltarget = xmltarget_${name};
init_target_desc (result);
tdesc_${name} = result;
}
EOF
# close things off
exec 1>&2
mv -- "new-$2" "$2"