xref: /dflybsd-src/contrib/gdb-7/gdb/regformats/regdat.sh (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert#!/bin/sh -u
25796c8dcSSimon Schubert
35796c8dcSSimon Schubert# Register protocol definitions for GDB, the GNU debugger.
4*ef5ccd6cSJohn Marino# Copyright (C) 2001-2013 Free Software Foundation, Inc.
55796c8dcSSimon Schubert#
65796c8dcSSimon Schubert# This file is part of GDB.
75796c8dcSSimon Schubert#
85796c8dcSSimon Schubert# This program is free software; you can redistribute it and/or modify
95796c8dcSSimon Schubert# it under the terms of the GNU General Public License as published by
105796c8dcSSimon Schubert# the Free Software Foundation; either version 3 of the License, or
115796c8dcSSimon Schubert# (at your option) any later version.
125796c8dcSSimon Schubert#
135796c8dcSSimon Schubert# This program is distributed in the hope that it will be useful,
145796c8dcSSimon Schubert# but WITHOUT ANY WARRANTY; without even the implied warranty of
155796c8dcSSimon Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165796c8dcSSimon Schubert# GNU General Public License for more details.
175796c8dcSSimon Schubert#
185796c8dcSSimon Schubert# You should have received a copy of the GNU General Public License
195796c8dcSSimon Schubert# along with this program.  If not, see <http://www.gnu.org/licenses/>.
205796c8dcSSimon Schubert
215796c8dcSSimon Schubertmove_if_change ()
225796c8dcSSimon Schubert{
235796c8dcSSimon Schubert    file=$1
245796c8dcSSimon Schubert    if test -r ${file} && cmp -s "${file}" new-"${file}"
255796c8dcSSimon Schubert    then
265796c8dcSSimon Schubert	echo "${file} unchanged." 1>&2
275796c8dcSSimon Schubert    else
285796c8dcSSimon Schubert	mv new-"${file}" "${file}"
295796c8dcSSimon Schubert	echo "${file} updated." 1>&2
305796c8dcSSimon Schubert    fi
315796c8dcSSimon Schubert}
325796c8dcSSimon Schubert
335796c8dcSSimon Schubert# Format of the input files
345796c8dcSSimon Schubertread="type entry"
355796c8dcSSimon Schubert
365796c8dcSSimon Schubertdo_read ()
375796c8dcSSimon Schubert{
385796c8dcSSimon Schubert    type=""
395796c8dcSSimon Schubert    entry=""
405796c8dcSSimon Schubert    while read line
415796c8dcSSimon Schubert    do
425796c8dcSSimon Schubert	if test "${line}" = ""
435796c8dcSSimon Schubert	then
445796c8dcSSimon Schubert	    continue
455796c8dcSSimon Schubert	elif test "${line}" = "#" -a "${comment}" = ""
465796c8dcSSimon Schubert	then
475796c8dcSSimon Schubert	    continue
485796c8dcSSimon Schubert	elif expr "${line}" : "#" > /dev/null
495796c8dcSSimon Schubert	then
505796c8dcSSimon Schubert	    comment="${comment}
515796c8dcSSimon Schubert${line}"
525796c8dcSSimon Schubert	else
535796c8dcSSimon Schubert
545796c8dcSSimon Schubert	    # The semantics of IFS varies between different SH's.  Some
555796c8dcSSimon Schubert	    # treat ``::' as three fields while some treat it as just too.
565796c8dcSSimon Schubert	    # Work around this by eliminating ``::'' ....
575796c8dcSSimon Schubert	    line="`echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g'`"
585796c8dcSSimon Schubert
595796c8dcSSimon Schubert	    OFS="${IFS}" ; IFS="[:]"
605796c8dcSSimon Schubert	    eval read ${read} <<EOF
615796c8dcSSimon Schubert${line}
625796c8dcSSimon SchubertEOF
635796c8dcSSimon Schubert	    IFS="${OFS}"
645796c8dcSSimon Schubert
655796c8dcSSimon Schubert	    # .... and then going back through each field and strip out those
665796c8dcSSimon Schubert	    # that ended up with just that space character.
675796c8dcSSimon Schubert	    for r in ${read}
685796c8dcSSimon Schubert	    do
695796c8dcSSimon Schubert		if eval test \"\${${r}}\" = \"\ \"
705796c8dcSSimon Schubert		then
715796c8dcSSimon Schubert		    eval ${r}=""
725796c8dcSSimon Schubert		fi
735796c8dcSSimon Schubert	    done
745796c8dcSSimon Schubert
755796c8dcSSimon Schubert	    break
765796c8dcSSimon Schubert	fi
775796c8dcSSimon Schubert    done
785796c8dcSSimon Schubert    if [ -n "${type}" ]
795796c8dcSSimon Schubert    then
805796c8dcSSimon Schubert	true
815796c8dcSSimon Schubert    else
825796c8dcSSimon Schubert	false
835796c8dcSSimon Schubert    fi
845796c8dcSSimon Schubert}
855796c8dcSSimon Schubert
865796c8dcSSimon Schubertif test ! -r $1; then
875796c8dcSSimon Schubert  echo "$0: Could not open $1." 1>&2
885796c8dcSSimon Schubert  exit 1
895796c8dcSSimon Schubertfi
905796c8dcSSimon Schubert
915796c8dcSSimon Schubertcopyright ()
925796c8dcSSimon Schubert{
935796c8dcSSimon Schubertcat <<EOF
945796c8dcSSimon Schubert/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
955796c8dcSSimon Schubert
965796c8dcSSimon Schubert/* A register protocol for GDB, the GNU debugger.
97*ef5ccd6cSJohn Marino   Copyright (C) 2001-2013 Free Software Foundation, Inc.
985796c8dcSSimon Schubert
995796c8dcSSimon Schubert   This file is part of GDB.
1005796c8dcSSimon Schubert
1015796c8dcSSimon Schubert   This program is free software; you can redistribute it and/or modify
1025796c8dcSSimon Schubert   it under the terms of the GNU General Public License as published by
103cf7f2e2dSJohn Marino   the Free Software Foundation; either version 3 of the License, or
1045796c8dcSSimon Schubert   (at your option) any later version.
1055796c8dcSSimon Schubert
1065796c8dcSSimon Schubert   This program is distributed in the hope that it will be useful,
1075796c8dcSSimon Schubert   but WITHOUT ANY WARRANTY; without even the implied warranty of
1085796c8dcSSimon Schubert   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1095796c8dcSSimon Schubert   GNU General Public License for more details.
1105796c8dcSSimon Schubert
1115796c8dcSSimon Schubert   You should have received a copy of the GNU General Public License
112cf7f2e2dSJohn Marino   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
1135796c8dcSSimon Schubert
1145796c8dcSSimon Schubert/* This file was created with the aid of \`\`regdat.sh'' and \`\`$1''.  */
1155796c8dcSSimon Schubert
1165796c8dcSSimon SchubertEOF
1175796c8dcSSimon Schubert}
1185796c8dcSSimon Schubert
1195796c8dcSSimon Schubert
1205796c8dcSSimon Schubertexec > new-$2
1215796c8dcSSimon Schubertcopyright $1
122cf7f2e2dSJohn Marinoecho '#include "server.h"'
1235796c8dcSSimon Schubertecho '#include "regdef.h"'
1245796c8dcSSimon Schubertecho
1255796c8dcSSimon Schubertoffset=0
1265796c8dcSSimon Schuberti=0
1275796c8dcSSimon Schubertname=x
1285796c8dcSSimon Schubertxmltarget=x
1295796c8dcSSimon Schubertxmlarch=x
1305796c8dcSSimon Schubertxmlosabi=x
1315796c8dcSSimon Schubertexpedite=x
1325796c8dcSSimon Schubertexec < $1
1335796c8dcSSimon Schubertwhile do_read
1345796c8dcSSimon Schubertdo
1355796c8dcSSimon Schubert  if test "${type}" = "name"; then
1365796c8dcSSimon Schubert    name="${entry}"
1375796c8dcSSimon Schubert    echo "struct reg regs_${name}[] = {"
1385796c8dcSSimon Schubert    continue
1395796c8dcSSimon Schubert  elif test "${type}" = "xmltarget"; then
1405796c8dcSSimon Schubert    xmltarget="${entry}"
1415796c8dcSSimon Schubert    continue
1425796c8dcSSimon Schubert  elif test "${type}" = "xmlarch"; then
1435796c8dcSSimon Schubert    xmlarch="${entry}"
1445796c8dcSSimon Schubert    continue
1455796c8dcSSimon Schubert  elif test "${type}" = "osabi"; then
1465796c8dcSSimon Schubert    xmlosabi="${entry}"
1475796c8dcSSimon Schubert    continue
1485796c8dcSSimon Schubert  elif test "${type}" = "expedite"; then
1495796c8dcSSimon Schubert    expedite="${entry}"
1505796c8dcSSimon Schubert    continue
1515796c8dcSSimon Schubert  elif test "${name}" = x; then
1525796c8dcSSimon Schubert    echo "$0: $1 does not specify \`\`name''." 1>&2
1535796c8dcSSimon Schubert    exit 1
1545796c8dcSSimon Schubert  else
1555796c8dcSSimon Schubert    echo "  { \"${entry}\", ${offset}, ${type} },"
1565796c8dcSSimon Schubert    offset=`expr ${offset} + ${type}`
1575796c8dcSSimon Schubert    i=`expr $i + 1`
1585796c8dcSSimon Schubert  fi
1595796c8dcSSimon Schubertdone
1605796c8dcSSimon Schubert
1615796c8dcSSimon Schubertecho "};"
1625796c8dcSSimon Schubertecho
1635796c8dcSSimon Schubertecho "const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };"
1645796c8dcSSimon Schubertif test "${xmltarget}" = x; then
1655796c8dcSSimon Schubert  if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
1665796c8dcSSimon Schubert    echo "const char *xmltarget_${name} = 0;"
1675796c8dcSSimon Schubert  else
1685796c8dcSSimon Schubert    echo "const char *xmltarget_${name} = \"@<target>\\"
1695796c8dcSSimon Schubert    if test "${xmlarch}" != x; then
1705796c8dcSSimon Schubert      echo "<architecture>${xmlarch}</architecture>\\"
1715796c8dcSSimon Schubert    fi
1725796c8dcSSimon Schubert    if test "${xmlosabi}" != x; then
1735796c8dcSSimon Schubert      echo "<osabi>${xmlosabi}</osabi>\\"
1745796c8dcSSimon Schubert    fi
1755796c8dcSSimon Schubert    echo "</target>\";"
1765796c8dcSSimon Schubert  fi
1775796c8dcSSimon Schubertelse
1785796c8dcSSimon Schubert  echo "const char *xmltarget_${name} = \"${xmltarget}\";"
1795796c8dcSSimon Schubertfi
1805796c8dcSSimon Schubertecho
1815796c8dcSSimon Schubert
1825796c8dcSSimon Schubertcat <<EOF
1835796c8dcSSimon Schubertvoid
1845796c8dcSSimon Schubertinit_registers_${name} ()
1855796c8dcSSimon Schubert{
1865796c8dcSSimon Schubert    set_register_cache (regs_${name},
1875796c8dcSSimon Schubert			sizeof (regs_${name}) / sizeof (regs_${name}[0]));
1885796c8dcSSimon Schubert    gdbserver_expedite_regs = expedite_regs_${name};
1895796c8dcSSimon Schubert    gdbserver_xmltarget = xmltarget_${name};
1905796c8dcSSimon Schubert}
1915796c8dcSSimon SchubertEOF
1925796c8dcSSimon Schubert
1935796c8dcSSimon Schubert# close things off
1945796c8dcSSimon Schubertexec 1>&2
1955796c8dcSSimon Schubertmove_if_change $2
196