diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c b/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c
index af9fc11ddab..635aa44135e 100644
--- a/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c
+++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c
@@ -16,7 +16,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 void
-foo ()
+foo (const char *s)
 {
   /* Nothing.  */
 }
diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.c b/gdb/testsuite/gdb.base/unwind-on-each-insn.c
index 60bc83a6d4f..821df375115 100644
--- a/gdb/testsuite/gdb.base/unwind-on-each-insn.c
+++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.c
@@ -15,11 +15,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-extern void foo ();
+extern void foo (const char *);
 
 int
 main ()
 {
-  foo ();
+  foo ("foo");
   return 0;
 }
diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp
index fc48bf5c061..6e68b24af9c 100644
--- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp
+++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp
@@ -113,7 +113,12 @@ for { set i_count 1 } { true } { incr i_count } {
 	# Check we can unwind the stack-pointer and the frame base
 	# address correctly.
 	lassign [get_sp_and_fba "for main"] sp_value fba_value
-	gdb_assert { $sp_value == $main_sp }
+	if { $i_count == 1 } {
+	    # The stack-pointer may have changed while running to *foo.
+	    set main_sp $sp_value
+	} else {
+	    gdb_assert { $sp_value == $main_sp }
+	}
 	gdb_assert { $fba_value == $main_fba }
 
 	# Check we have a consistent value for main's frame-id.