Fix gdb.multi/multi-re-run.exp with native-gdbserver
authorPedro Alves <palves@redhat.com>
Sat, 16 May 2020 17:59:10 +0000 (18:59 +0100)
committerPedro Alves <palves@redhat.com>
Sat, 16 May 2020 17:59:10 +0000 (18:59 +0100)
The new exec-file-mismatch feature reveals that when running
gdb.multi/multi-re-run.exp against --target_board=native-gdbserver,
we've been starting gdbserver with the wrong program:

 (gdb) spawn /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/../../gdbserver/gdbserver --once localhost:2347 /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/te
 stsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2
 Process /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 created; pid = 6280
 Listening on port 2347
 target remote localhost:2347
 Remote debugging using localhost:2347
 warning: Mismatch between current exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-1
 and automatically determined exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2
 exec-file-mismatch handling is currently "ask"
 Load new symbol table from "/home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2"? (y or n) Quit
 (gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: running to all_started in runto

The problem is that gdb_reload uses the last loaded file as binary to
spawn, but we load the program for inferior 2 and then switch to
inferior 1 and run it, so the last loaded file is the program for
inferior 2.

Fix this by tweaking last_loaded_file.

gdb/testsuite/ChangeLog:
2020-05-16  Pedro Alves  <palves@redhat.com>

* gdb.multi/multi-re-run.exp (test_re_run): Switch
LAST_LOADED_FILE accordingly.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.multi/multi-re-run.exp

index c57ddf55cbfc7f986d751fc83d066395d95a9856..0be2fd3386c3619b4994ec5d9f14710504986973 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-16  Pedro Alves  <palves@redhat.com>
+
+       * gdb.multi/multi-re-run.exp (test_re_run): Switch
+       LAST_LOADED_FILE accordingly.
+
 2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases.
index 93cd709b5c73ff8b6b471960a92ec5976d08bf94..a243293482406a9affb598817b9ed2994c2763c7 100644 (file)
@@ -51,6 +51,7 @@ proc test_re_run {re_run_inf} {
     global binfile1 binfile2
     global inferior_exited_re
     global gdb_prompt
+    global last_loaded_file
 
     clean_restart ${binfile1}
 
@@ -65,12 +66,17 @@ proc test_re_run {re_run_inf} {
 
     if {$re_run_inf == 1} {
        set steady_inf 2
+       set steady_binfile $binfile2
+       set re_run_binfile $binfile1
     } else {
        set steady_inf 1
+       set steady_binfile $binfile1
+       set re_run_binfile $binfile2
     }
 
     gdb_test "inferior $steady_inf" "Switching to inferior $steady_inf.*" \
        "switch to steady inferior"
+    set last_loaded_file $steady_binfile
 
     # Run the steady inferior to a breakpoint, and let it stay stopped
     # there.
@@ -81,6 +87,7 @@ proc test_re_run {re_run_inf} {
 
     gdb_test "inferior $re_run_inf" "Switching to inferior $re_run_inf.*" \
        "switch to re-run inferior"
+    set last_loaded_file $re_run_binfile
 
     # Now run the RE_RUN_INF inferior a couple times.  GDB used to
     # have a bug that caused the second run to fail to load