gdb: make gdbarch.sh write gdbarch.{c,h} directly

It was suggested in this thread [1] that gdbarch.sh should write to
gdbarch.h and gdbarch.c directly.  This patch implements that.

When running gdbarch.sh, we currently need to move new-gdbarch.c over
gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
but with git it's really unnecessary.  Any changes to gdbarch.sh can be
inspected using `git diff`.

A next step would be to have the Makefile automatically run gdbarch.sh
if it sees that gdbarch.c and gdbarch.h are out of date.  Or maybe even
remove gdbarch.c and gdbarch.h from the tree and generate them in the
build directory when building.  But that requires more thinking and
discussions, and I think that this change is already useful in itself.

[1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html

gdb/ChangeLog;

	* gdbarch.sh: Write to gdbarch.c/gdbarch.h directly.  Don't
	compare old and new versions.
	(compare_new): Remove.

Change-Id: I7970a9e8af0afc0145cb5a28e73d94fbaa1e25b9
This commit is contained in:
Simon Marchi 2020-05-11 17:18:25 -04:00 committed by Simon Marchi
parent e08bd6c508
commit 41a77cbaad
3 changed files with 8 additions and 55 deletions

View File

@ -20,17 +20,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file was created with the aid of ``gdbarch.sh''.
The Bourne shell script ``gdbarch.sh'' creates the files
``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
against the existing ``gdbarch.[hc]''. Any differences found
being reported.
If editing this file, please also run gdbarch.sh and merge any
changes into that script. Conversely, when making sweeping changes
to this file, modifying gdbarch.sh and using its output may prove
easier. */
/* This file was created with the aid of ``gdbarch.sh''. */
#include "defs.h"

View File

@ -20,17 +20,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file was created with the aid of ``gdbarch.sh''.
The Bourne shell script ``gdbarch.sh'' creates the files
``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
against the existing ``gdbarch.[hc]''. Any differences found
being reported.
If editing this file, please also run gdbarch.sh and merge any
changes into that script. Conversely, when making sweeping changes
to this file, modifying gdbarch.sh and using its output may prove
easier. */
/* This file was created with the aid of ``gdbarch.sh''. */
#ifndef GDBARCH_H
#define GDBARCH_H

View File

@ -24,22 +24,6 @@
LANG=C ; export LANG
LC_ALL=C ; export LC_ALL
compare_new ()
{
file=$1
if test ! -r "${file}"
then
echo "${file} missing? cp new-${file} ${file}" 1>&2
elif diff -u "${file}" "new-${file}"
then
echo "${file} unchanged" 1>&2
else
echo "${file} has changed? cp new-${file} ${file}" 1>&2
fi
}
# Format of the input table
read="class returntype function formal actual staticdefault predefault postdefault invalid_p print garbage_at_eol"
@ -1203,7 +1187,7 @@ EOF
#
# The .log file
#
exec > new-gdbarch.log
exec > gdbarch.log
function_list | while do_read
do
cat <<EOF
@ -1239,7 +1223,6 @@ EOF
done
exec 1>&2
compare_new gdbarch.log
copyright ()
@ -1267,17 +1250,7 @@ cat <<EOF
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file was created with the aid of \`\`gdbarch.sh''.
The Bourne shell script \`\`gdbarch.sh'' creates the files
\`\`new-gdbarch.c'' and \`\`new-gdbarch.h and then compares them
against the existing \`\`gdbarch.[hc]''. Any differences found
being reported.
If editing this file, please also run gdbarch.sh and merge any
changes into that script. Conversely, when making sweeping changes
to this file, modifying gdbarch.sh and using its output may prove
easier. */
/* This file was created with the aid of \`\`gdbarch.sh''. */
EOF
}
@ -1695,8 +1668,8 @@ gdbarch_num_cooked_regs (gdbarch *arch)
#endif
EOF
exec 1>&2
#../move-if-change new-gdbarch.h gdbarch.h
compare_new gdbarch.h
../move-if-change new-gdbarch.h gdbarch.h
rm -f new-gdbarch.h
#
@ -2605,5 +2578,5 @@ EOF
# close things off
exec 1>&2
#../move-if-change new-gdbarch.c gdbarch.c
compare_new gdbarch.c
../move-if-change new-gdbarch.c gdbarch.c
rm -f new-gdbarch.c