diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
index 744e044..4f43601 100644
--- a/gdb/testsuite/boards/native-extended-gdbserver.exp
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -48,10 +48,16 @@ load_lib mi-support.exp
 # GDB is started.  Note nothing is needed for gdb_exit, since
 # gdbserver is started with --once, causing it to exit once GDB
 # disconnects.
-proc gdb_start { } {
+proc gdb_start { {stop_mode "all-stop"} } {
     # Spawn GDB.
     default_gdb_start
 
+    # Non-stop mode must be set before connecting to gdbserver for it
+    # to be enabled in gdbserver, so we set non-stop here.
+    if { $stop_mode == "non-stop" } then {
+        gdb_test_no_output "set non-stop on" "enable non-stop mode"
+    }
+
     # And then GDBserver, ready for extended-remote mode.
     gdbserver_start_multi
 
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 5bea3ba..8b2eae0 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -68,6 +68,13 @@ proc zap_session {} {
     -re ".*$gdb_prompt $" {}
     timeout { fail "killing inferior (timeout)" ; return }
    }
+
+   # For remote targets the 'file' command doesn't change the exec-file,
+   # as it does for native targets.  In the remote case we must also use
+   # 'set remote exec-file'.
+   if [gdb_is_target_remote] then {
+     gdb_test_no_output "set remote exec-file $binfile" "reset remote exec-file to original file"
+   }
 }
 
 proc do_exec_tests {} {
diff --git a/gdb/testsuite/gdb.base/pie-execl.exp b/gdb/testsuite/gdb.base/pie-execl.exp
index 41411d5..56cd94e 100644
--- a/gdb/testsuite/gdb.base/pie-execl.exp
+++ b/gdb/testsuite/gdb.base/pie-execl.exp
@@ -16,6 +16,8 @@
 # The problem was due to amd64_skip_prologue attempting to access inferior
 # memory before the PIE (Position Independent Executable) gets relocated.
 
+global inferior_spawn_id
+
 if ![istarget *-linux*] {
     continue
 }
@@ -67,6 +69,7 @@ gdb_test_multiple "p/x &pie_execl_marker" $test {
 verbose -log "addr1 is $addr1"
 
 set test "continue"
+set matches_found 0
 gdb_test_multiple $test $test {
     -re "Error in re-setting breakpoint" {
 	fail $test
@@ -74,8 +77,21 @@ gdb_test_multiple $test $test {
     -re "Cannot access memory" {
 	fail $test
     }
-    -re "pie-execl: re-exec.*executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" {
-	pass $test
+    -re ".*executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" {
+        incr matches_found
+	if { $matches_found == 2 } {
+	    pass $test
+	} else {
+	    exp_continue
+	}
+    }
+    -i "$inferior_spawn_id" -re "pie-execl: re-exec" {
+        incr matches_found
+	if { $matches_found == 2 } {
+	    pass $test
+	} else {
+	    exp_continue
+	}
     }
 }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
index 69e5cc6..147e7f3 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
@@ -28,11 +28,11 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-proc do_test { lock_sched } {
-    with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+    with_test_prefix "lock-sched$lock_sched,$stop_mode" {
 	global executable
 
-	clean_restart ${executable}
+	clean_restart ${executable} $stop_mode
 
 	if ![runto_main] {
 	    return -1
@@ -48,11 +48,17 @@ proc do_test { lock_sched } {
 	    gdb_test_no_output "set scheduler-locking on"
 	}
 
+	if { $stop_mode == "non-stop" } {
+	    gdb_test "thread 2" "Switching.*"
+	}
+
 	gdb_test "continue" \
 	    ".*is executing new program.*Breakpoint 1, main.* at .*" \
 	    "continue over exec"
     }
 }
 
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
index 9386153..748ff11 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -29,18 +29,26 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-proc do_test { lock_sched } {
-    with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+    with_test_prefix "lock-sched$lock_sched,$stop_mode" {
 	global executable
 
-	clean_restart ${executable}
+	clean_restart ${executable} $stop_mode
 
 	if ![runto_main] {
 	    return -1
 	}
 
 	gdb_breakpoint [gdb_get_line_number "break-here"]
-	gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+	gdb_test_multiple "continue" "continue to breakpoint" {
+	    -re ".*Breakpoint.*break-here.*" {
+	        pass "continue to breakpoint"
+	    }
+	}
+
+	if { $stop_mode == "non-stop" } {
+	    gdb_test "thread 2" "Switching.*"
+	}
 
 	gdb_test "info threads" \
 	    "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
@@ -59,5 +67,7 @@ proc do_test { lock_sched } {
     }
 }
 
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
index cc7da1a..2dbcd81 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
@@ -31,18 +31,22 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-proc do_test { lock_sched } {
-    with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+    with_test_prefix "lock-sched$lock_sched,$stop_mode" {
 	global executable
 
-	clean_restart ${executable}
+	clean_restart ${executable} $stop_mode
 
 	if ![runto_main] {
 	    return -1
 	}
 
 	gdb_breakpoint [gdb_get_line_number "break-here"]
-	gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+	gdb_test_multiple "continue" "continue to breakpoint" {
+	    -re ".*Breakpoint.*break-here.*" {
+	        pass "continue to breakpoint"
+	    }
+	}
 
 	# Also test with sched-lock to make sure we can follow the
 	# non-leader thread execing even though the main thread wasn't
@@ -51,11 +55,17 @@ proc do_test { lock_sched } {
 	    gdb_test_no_output "set scheduler-locking on"
 	}
 
+	if { $stop_mode == "non-stop" } {
+	    gdb_test "thread 2" "Switching.*"
+	}
+
 	gdb_test "continue" \
 	    ".*is executing new program.*Breakpoint 1, main.* at .*" \
 	    "continue over exec"
     }
 }
 
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
index a89b818..a9e5c5a 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
@@ -30,11 +30,11 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-proc do_test { lock_sched } {
-    with_test_prefix "lock-sched$lock_sched" {
+proc do_test { lock_sched stop_mode } {
+    with_test_prefix "lock-sched$lock_sched,$stop_mode" {
 	global executable
 
-	clean_restart ${executable}
+	clean_restart ${executable} $stop_mode
 
 	if ![runto_main] {
 	    return -1
@@ -50,11 +50,17 @@ proc do_test { lock_sched } {
 	    gdb_test_no_output "set scheduler-locking on"
 	}
 
+	if { $stop_mode == "non-stop" } {
+	    gdb_test "thread 2" "Switching.*"
+	}
+
 	gdb_test "continue" \
 	    ".*is executing new program.*Breakpoint 1, main.* at .*" \
 	    "continue over exec"
     }
 }
 
-do_test 0
-do_test 1
+do_test 0 "all-stop"
+do_test 1 "all-stop"
+do_test 0 "non-stop"
+do_test 1 "non-stop"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0805de9..4ef72d1 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3601,8 +3601,11 @@ proc gdb_spawn_with_cmdline_opts { cmdline_flags } {
 # Overridable function -- you can override this function in your
 # baseboard file.
 
-proc gdb_start { } {
+proc gdb_start { {stop_mode "all-stop"} } {
     default_gdb_start
+    if { $stop_mode == "non-stop" } {
+        gdb_test_no_output "set non-stop on" "enable non-stop mode"
+    }
 }
 
 proc gdb_exit { } {
@@ -4870,15 +4873,16 @@ proc build_executable { testname executable {sources ""} {options {debug}} } {
 }
 
 # Starts fresh GDB binary and loads EXECUTABLE into GDB. EXECUTABLE is
-# the basename of the binary.
+# the basename of the binary.  If MODE is "non-stop", then non-stop
+# mode will be enabled.
 # The return value is 0 for success, -1 for failure.
-proc clean_restart { executable } {
+proc clean_restart { executable {stop_mode "all-stop"} } {
     global srcdir
     global subdir
     set binfile [standard_output_file ${executable}]
 
     gdb_exit
-    gdb_start
+    gdb_start $stop_mode
     gdb_reinitialize_dir $srcdir/$subdir
     return [gdb_load ${binfile}]
 }
