+2020-07-03  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/call-sc.exp (start_scalars_test): Use
+       prepare_for_testing and don't try compiling with -DNO_PROTOTYPES.
+       * gdb.base/overlays.c: Remove references to PARAMS.
+       * gdb.base/ovlymgr.h (PARAMS): Delete, and remove all references.
+       * gdb.base/reread.exp: Don't set 'prototypes' global.
+       * gdb.base/structs.exp (start_structs_test): Use
+       prepare_for_testing and don't try compiling with -DNO_PROTOTYPES.
+       * gdb.base/structs2.exp: Don't set 'prototypes' global.  Use
+       prepare_for_testing and don't try compiling with -DNO_PROTOTYPES.
+       Don't issue "set width 0".  Remove gdb_stop_suppressing_tests
+       call.
+       * gdb.base/varargs.exp: Don't set 'prototypes' global.
+
 2020-07-03  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/m32rovly.c: Delete.
 
     set testfile "call-sc-${type}"
 
     set binfile [standard_output_file ${testfile}]
-    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
-       # built the second test case since we can't use prototypes
-       warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
-       if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
-           untested "failed to compile"
-           return -1
-       }
+    if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
+       return -1
     }
 
-    # Start with a fresh gdb.
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
-
     # Make certain that the output is consistent
     with_test_prefix "testfile=$testfile" {
        gdb_test_no_output "set print sevenbit-strings"
 
 
 #include "ovlymgr.h"
 
-extern int foo PARAMS((int));
-extern int bar PARAMS((int));
-extern int baz PARAMS((int));
-extern int grbx PARAMS((int));
+extern int foo (int);
+extern int bar (int);
+extern int baz (int);
+extern int grbx (int);
 
 int main ()
 {
 
  * Sample runtime overlay manager.
  */
 
-#ifdef NO_PROTOTYPES
-#define PARAMS(paramlist) ()
-#else
-#define PARAMS(paramlist) paramlist
-#endif
-
 typedef enum { FALSE, TRUE } bool;
 
 /* Entry Points: */
 
-bool OverlayLoad   PARAMS((unsigned long ovlyno));
-bool OverlayUnload PARAMS((unsigned long ovlyno));
-
+bool OverlayLoad (unsigned long ovlyno);
+bool OverlayUnload (unsigned long ovlyno);
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set prototypes 1
-
 # Build programs in PIE mode, to reproduce PR 21555.
 foreach_with_prefix opts {
     { "" "" }
 
     }
 
     set binfile [standard_output_file ${testfile}]
-    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
-       # built the second test case since we can't use prototypes
-       warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
-       if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
-           untested "failed to compile"
-           return -1
-       }
+    if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
+       return -1
     }
 
-    # Start with a fresh gdb.
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
-
     # Make certain that the output is consistent
     with_test_prefix "types=$types" {
        gdb_test_no_output "set print sevenbit-strings"
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set prototypes 1
 standard_testfile .c
 
 # Create and source the file that provides information about the compiler
     return -1
 }
 
-# build the first test case
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    # built the second test case since we can't use prototypes
-    warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
-    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
-       untested "failed to compile"
-       return -1
-    }
-    set prototypes 0
+if { [prepare_for_testing "failed to prepare" $binfile $srcfile {debug}] } {
+    return -1
 }
 
-# Start with a fresh gdb.
-
-clean_restart ${binfile}
-
-gdb_test_no_output "set width 0"
-
 if ![runto_main] then {
     fail "can't run to main"
     return 0
 }
 
-# Ok, we're finally ready to actually do our tests.
-
 gdb_test "f" \
     ".*bkpt = 0.*" \
     "structs2 sanity check"
 gdb_test "continue" \
     ".*pr_char=-126.*pr_uchar=120.*pr_short=-32536.*pr_ushort=32000.*bkpt = 1.*" \
     "structs2 continue2"
-
-# End of tests.
-
-gdb_stop_suppressing_tests
-
-return 0
 
 
 
 
-set prototypes 0
-
 standard_testfile .c
 
 if [get_compiler_info] {