summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/reghunt/ChangeLog25
-rwxr-xr-xcontrib/reghunt/bin/gcc-build-full52
-rwxr-xr-xcontrib/reghunt/bin/gcc-build-simple79
-rwxr-xr-xcontrib/reghunt/bin/gcc-cleanup20
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-checkfail9
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-ids88
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-patchlist85
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-recordfail8
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-report26
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-update117
-rwxr-xr-xcontrib/reghunt/bin/gcc-svn-update-fix113
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-accepts-invalid48
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-bogus-warning42
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-compiler-hangs63
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-ice-on-invalid-code54
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-ice-on-valid-code48
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-missing-warning42
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-rejects-valid48
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-segfault-on-valid-code49
-rwxr-xr-xcontrib/reghunt/bin/gcc-test-wrong-code42
-rwxr-xr-xcontrib/reghunt/bin/reg-hunt363
-rwxr-xr-xcontrib/reghunt/bin/reg-newmid86
-rwxr-xr-xcontrib/reghunt/bin/reg-test152
23 files changed, 1659 insertions, 0 deletions
diff --git a/contrib/reghunt/ChangeLog b/contrib/reghunt/ChangeLog
index a8632205ba2..24625a26bd6 100644
--- a/contrib/reghunt/ChangeLog
+++ b/contrib/reghunt/ChangeLog
@@ -1,5 +1,30 @@
2009-02-17 Janis Johnson <janis187@us.ibm.com>
+ * bin: New directory.
+ * bin/reg-hunt: New.
+ * bin/reg_periodic: New.
+ * bin/gcc-svn-update: New.
+ * bin/gcc-svn-update-fix: New.
+ * bin/gcc-build-simple: New.
+ * bin/gcc-build-full: New.
+ * bin/gcc-cleanup: New.
+ * bin/reg-test: New.
+ * bin/reg-newmid: New.
+ * bin/gcc-test-ice-on-valid-code: New.
+ * bin/gcc-test-ice-on-invalid-code: New.
+ * bin/gcc-test-compiler-hangs: New.
+ * bin/gcc-test-missing-warning: New.
+ * bin/gcc-test-bogus-warning: New.
+ * bin/gcc-test-segfault-on-valid-code: New.
+ * bin/gcc-test-rejects-valid: New.
+ * bin/gcc-test-accepts-invalid: New.
+ * bin/gcc-test-wrong-code: New.
+ * bin/gcc-svn-patchlist: New.
+ * bin/gcc-svn-checkfail: New.
+ * bin/gcc-svn-recordfail: New.
+ * bin/gcc-svn-report: New.
+ * bin/gcc-svn-ids: New.
+
* date_based: New directory.
* README: Move from here ...
* date_based/README: to here.
diff --git a/contrib/reghunt/bin/gcc-build-full b/contrib/reghunt/bin/gcc-build-full
new file mode 100755
index 00000000000..21e6d684fed
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-build-full
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+# Perform a simple build of GCC for a particular language, using several
+# environment variables defined by reghunt scripts and config files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+abort() {
+ echo "`date` $1"
+ exit 1
+}
+
+ID=$1
+LOGDIR=${REG_BUILDDIR}/logs/${BUGID}/${ID}
+mkdir -p $LOGDIR
+
+echo "`date` building GCC ($REG_LANGS) for id ${ID}"
+
+cd $REG_BUILDDIR
+rm -rf obj
+mkdir obj
+cd obj
+
+echo "REG_CONFOPTS = $REG_CONFOPTS" > ${LOGDIR}/configure.log
+echo "REG_PREFIX = $REG_PREFIX" >> ${LOGDIR}/configure.log
+echo "REG_LANGS = $REG_LANGS" >> ${LOGDIR}/configure.log
+echo >> ${LOGDIR}/configure.log
+
+${REG_GCCSRC}/configure \
+ --prefix=$REG_PREFIX \
+ $REG_CONFOPTS \
+ --enable-languages=$REG_LANGS \
+ >> ${LOGDIR}/configure.log 2>&1 || abort " configure failed"
+
+make $REG_MAKE_J > ${LOGDIR}/make.log 2>&1 || abort " make failed"
+make install > ${LOGDIR}/make.install.log 2>&1 || abort " make install failed"
+
+exit 0
diff --git a/contrib/reghunt/bin/gcc-build-simple b/contrib/reghunt/bin/gcc-build-simple
new file mode 100755
index 00000000000..f2d8ea39cc6
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-build-simple
@@ -0,0 +1,79 @@
+#! /bin/sh
+
+# Build a GCC compiler, using environment variables defined by several
+# reghunt scripts and config files.
+#
+# This doesn't work for sources earlier than about 2003-02-25.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID="${1}"
+LOGDIR=${REG_BUILDDIR}/logs/${BUGID}/${ID}
+mkdir -p $LOGDIR
+
+msg() {
+ echo "`date` ${1}"
+}
+
+abort() {
+ msg "${1}"
+ exit 1
+}
+
+msg "building $REG_COMPILER for id $ID"
+
+rm -rf $REG_OBJDIR
+mkdir $REG_OBJDIR
+cd $REG_OBJDIR
+
+#msg "configure"
+${REG_GCCSRC}/configure \
+ --prefix=$REG_PREFIX \
+ --enable-languages=$REG_LANGS \
+ $REG_CONFOPTS \
+ > configure.log 2>&1 || abort " configure failed"
+
+#msg "make libraries"
+make all-build-libiberty > ${LOGDIR}/make.all-build-libiberty.log 2>&1 || true
+make all-libcpp > ${LOGDIR}/make.all-libcpp.log 2>&1 || true
+make all-libdecnumber > ${LOGDIR}/make.all-libdecnumber.log 2>&1 || true
+make all-intl > ${LOGDIR}/make.all-intl.log 2>&1 || true
+make all-libbanshee > ${LOGDIR}/make.all-libbanshee.log 2>&1 || true
+make configure-gcc > ${LOGDIR}/make.configure-gcc.log 2>&1 || true
+
+# hack for 3.3 branch
+if [ ! -f libiberty/libiberty.a ]; then
+ if [ -d libiberty ]; then
+ # another hack for 3.2!
+ cd libiberty
+ make > ${LOGDIR}/make.libiberty.log 2>&1 || true
+ cd ..
+ else
+ mkdir -p libiberty
+ cd libiberty
+ ln -s ../build-${REG_BLD}/libiberty/libiberty.a .
+ cd ..
+ fi
+fi
+
+cd gcc
+# REG_COMPILER is cc1, cc1plus, or f951
+#msg "make $REG_COMPILER"
+make $REG_MAKE_J $REG_COMPILER > ${LOGDIR}/make.${REG_COMPILER}.log 2>&1 \
+ || abort " make failed"
+msg "build completed"
+exit 0
diff --git a/contrib/reghunt/bin/gcc-cleanup b/contrib/reghunt/bin/gcc-cleanup
new file mode 100755
index 00000000000..3ec1b8f050e
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-cleanup
@@ -0,0 +1,20 @@
+#! /bin/sh
+
+# Clean up between regression hunts.
+
+if [ "x${REG_SRCDIR}" = "x" ]; then
+ if [ -f gcc-svn-env ]; then
+ . ./gcc-svn-env
+ elif [ -f ../gcc-svn-env ]; then
+ . ../gcc-svn-env
+ elif [ -f ${HOME}/etc/gcc-svn-env ]; then
+ . ${HOME}/etc/gcc-svn-env
+ else
+ echo "$0: could not find gcc-svn-env file"
+ exit 1
+ fi
+fi
+
+rm -rf ${REG_SRCDIR}/gcc
+rm -rf ${REG_BUILDDIR}/obj
+rm -rf ${REG_PREFIX}
diff --git a/contrib/reghunt/bin/gcc-svn-checkfail b/contrib/reghunt/bin/gcc-svn-checkfail
new file mode 100755
index 00000000000..3877a062bf8
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-checkfail
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+# Given an identifier that is an index into the current patch list,
+# return 1 if the corresponding SVN revision number is in the list of
+# known failures, 0 otherwise.
+
+ID=$1
+REV=`${REG_IDS} -f index -t rev ${ID}`
+grep -q "^${REV}$" ${REG_FAILLIST}
diff --git a/contrib/reghunt/bin/gcc-svn-ids b/contrib/reghunt/bin/gcc-svn-ids
new file mode 100755
index 00000000000..98602cc3e63
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-ids
@@ -0,0 +1,88 @@
+#! /bin/sh
+
+# Convert one kind of changeset identifier to another.
+#
+# Usage: gcc-svn-ids -f from_kind -t to_kind id
+#
+# Where from_kind is one of:
+# index index into the changeset list used by the reghunt tools
+# rev is the Subversion revision name
+# and to_kind is one of:
+# index index into the changeset list used by the reghunt tools
+# rev is the Subversion revision name
+# date expanded UTC date string
+# branch the branch, or "trunk" for mainline
+# author the person who checked in the patch
+
+errmsg () {
+ echo $1 1>&2
+}
+
+usage () {
+ echo 'cvs_ids -f kind -t kind id' 1>&2
+ echo ' where from_kind is index or rev' 1>&2
+ echo ' and to_kind is index, rev, date, author, or branch' 1>&2
+ echo "error"
+ exit 1
+}
+
+if [ "x${REG_CHANGESET_LIST}" = "x" ]; then
+ errmsg "REG_CHANGESET_LIST is not defined"
+ echo "error"
+ exit 1
+fi
+
+if [ ! -f ${REG_CHANGESET_LIST} ]; then
+ errmsg "changeset list ${REG_CHANGESET_LIST} does not exist"
+ echo "error"
+ exit 1
+fi
+
+# Use a shorter name here.
+LIST=${REG_CHANGESET_LIST}
+
+while getopts "f:t:" ARG; do
+ case ${ARG} in
+ f) FROM_KIND="${OPTARG}";;
+ t) TO_KIND="${OPTARG}";;
+ h) usage;;
+ *) errmsg "unrecognized option: ${ARG}";
+ usage;;
+ esac
+done
+shift `expr ${OPTIND} - 1`
+
+if [ $# -eq 0 ]; then
+ errmsg "too few arguments, ID is missing"
+ usage
+fi
+if [ $# -gt 1 ]; then
+ errmsg "unexpected arguments: $*"
+ usage
+fi
+ID="$1"
+
+case ${FROM_KIND} in
+index) LINE="`awk -F '|' -v id="${ID}" '{if ($1 == id) print }' < ${LIST}`";;
+rev) LINE="`awk -F '|' -v id="${ID}" '{if ($2 == id) print }' < ${LIST}`";;
+*) errmsg "unrecognized FROM kind: ${FROM_KIND}";
+ usage;;
+esac
+
+if [ "x${LINE}" = "x" ]; then
+ errmsg "no entry found for ${FROM_KIND} = ${ID}"
+ echo "error"
+ exit 1
+fi
+
+case ${TO_KIND} in
+index) TO_ID="`echo ${LINE} | awk -F '|' '{ print $1 }'`";;
+rev) TO_ID="`echo ${LINE} | awk -F '|' '{ print $2 }'`";;
+author) TO_ID="`echo ${LINE} | awk -F '|' '{ print $3 }'`";;
+date) TO_ID="`echo ${LINE} | awk -F '|' '{ print $4 }'`";;
+branch) TO_ID="`echo ${LINE} | awk -F '|' '{ print $5 }'`";;
+*) errmsg "unrecognized TO kind: ${TO_KIND}";
+ usage;;
+esac
+
+echo ${TO_ID}
diff --git a/contrib/reghunt/bin/gcc-svn-patchlist b/contrib/reghunt/bin/gcc-svn-patchlist
new file mode 100755
index 00000000000..02b2046a8f0
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-patchlist
@@ -0,0 +1,85 @@
+#! /bin/bash
+
+# Make a list of revisions for commits to the branch of interest (trunk
+# by default) between the specified dates. This skips commits that do
+# not modify any existing files and changes by gccadmin.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+#set -ex
+
+abort() {
+ echo "$@"
+ exit 1
+}
+
+test $# -lt 2 && abort "usage: $0 low_date high_date [branch]"
+
+export TZ=UTC
+LOW_DATE="$1"
+HIGH_DATE="$2"
+
+if [ $# -eq 3 ]; then
+ BRANCH="$3"
+else
+ BRANCH=""
+fi
+
+# Verify branch name, convert a short name to the real one.
+
+case $BRANCH in
+"") BRANCH="trunk";;
+mline) BRANCH="trunk";;
+mainline) BRANCH="trunk";;
+4.1) BRANCH="gcc-4_1-branch";;
+gcc-4_1-branch) ;;
+4.0) BRANCH="gcc-4_0-branch";;
+gcc-4_0-branch) ;;
+3.4) BRANCH="gcc-3_4-branch";;
+gcc-3_4-branch) ;;
+*) ;; # abort "$0: unrecognized branch $BRANCH"
+esac
+
+if [ "${BRANCH}" = "trunk" ]; then
+ BRANCHPATH=trunk
+else
+ BRANCHPATH=branches/${BRANCH}
+fi
+
+# Get the revision at the time of LOW_DATE.
+
+LOW_REV=`svn info --revision {"${LOW_DATE}"} \
+ ${REG_SVN_REPO}/${BRANCHPATH} \
+ | awk '/Revision:/ { print $2 }'`
+
+# Create the list of information for LOW_REV through HIGH_DATE in a
+# form expected by gcc-svn-ids.
+
+svn log --quiet --non-interactive \
+ --revision ${LOW_REV}:{"${HIGH_DATE}"} \
+ ${REG_SVN_REPO}/${BRANCHPATH} \
+ | awk -v branch=$BRANCH \
+ 'BEGIN { id=0 }
+ /---/ { next }
+ /(no author)/ { next }
+ /gccadmin/ { next }
+ { sub(" \\+0000 (.*)","")
+ sub("r","",$1)
+ gsub(" \\| ","|")
+ id++
+ print id "|" $0 "|" branch
+ }'
diff --git a/contrib/reghunt/bin/gcc-svn-recordfail b/contrib/reghunt/bin/gcc-svn-recordfail
new file mode 100755
index 00000000000..cf5cde7540b
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-recordfail
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+# Given an identifier that is an index into the current patch list,
+# record the corresponding SVN number to the list of known failures.
+
+ID=$1
+REV=`${REG_IDS} -f index -t rev ${ID}`
+echo $REV >> ${REG_FAILLIST}
diff --git a/contrib/reghunt/bin/gcc-svn-report b/contrib/reghunt/bin/gcc-svn-report
new file mode 100755
index 00000000000..a0de534b3d5
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-report
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+# Report a more informative version of the patch identifier.
+
+ID=$1
+
+test "x${REG_IDS}" != "x" || exit 1
+test "x${REG_CHANGESET_LIST}" != "x" || exit 1
+
+BRANCH=`${REG_IDS} -f index -t branch ${ID}`
+cd ${REG_SRCDIR}/gcc
+unset LANG
+unset LC_ALL
+REV=`${REG_IDS} -f index -t rev ${ID}`
+
+# long set of information
+TZ=UTC \
+svn log --revision $REV
+
+# URL of diffs
+echo
+echo ' http://gcc.gnu.org/viewcvs?view=rev&rev='$REV
+
+# short set of information, without final line of hyphens
+TZ=UTC \
+svn log --quiet --revision $REV | sed -e '/---/d' -e 's/^/ /'
diff --git a/contrib/reghunt/bin/gcc-svn-update b/contrib/reghunt/bin/gcc-svn-update
new file mode 100755
index 00000000000..0f6aac86675
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-update
@@ -0,0 +1,117 @@
+#! /bin/bash
+
+# Update or check out GCC sources for a particular Subversion revision
+# and a particular branch.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+#set -ex
+
+if [ $# != 1 ]; then
+ echo Usage: $0 id
+ exit 1
+fi
+
+if [ "x${REG_DO_CLEANUPS}" != "x" ]; then
+ reg_cleanup
+fi
+
+ID=$1
+BRANCH=""
+
+########################################################################
+# Get sources.
+########################################################################
+
+svn_get() {
+ # In case there are problems with updates (there were with CVS),
+ # creating a file called REMOVE in the REG_SRCDIR directory causes us
+ # to start with a clean tree each time.
+
+ unset LC_ALL
+ unset LANG
+
+ cd ${REG_SRCDIR}
+ if [ -d gcc ]; then
+ # There's already a tree; do an update with the new revision.
+ cd gcc
+ echo "`date` svn update begun for id ${ID}, rev ${REV}"
+ echo svn update --non-interactive --revision ${REV} >> $LOG
+ svn update --non-interactive --revision ${REV} >> $LOG
+ if [ $? -eq 0 ]; then
+ echo "`date` svn update done"
+ else
+ echo "`date` svn update failed"
+ exit 1
+ fi
+ else
+ echo "`date` svn checkout begun for id ${ID}, rev ${REV}"
+ echo svn checkout --non-interactive --revision ${REV} \
+ ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
+ svn checkout --non-interactive --revision ${REV} \
+ ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
+ if [ $? -eq 0 ]; then
+ echo "`date` svn checkout done"
+ else
+ echo "`date` svn checkout failed"
+ exit 1
+ fi
+ cd gcc
+ fi
+
+ # Touch generated files.
+ contrib/gcc_update --touch >> $LOG
+}
+
+########################################################################
+# Main program
+########################################################################
+
+cd ${REG_SRCDIR}
+
+# This is a simple way to stop a long regression search fairly cleanly;
+# just touch a file called STOP.
+
+if [ -f STOP ]; then
+ echo "`date` $0 detected STOP file"
+ rm -f STOP
+ exit 1
+fi
+
+# Set up the log file.
+REV=`${REG_IDS} -f index -t rev ${ID}`
+LOG=${REG_SRCDIR}/logs/${BUGID}/${REV}.log
+mkdir -p ${REG_SRCDIR}/logs/${BUGID}
+rm -f $LOG
+touch $LOG
+
+# Get the branch for this patch.
+BRANCH=`${REG_IDS} -f index -t branch ${ID}`
+if [ "${BRANCH}" = "error" ]; then
+ echo "`date` $0: cannot determine the SVN branch for id ${ID}"
+ exit 1
+fi
+
+if [ "${BRANCH}" = "trunk" ]; then
+ BRANCHPATH=trunk
+else
+ BRANCHPATH=branches/${BRANCH}
+fi
+
+svn_get
+
+exit 0
diff --git a/contrib/reghunt/bin/gcc-svn-update-fix b/contrib/reghunt/bin/gcc-svn-update-fix
new file mode 100755
index 00000000000..9775055022a
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-svn-update-fix
@@ -0,0 +1,113 @@
+#! /bin/bash
+
+#set -ex
+
+# Update an SVN tree for a particular date.
+
+if [ $# != 1 ]; then
+ echo Usage: $0 id
+ exit 1
+fi
+
+if [ "x${REG_DO_CLEANUPS}" != "x" ]; then
+ reg_cleanup
+fi
+
+ID=$1
+BRANCH=""
+
+########################################################################
+# Get sources.
+########################################################################
+
+svn_get() {
+ # In case there are problems with updates (there were with CVS),
+ # creating a file called REMOVE in the REG_SRCDIR directory causes us
+ # to start with a clean tree each time.
+
+ unset LC_ALL
+ unset LANG
+
+ cd ${REG_SRCDIR}
+ if [ -d gcc ]; then
+ # There's already a tree; do an update with the new revision.
+ cd gcc
+ echo "`date` svn update begun for id ${ID}, rev ${REV} (fix)"
+ echo svn update --non-interactive --revision ${REV} >> $LOG
+ svn update --non-interactive --revision ${REV} >> $LOG
+ if [ $? -eq 0 ]; then
+ echo "`date` svn update done"
+ else
+ echo "`date` svn update failed"
+ exit 1
+ fi
+ else
+ echo "`date` svn checkout begun for id ${ID}, rev ${REV}"
+ echo svn checkout --non-interactive --revision ${REV} \
+ ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
+ svn checkout --non-interactive --revision ${REV} \
+ ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
+ if [ $? -eq 0 ]; then
+ echo "`date` svn checkout done"
+ else
+ echo "`date` svn checkout failed"
+ exit 1
+ fi
+ cd gcc
+ fi
+
+ # Touch generated files.
+ contrib/gcc_update --touch >> $LOG
+}
+
+########################################################################
+# Main program
+########################################################################
+
+cd ${REG_SRCDIR}
+
+# This is a simple way to stop a long regression search fairly cleanly;
+# just touch a file called STOP.
+
+if [ -f STOP ]; then
+ echo "`date` $0 detected STOP file"
+ rm -f STOP
+ exit 1
+fi
+
+# Set up the log file.
+REV=`${REG_IDS} -f index -t rev ${ID}`
+LOG=${REG_SRCDIR}/logs/${BUGID}/${REV}.log
+mkdir -p ${REG_SRCDIR}/logs/${BUGID}
+rm -f $LOG
+touch $LOG
+
+# Get the branch for this patch.
+BRANCH=`${REG_IDS} -f index -t branch ${ID}`
+if [ "${BRANCH}" = "error" ]; then
+ echo "`date` $0: cannot determine the SVN branch for id ${ID}"
+ exit 1
+fi
+
+if [ "${BRANCH}" = "trunk" ]; then
+ BRANCHPATH=trunk
+else
+ BRANCHPATH=branches/${BRANCH}
+fi
+
+svn_get
+
+# Look for a patch that's needed for this revision to build.
+FIX=${REG_PATCHES}/${REV}.fix
+echo "`date` looking for $FIX"
+if [ -f $FIX ]; then
+ echo "`date` fix needed; checking whether it is already applied"
+ cd ${REG_SRCDIR}/gcc
+ patch --dry-run -s -p0 -i $FIX < /dev/null > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "`date` applying fix"
+ patch -s -p0 -i $FIX
+ fi
+fi
+
+exit 0
diff --git a/contrib/reghunt/bin/gcc-test-accepts-invalid b/contrib/reghunt/bin/gcc-test-accepts-invalid
new file mode 100755
index 00000000000..564c0bbd7c4
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-accepts-invalid
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+# Test an "accepts-invalid" GCC bug, using environment variables set in
+# several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -eq 0 ]; then
+ echo "`date` test compiled successfully for ${MSGID}"
+ exit $REG_FAIL
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'error' ${LOG}
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: no error message for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` compilation failed for ${MSGID}"
+exit $REG_PASS
diff --git a/contrib/reghunt/bin/gcc-test-bogus-warning b/contrib/reghunt/bin/gcc-test-bogus-warning
new file mode 100755
index 00000000000..1bd0095ba98
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-bogus-warning
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# Test a "bogus-warning" GCC bug, using environment variables set in
+# several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: compilation failed for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'warning' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` bogus warning detected for ${MSGID}"
+ exit $REG_FAIL
+fi
+
+echo "`date` no bogus warning for ${MSGID}"
+exit $REG_PASS
diff --git a/contrib/reghunt/bin/gcc-test-compiler-hangs b/contrib/reghunt/bin/gcc-test-compiler-hangs
new file mode 100755
index 00000000000..043bc26991b
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-compiler-hangs
@@ -0,0 +1,63 @@
+#! /bin/sh
+
+# Test a bug for which the compiler hangs, using environment variables
+# set in several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+trap "echo \"`date` compiler hang for ${MSGID}\"; pkill -9 cc1; exit $REG_FAIL" SIGUSR1
+SLEEPCNT=10
+
+# Set up to trap the hang.
+sleep $SLEEPCNT && /bin/kill -s SIGUSR1 0 &
+SLEEPID=$!
+
+# This might hang.
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+# The command didn't hang. Capture its return value so we can check
+# whether it had other unexpected problems.
+RET=$?
+
+# Kill the sleep command so it won't finish normally and cause this
+# process to get a signal telling it to report a failure.
+/bin/kill $SLEEPID
+
+if [ $RET -eq 0 ]; then
+ echo "`date` test compiled successfully for ${MSGID}"
+ exit $REG_PASS
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q "egmentation fault"
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: segfault for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` unexpected failure for ${MSGID}"
+exit $REG_ERROR
diff --git a/contrib/reghunt/bin/gcc-test-ice-on-invalid-code b/contrib/reghunt/bin/gcc-test-ice-on-invalid-code
new file mode 100755
index 00000000000..6e449a84ac3
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-ice-on-invalid-code
@@ -0,0 +1,54 @@
+#! /bin/sh
+
+# Test an "ice-on-invalid-code" GCC bug, using environment variables set
+# in several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: compilation succeeded for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'internal compiler error' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` internal compiler error for ${MSGID}"
+ exit $REG_FAIL
+fi
+
+grep -q 'error' ${LOG}
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: no error message for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` compilation failed for ${MSGID}"
+exit $REG_PASS
diff --git a/contrib/reghunt/bin/gcc-test-ice-on-valid-code b/contrib/reghunt/bin/gcc-test-ice-on-valid-code
new file mode 100755
index 00000000000..ecc5fe04afc
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-ice-on-valid-code
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+# Test an "ice-on-valid-code" GCC bug, using environment variables set
+# in several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -eq 0 ]; then
+ echo "`date` test compiled successfully for ${MSGID}"
+ exit $REG_PASS
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'nternal.* error' ${LOG}
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: no ICE message for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` compilation failed for ${MSGID}"
+exit $REG_FAIL
diff --git a/contrib/reghunt/bin/gcc-test-missing-warning b/contrib/reghunt/bin/gcc-test-missing-warning
new file mode 100755
index 00000000000..0fc9b2dc8ea
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-missing-warning
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# Test a "missing-warning" GCC bug, using environment variables set in
+# several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: compilation failed for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'warning' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` warning detected for ${MSGID}"
+ exit $REG_PASS
+fi
+
+echo "`date` no warning for ${MSGID}"
+exit $REG_FAIL
diff --git a/contrib/reghunt/bin/gcc-test-rejects-valid b/contrib/reghunt/bin/gcc-test-rejects-valid
new file mode 100755
index 00000000000..5672a0dfee6
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-rejects-valid
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+# Test a "rejects-valid" GCC bug, using environment variables set in
+# several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -eq 0 ]; then
+ echo "`date` test compiled successfully for ${MSGID}"
+ exit $REG_PASS
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'error' ${LOG}
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: no error message for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` compilation failed for ${MSGID}"
+exit $REG_FAIL
diff --git a/contrib/reghunt/bin/gcc-test-segfault-on-valid-code b/contrib/reghunt/bin/gcc-test-segfault-on-valid-code
new file mode 100755
index 00000000000..0a1b1b722b5
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-segfault-on-valid-code
@@ -0,0 +1,49 @@
+#! /bin/sh
+
+# Test an "ice-on-valid-code" GCC bug that results in a compiler
+# segfault, using environment variables set in several reghunt scripts
+# and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -eq 0 ]; then
+ echo "`date` test compiled successfully for ${MSGID}"
+ exit $REG_PASS
+fi
+
+grep -q 'No such file or directory' ${LOG}
+if [ $? -eq 0 ]; then
+ echo "`date` unexpected failure: missing file for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+grep -q 'egmentation fault' ${LOG}
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: no segfault message for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+echo "`date` compilation failed for ${MSGID}"
+exit $REG_FAIL
diff --git a/contrib/reghunt/bin/gcc-test-wrong-code b/contrib/reghunt/bin/gcc-test-wrong-code
new file mode 100755
index 00000000000..2c0398beac7
--- /dev/null
+++ b/contrib/reghunt/bin/gcc-test-wrong-code
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# Test a "wrong-code" GCC bug, using environment variables set in
+# several reghunt scripts and configuration files.
+#
+# Copyright (C) 2007 Free Software Foundation.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+ID=$1
+
+LOGID=`printf "%04d" ${ID}`
+LOG=${BUGID}.${LOGID}.out
+MSGID="bug ${BUGID}, id ${ID}"
+
+$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
+
+if [ $? -ne 0 ]; then
+ echo "`date` unexpected failure: test compilation failed for ${MSGID}"
+ exit $REG_ERROR
+fi
+
+./a.out >> ${LOG} 2>&1
+if [ $? -ne 0 ]; then
+ echo "`date` test run aborted for ${MSGID}"
+ exit $REG_FAIL
+fi
+
+echo "`date` test ran successfully for ${MSGID}"
+exit $REG_PASS
diff --git a/contrib/reghunt/bin/reg-hunt b/contrib/reghunt/bin/reg-hunt
new file mode 100755
index 00000000000..aa0ea61ee22
--- /dev/null
+++ b/contrib/reghunt/bin/reg-hunt
@@ -0,0 +1,363 @@
+#! /bin/bash
+
+#set -x
+
+########################################################################
+#
+# File: reg-hunt
+# Author: Janis Johnson <janis187@us.ibm.com>
+# Date: 2003/08/19
+#
+# Search for the patch identifier for which results for a test changed,
+# using a binary search. The functionality for getting sources,
+# building the component to test, and running the test are in other
+# scripts that are run from here. Before the search begins, we verify
+# that we get the expected behavior for the first and last patch
+# identifiers.
+#
+# Define these in a file whose name is the argument to this script:
+# LOW_PATCH: Patch identifier.
+# HIGH_PATCH: Patch identifier.
+# REG_UPDATE: Pathname of script to update your source tree; returns
+# zero for success, nonzero for failure.
+# REG_BUILD: Pathname of script to build enough of the product to run
+# the test; returns zero for success, nonzero for failure.
+# REG_TEST: Pathname of script to run the test; returns 1 if we
+# should search later patches, 0 if we should search
+# earlier patches, and something else if there was an
+# unexpected failure.
+# Optional:
+# REG_REPORT Pathname of script to call at the end with the id of the
+# patch that caused the change in behavior.
+# REG_FINISH Pathname of script to call at the end with the two final
+# patch identifiers as arguments.
+# REG_NEWMID Pathname of script to call when a build has failed, with
+# arguments of the failed id and the current low and high
+# SKIP_LOW If 1, skip verifying the low patch identifier of the
+# range; define this only if you're restarting and have
+# already tested the low patch.
+# SKIP_HIGH If 1, skip verifying the high patch identifier of the
+# range; define this only if you're restarting and have
+# already tested the high patch.
+# FIRST_MID Use this as the first midpoint, to avoid a midpoint that
+# is known not to build.
+# VERBOSITY Default is 0, to print only errors and final message.
+# DATE_IN_MSG If set to anything but 0, include the time and date in
+# messages.
+#
+#
+#
+# Copyright (c) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+#
+########################################################################
+
+########################################################################
+# Functions
+########################################################################
+
+# Issue a message if its verbosity level is high enough.
+
+msg() {
+ test ${1} -gt ${VERBOSITY} && return
+
+ if [ "x${DATE_IN_MSG}" = "x" ]; then
+ echo "${2}"
+ else
+ echo "`date` ${2}"
+ fi
+}
+
+# Issue an error message and exit with a non-zero status. If there
+# is a valid current range whose end points have been tested, report
+# it so the user can start again from there.
+
+error() {
+ msg 0 "error: ${1}"
+ test ${VALID_RANGE} -eq 1 && \
+ echo "current range:"
+ echo "LOW_PATCH=${LATER_THAN}"
+ echo "HIGH_PATCH=${EARLIER_THAN}"
+ exit 1
+}
+
+# Build the components to test using sources as of a particular patch
+# and run a test case. Pass each of the scripts the patch identifier
+# that we're testing; the first one needs it, the others can ignore it
+# if they want.
+
+process_patch () {
+ TEST_ID=${1}
+
+ # If we're keeping track of known failures, see if TEST_ID is one and
+ # if so, don't bother updating sources and trying to build.
+
+ FAILS=0
+ SKIP=0
+ if [ ${SKIP_FAILURES} -eq 1 ]; then
+ ${REG_CHECKFAIL} ${TEST_ID}
+ if [ $? -eq 0 ]; then
+ msg 1 "skipping ${TEST_ID}; it is a known build failure"
+ FAILS=1
+ SKIP=1
+ fi
+ fi
+
+ if [ ${FAILS} -eq 0 ]; then
+ ${REG_UPDATE} ${TEST_ID} || error "source update failed for ${TEST_ID}"
+ ${REG_BUILD} ${TEST_ID}
+ if [ $? -ne 0 ]; then
+ FAILS=1
+ msg 1 "build failed for ${TEST_ID}"
+ if [ ${SKIP_FAILURES} -eq 1 ]; then
+ ${REG_RECORDFAIL} ${TEST_ID}
+ fi
+ fi
+ fi
+
+ if [ ${FAILS} -eq 0 ]; then
+ ${REG_TEST} ${TEST_ID}
+ LATER=$?
+ if [ $LATER -ne 0 -a $LATER -ne 1 ]; then
+ msg 0 "unexpected test failure for ${TEST_ID}"
+ exit 1
+ fi
+ else
+
+ # The build failed, or this patch is already known to fail to build.
+ # If it's an endpoint, or if we don't have a way to recover from
+ # build failures, quit now.
+
+ if [ ${SKIP} -eq 0 ]; then
+ if [ "x${REG_NEWMID}" == "x" \
+ -o ${TEST_ID} -eq ${LATER_THAN} \
+ -o ${TEST_ID} -eq ${EARLIER_THAN} ]; then
+ error "build failed for ${TEST_ID}"
+ fi
+ fi
+
+ # Try to find a new patch to try within the current range.
+
+ FIRST_MID=`${REG_NEWMID} ${LATER_THAN} ${EARLIER_THAN}`
+ if [ ${FIRST_MID} -eq 0 ]; then
+
+ # The heuristics in the tool ran out of patches to try next;
+ # let the user handle it from here.+
+ error "build failed for ${TEST_ID}, could not find new candidate"
+ fi
+ msg 1 "using ${FIRST_MID}, between ${LATER_THAN} and ${EARLIER_THAN}"
+ fi
+
+ # Return with a valid LATER value or a new ID to try in FIRST_MID.
+}
+
+# Get the number of a patch within the range. It's not actually the
+# middle one, but the one that might minimize the number of checks.
+
+get_mid_special() {
+ LOW=$1
+ HIGH=$2
+
+ let DIFF=HIGH-LOW
+ M=1
+ POWER2=1
+ while
+ [ $POWER2 -lt $DIFF ]
+ do
+ let M=POWER2
+ let POWER2=POWER2*2
+ done
+ let MID=LOW+M
+}
+
+# Get the number of the patch in the middle of the range.
+
+get_mid () {
+ LOW=$1
+ HIGH=$2
+
+ let DIFF=HIGH-LOW
+ let M=DIFF/2
+ let MID=LOW+M
+}
+
+# Perform a binary search on patch identifiers within the range
+# specified by the arguments.
+
+search_patches () {
+ LOW=$1
+ HIGH=$2
+
+ # Get an identifier within the range. The user can override the
+ # initial mid patch if it is known to have problems, e.g., if a
+ # build fails for that patch.
+
+ if [ ${FIRST_MID} -ne 0 ]; then
+ MID=${FIRST_MID}
+ FIRST_MID=0
+ let DIFF=HIGH-LOW
+ else
+ get_mid $LOW $HIGH
+ fi
+
+ while [ ${DIFF} -gt 1 ]; do
+ TEST_ID="${MID}"
+
+ # Test it.
+
+ process_patch ${TEST_ID}
+
+ # FIRST_MID being set is a signal that the build failed and we
+ # should start over again.
+
+ test ${FIRST_MID} -ne 0 && return
+
+ # Narrow the search based on the outcome of testing TEST_ID.
+
+ if [ ${LATER} -eq 1 ]; then
+ msg 1 "search patches later than ${TEST_ID}"
+ LATER_THAN=${TEST_ID}
+ let LOW=MID
+ else
+ msg 1 "search patches earlier than ${TEST_ID}"
+ EARLIER_THAN=${TEST_ID}
+ let HIGH=MID
+ fi
+
+ get_mid $LOW $HIGH
+ done
+}
+
+########################################################################
+# Main program (so to speak)
+########################################################################
+
+# The error function uses this.
+
+VALID_RANGE=0
+
+# Process the configuration file.
+
+if [ $# != 1 ]; then
+ echo Usage: $0 config_file
+ exit 1
+fi
+
+CONFIG=${1}
+if [ ! -f ${CONFIG} ]; then
+ error "configuration file ${CONFIG} does not exist"
+fi
+
+# OK, the config file exists. Source it, make sure required parameters
+# are defined and their files exist, and give default values to optional
+# parameters.
+
+. ${CONFIG}
+
+test "x${REG_UPDATE}" = "x" && error "REG_UPDATE is not defined"
+test "x${REG_BUILD}" = "x" && error "REG_BUILD is not defined"
+test "x${REG_TEST}" = "x" && error "REG_TEST is not defined"
+test -x ${REG_TEST} || error "REG_TEST is not an executable file"
+test "x${SKIP_LOW}" = "x" && SKIP_LOW=0
+test "x${SKIP_HIGH}" = "x" && SKIP_HIGH=0
+test "x${VERBOSITY}" = "x" && VERBOSITY=0
+test "x${REG_FINISH}" = "x" && REG_FINISH=true
+test "x${REG_REPORT}" = "x" && REG_REPORT=true
+
+msg 2 "LOW_PATCH = ${LOW_PATCH}"
+msg 2 "HIGH_PATCH = ${HIGH_PATCH}"
+msg 2 "REG_UPDATE = ${REG_UPDATE}"
+msg 2 "REG_BUILD = ${REG_BUILD}"
+msg 2 "REG_TEST = ${REG_TEST}"
+msg 2 "REG_NEWMID = ${REG_NEWMID}"
+msg 2 "SKIP_LOW = ${SKIP_LOW}"
+msg 2 "SKIP_HIGH = ${SKIP_HIGH}"
+msg 2 "FIRST_MID = ${FIRST_MID}"
+msg 2 "VERBOSITY = ${VERBOSITY}"
+
+# If REG_NEWMID was defined, assume that we're skipping known failures
+# and adding to the list for new failures. If the list of failures
+# doesn't exist, create it. We use a different flag, SKIP_FAILURES,
+# to make it easier to separate the flag from REG_NEWMID if we want
+# to change the usage later.
+
+if [ "x${REG_NEWMID}" != "x" ]; then
+ touch ${REG_FAILLIST}
+ SKIP_FAILURES=1
+else
+ SKIP_FAILURES=0
+fi
+
+# If FIRST_MID was defined, make sure it's in the range.
+
+if [ "x${FIRST_MID}" != "x" ]; then
+ test ${FIRST_MID} -le ${LOW_PATCH} && \
+ error "FIRST_MID id is lower than LOW_PATCH"
+ test ${FIRST_MID} -ge ${HIGH_PATCH} && \
+ error "FIRST_MID is higher than HIGH_PATCH"
+else
+ FIRST_MID=0
+fi
+
+# Keep track of the bounds of the range where the test behavior changes.
+
+LATER_THAN=${LOW_PATCH}
+EARLIER_THAN=${HIGH_PATCH}
+LATER=1
+
+msg 1 "LATER_THAN = ${LATER_THAN}"
+msg 1 "EARLIER_THAN = ${EARLIER_THAN}"
+
+# Verify that the range isn't backwards.
+
+test ${LOW_PATCH} -lt ${HIGH_PATCH} || \
+ error "patch identifier range is backwards"
+
+# Verify that the first and last patches in the range get the results we
+# expect. If not, quit, because any of several things could be wrong.
+
+if [ ${SKIP_HIGH} -eq 0 ]; then
+ process_patch ${EARLIER_THAN}
+ test ${LATER} -ne 0 && \
+ error "unexpected result for high patch ${EARLIER_THAN}"
+ msg 1 "result for high patch ${EARLIER_THAN} is as expected"
+fi
+
+if [ ${SKIP_LOW} -eq 0 ]; then
+ process_patch ${LATER_THAN}
+ test ${LATER} -ne 1 && \
+ error "unexpected result for low patch ${LATER_THAN}"
+ msg 1 "result for low patch ${LATER_THAN} is as expected"
+fi
+
+# Search within the range, now that we know that the end points are valid.
+# If the build failed then FIRST_MID is set to a new patch to try.
+
+VALID_RANGE=1
+while true; do
+ search_patches ${LATER_THAN} ${EARLIER_THAN}
+ test ${FIRST_MID} -eq 0 && break
+done
+
+# Report where the test behavior changes.
+
+echo "Test result changes with id ${EARLIER_THAN}"
+${REG_REPORT} ${EARLIER_THAN}
+
+# Invoke the optional script to verify the result and report additional
+# information about changes between the two patches.
+
+${REG_FINISH} ${LATER_THAN} ${EARLIER_THAN}
diff --git a/contrib/reghunt/bin/reg-newmid b/contrib/reghunt/bin/reg-newmid
new file mode 100755
index 00000000000..2a6b57362ba
--- /dev/null
+++ b/contrib/reghunt/bin/reg-newmid
@@ -0,0 +1,86 @@
+#! /bin/sh
+
+# The build failed for and identifier in the range bwetween LOW and HIGH.
+# Find a new patch id to try within that range.
+#
+# It's meant to be easy to modify the heuristics used to select the
+# next patch to try by adding to or rearranging the patches listed in
+# MIDLIST. Known failures are recorded in ${REG_FAILLIST}.
+#
+# A nifty improvement would be to record known ranges of failure as
+# ranges, and then pick revisions just before and just after the range.
+#
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+
+LOW=$1
+HIGH=$2
+
+MIDLIST=""
+
+let MID01=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH
+let MID01=MID01/12
+let MID02=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH
+let MID02=MID02/12
+let MID03=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH
+let MID03=MID03/12
+let MID04=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH
+let MID04=MID04/12
+let MID05=LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID05=MID05/12
+let MID06=LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID06=MID06/12
+let MID07=LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID07=MID07/12
+let MID08=LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID08=MID08/12
+let MID09=LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID09=MID09/12
+let MID10=LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID10=MID10/12
+let MID11=LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
+let MID11=MID11/12
+
+# Look in this order; MID has already been done:
+#
+# LOW--10---7---6---3---2---MID---1---4---5---8---9---HIGH
+
+MIDLIST="${MIDLIST} ${MID07}"
+MIDLIST="${MIDLIST} ${MID05}"
+MIDLIST="${MIDLIST} ${MID04}"
+MIDLIST="${MIDLIST} ${MID08}"
+MIDLIST="${MIDLIST} ${MID09}"
+MIDLIST="${MIDLIST} ${MID03}"
+MIDLIST="${MIDLIST} ${MID02}"
+MIDLIST="${MIDLIST} ${MID10}"
+MIDLIST="${MIDLIST} ${MID11}"
+MIDLIST="${MIDLIST} ${MID01}"
+
+for MID in ${MIDLIST}
+do
+ # Skip this if it's the low endpoint.
+ if [ ${MID} != ${LOW} ]; then
+ # Is this patch already known to fail?
+ ${REG_CHECKFAIL} ${MID}
+ if [ $? -ne 0 ]; then
+ echo ${MID}
+ exit 0
+ fi
+ fi
+done
+
+echo 0
+exit 1
diff --git a/contrib/reghunt/bin/reg-test b/contrib/reghunt/bin/reg-test
new file mode 100755
index 00000000000..622a6546150
--- /dev/null
+++ b/contrib/reghunt/bin/reg-test
@@ -0,0 +1,152 @@
+#! /bin/bash
+
+#set -x
+
+########################################################################
+#
+# File: reg-test
+# Author: Janis Johnson
+# Date: 2005/09/08
+#
+# For each of a list of patches, invoke separate tools to update
+# sources, do a build, and run one or more tests.
+#
+# Define these in a file whose name is the argument to this script:
+# REG_IDLIST: List of patch identifiers.
+# REG_UPDATE: Pathname of script to update the source tree.
+# REG_BUILD: Pathname of script to build enough of the product to run
+# the test.
+# REG_TEST: Pathname of script to run one or more tests.
+# Optional:
+# VERBOSITY: Default is 0, to print only errors and final message.
+# DATE_IN_MSG If set to anything but 0, include the time and date in
+# messages
+# REG_STOP Pathname of a file whose existence says to quit; default
+# is STOP in the current directory.
+#
+#
+# Copyright (c) 2002, 2003, 2005 Free Software Foundation, Inc.
+#
+# This file 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.
+#
+# For a copy of the GNU General Public License, write the the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1301, USA.
+#
+########################################################################
+
+########################################################################
+# Functions
+########################################################################
+
+# Issue a message if its verbosity level is high enough.
+
+msg() {
+ test ${1} -gt ${VERBOSITY} && return
+
+ if [ "x${DATE_IN_MSG}" = "x" ]; then
+ echo "${2}"
+ else
+ echo "`${DATE}` ${2}"
+ fi
+}
+
+# Issue an error message and exit with a nonzero status.
+
+error() {
+ msg 0 "error: ${1}"
+ exit 1
+}
+
+# Build the components to test using sources as of a particular patch
+# and run a test case. Pass each of the scripts the patch identifier
+# that we're testing; the first one needs it, the others can ignore it
+# if they want.
+
+process_patch () {
+ TEST_ID=${1}
+
+ ${REG_UPDATE} ${TEST_ID}
+ if [ $? -ne 0 ]; then
+ msg 0 "source update failed for id ${TEST_ID}"
+ return
+ fi
+ ${REG_BUILD} ${TEST_ID}
+ if [ $? -ne 0 ]; then
+ msg 0 "build failed for id ${TEST_ID}"
+ return
+ fi
+ ${REG_TEST} "${TEST_ID}"
+}
+
+########################################################################
+# Main program (so to speak)
+########################################################################
+
+# If DATE isn't defined, use the default date command; the configuration
+# file can override this.
+
+if [ "x${DATE}" = "x" ]; then
+ DATE=date
+fi
+
+# Process the configuration file.
+
+if [ $# -ne 1 ]; then
+ echo Usage: $0 config_file
+ exit 1
+fi
+
+CONFIG=${1}
+if [ ! -f ${CONFIG} ]; then
+ error "configuration file ${CONFIG} does not exist"
+fi
+
+# OK, the config file exists. Source it, make sure required parameters
+# are defined and their files exist, and give default values to optional
+# parameters.
+
+. ${CONFIG}
+
+test "x${REG_IDLIST}" = "x" && error "REG_IDLIST is not defined"
+test "x${REG_UPDATE}" = "x" && error "REG_UPDATE is not defined"
+test "x${REG_BUILD}" = "x" && error "REG_BUILD is not defined"
+test "x${REG_TEST}" = "x" && error "REG_TEST is not defined"
+test -x ${REG_TEST} || error "REG_TEST is not an executable file"
+test "x${VERBOSITY}" = "x" && VERBOSITY=0
+test "x${REG_STOP}" = "x" && REG_STOP="STOP"
+
+msg 2 "REG_IDLIST = ${REG_IDLIST}"
+msg 2 "REG_UPDATE = ${REG_UPDATE}"
+msg 2 "REG_BUILD = ${REG_BUILD}"
+msg 2 "REG_TEST = ${REG_TEST}"
+msg 2 "VERBOSITY = ${VERBOSITY}"
+
+# Process each patch identifier in the list.
+
+for TEST_ID in $REG_IDLIST; do
+
+ # If a file called STOP appears, stop; this allows a clean way to
+ # interrupt a search.
+
+ if [ -f ${REG_STOP} ]; then
+ msg 0 "STOP file detected"
+ rm -f ${REG_STOP}
+ exit 1
+ fi
+
+ # Process the new patch.
+
+ msg 2 "process id ${TEST_ID}"
+ process_patch ${TEST_ID}
+done
+
+msg 1 "done"