]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb testsuite: Introduce allow_multi_inferior_tests and use it throughout
authorPedro Alves <pedro@palves.net>
Thu, 1 Jun 2023 17:43:15 +0000 (18:43 +0100)
committerPedro Alves <pedro@palves.net>
Wed, 11 Jun 2025 14:03:28 +0000 (15:03 +0100)
The Windows port does not support multi-process debugging.  Testcases
that want to exercise multi-process currently FAIL and some hit
cascading timeouts.  Add a new allow_multi_inferior_tests procedure,
meant to be used with require, and sprinkle it throughout testcases as
needed.

Approved-by: Kevin Buettner <kevinb@redhat.com>
Change-Id: I4a10d8f04f9fa10f4b751f140ad0a6d31fbd9dfb

25 files changed:
gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
gdb/testsuite/gdb.btrace/multi-inferior.exp
gdb/testsuite/gdb.mi/interrupt-thread-group.exp
gdb/testsuite/gdb.mi/user-selected-context-sync.exp
gdb/testsuite/gdb.multi/attach-while-running.exp
gdb/testsuite/gdb.multi/bp-thread-specific.exp
gdb/testsuite/gdb.multi/dummy-frame-restore.exp
gdb/testsuite/gdb.multi/multi-arch.exp
gdb/testsuite/gdb.multi/multi-attach.exp
gdb/testsuite/gdb.multi/multi-exit.exp
gdb/testsuite/gdb.multi/multi-kill.exp
gdb/testsuite/gdb.multi/multi-re-run.exp
gdb/testsuite/gdb.multi/multi-target.exp.tcl
gdb/testsuite/gdb.multi/multi-term-settings.exp
gdb/testsuite/gdb.multi/start-inferior-specific.exp
gdb/testsuite/gdb.multi/stop-all-on-exit.exp
gdb/testsuite/gdb.multi/tids-gid-reset.exp
gdb/testsuite/gdb.multi/tids.exp
gdb/testsuite/gdb.multi/watchpoint-multi.exp
gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
gdb/testsuite/gdb.threads/detach-step-over.exp
gdb/testsuite/gdb.threads/threadapply.exp
gdb/testsuite/gdb.threads/vfork-multi-inferior.exp
gdb/testsuite/lib/gdb.exp

index ef4bb88a217f8f1d38703b983735e6e5c270867c..57ec33035299f918bad21965b0d55961064c2df9 100644 (file)
@@ -19,6 +19,7 @@
 # commands.
 
 require can_spawn_for_attach
+require allow_multi_inferior_tests
 
 standard_testfile
 set executable $testfile
index 22913ca97d81f9a1da8d6d3ace1b4914c0b56ed9..eaee0101a901c0f010f6d4518bf7b56c35021d04 100644 (file)
@@ -49,6 +49,11 @@ if {[build_executable "failed to prepare" $testfile $srcfile]} {
 #  - run: use the run command
 #  - attach: start a process outside of GDB and attach it
 proc do_test { action1 action2 } {
+
+    if {$action1 == "add" && ![allow_multi_inferior_tests]} {
+       return
+    }
+
     save_vars { ::GDBFLAGS } {
        append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
        clean_restart $::binfile
index ed2acb2520dce1dd7592258fbed9f4e90b597634..d87a94160a7313a0d7db8c88f1838b1d8896a96a 100644 (file)
@@ -24,6 +24,8 @@
 
 require allow_btrace_tests
 
+require allow_multi_inferior_tests
+
 require !use_gdb_stub
 
 standard_testfile
index ff35109716c09fbab9a7632164a3906ab1310880..869fb1cb287161ead05ab1b084197c3d2df689fc 100644 (file)
@@ -54,7 +54,7 @@ mi_send_resuming_command "exec-continue --thread-group i1" \
 
 # We can't run a second inferior on stub targets.  We can still test with one
 # inferior and ensure that the command has the desired effect.
-set use_second_inferior [expr {![use_gdb_stub]}]
+set use_second_inferior [expr {![use_gdb_stub] && [allow_multi_inferior_tests]}]
 
 if { $use_second_inferior } {
     mi_gdb_test "-add-inferior" \
index ec22538d30bf0a83e529a4b24bb54b00c91cd236..f85e108ab194d0c249e3015448c9dd0d61967bb5 100644 (file)
@@ -40,6 +40,8 @@ standard_testfile
 # gdbserver modes are supported.
 require !use_gdb_stub
 
+require allow_multi_inferior_tests
+
 set compile_options "debug pthreads"
 if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} {
     untested "failed to compile"
index 061b30db20c9aed4329e71a756db7ab43a627495..723ebb2e4eec38766774e9c8c78e8aa803830398 100644 (file)
@@ -37,6 +37,7 @@
 standard_testfile
 
 require can_spawn_for_attach
+require allow_multi_inferior_tests
 
 if { [build_executable "failed to prepare" ${testfile} ${srcfile}] } {
     return
index 32b76022573677b955b1eb1dcde96be9963c8809..3fe4c2090c9e58c25fabddf94063fea707a41802 100644 (file)
@@ -19,6 +19,8 @@
 # Also check that the correct thread-ids are used in the saved
 # breakpoints file.
 
+require allow_multi_inferior_tests
+
 # The plain remote target can't do multiple inferiors.
 require !use_gdb_stub
 
index 1a9d4135cc6a183598ff56e4d5c0e3869b6c8037..4119e3f1ef2ff198dec1f4d61d2df9abc560f4e7 100644 (file)
@@ -19,6 +19,8 @@ set executable ${testfile}
 # The plain remote target can't do multiple inferiors.
 require !use_gdb_stub
 
+require allow_multi_inferior_tests
+
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
     return -1
 }
index d0ae5110550f7e923ae971722cf571c411a85a5f..1d41ba5c0ae6bf9101171270e619f90986c0d68d 100644 (file)
@@ -18,6 +18,8 @@
 
 set testfile "multi-arch"
 
+require allow_multi_inferior_tests
+
 # The plain remote target can't do multiple inferiors.
 require !use_gdb_stub
 
index 2d702eec40509c3d53c9545c23dc474d3fbd3a38..210c8ca6b538860495bb28e993d16aad6a68ee26 100644 (file)
@@ -17,6 +17,8 @@
 
 # Test attaching to multiple threaded programs.
 
+require allow_multi_inferior_tests
+
 standard_testfile
 
 require can_spawn_for_attach
index 71236c19e2f0eef789362cd3993d2b76db7c3c00..8393067e532512f52259d7f212c7a623bf588400 100644 (file)
@@ -24,6 +24,8 @@
 
 standard_testfile
 
+require allow_multi_inferior_tests
+
 require !use_gdb_stub
 
 if {[build_executable "failed to prepare" $testfile $srcfile]} {
index 48a253445fea3c2ac343e37c388cc92937c314eb..7d66ab0152a6d0aeb3f308d8a06e489cc5568443 100644 (file)
@@ -24,6 +24,8 @@
 
 standard_testfile
 
+require allow_multi_inferior_tests
+
 require !use_gdb_stub
 
 if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
index 002de57fa7616727f1b456758773a918513a6ebe..4caadeafde5cf4073f688bc63bc6d922efcee740 100644 (file)
@@ -20,6 +20,8 @@
 # misbehave, including failing to load libthread_db.so.  See PR
 # gdb/25410.
 
+require allow_multi_inferior_tests
+
 # Build two executables, with different symbols.
 
 set exec1 "multi-re-run-1"
index 8c24602adeef9e65e91235a52ffab4bb9d91720b..dc88ca4b2e62352322ddcb65877c68e85faafef2 100644 (file)
@@ -175,6 +175,10 @@ proc multi_target_prepare {} {
        return 0
     }
 
+    if {![allow_multi_inferior_tests]} {
+       return 0
+    }
+
     # The plain remote target can't do multiple inferiors.
     if {[target_info gdb_protocol] != ""} {
        return 0
index 2f8b3b819d37ba391eeccddae441b946ce5f5d91..38322be5c440d701dc422ac1035f25617468d062 100644 (file)
@@ -25,6 +25,8 @@
 
 standard_testfile
 
+require allow_multi_inferior_tests
+
 require can_spawn_for_attach
 
 if [build_executable "failed to prepare" $testfile $srcfile {debug}] {
index 819c1c3d2ea19173781c4c747ec93907bda3dd3e..74f984cccd440b169b58464d45d907a4e1623dd0 100644 (file)
@@ -25,6 +25,8 @@
 
 standard_testfile .c -other.c
 
+require allow_multi_inferior_tests
+
 require !use_gdb_stub
 
 set srcfile_other ${srcfile2}
index b4ff09c72e77f5ecd8acb2b880b3947eceb026a2..47071f390ad994a1a4cefc8b9b786a08210a2b76 100644 (file)
@@ -18,6 +18,8 @@
 # Test that in all-stop mode with multiple inferiors, GDB stops all
 # threads upon receiving an exit event from one of the inferiors.
 
+require allow_multi_inferior_tests
+
 # This is a test specific for a native target, where we use the
 # "-exec" argument to "add-inferior" and we explicitly don't do
 # "maint set target-non-stop on".
index 6cc27eb1996d940b5e973df7a7dd7ad5a7d27375..1785ac28494e214eac7f7e6a9f5df69f9cedc366 100644 (file)
@@ -54,6 +54,8 @@ with_test_prefix "single-inferior" {
 # non-extended gdbserver is not supported.
 require !use_gdb_stub
 
+require allow_multi_inferior_tests
+
 # Test with multiple inferiors.  This time, since we restart inferior
 # 1 while inferior 2 still has threads, then the new thread 1.1 should
 # end up with GID == 3, since we won't be able to reset the global
index dab6275dc03cfb25c9ab88ef5157431a06226dec..436a38a985ce07c94621923f4f290b0801fe5122 100644 (file)
@@ -124,6 +124,9 @@ with_test_prefix "single inferior" {
     gdb_test "print \$_inferior_thread_count" " = 1"
 }
 
+# The rest of the tests require running multiple inferiors.
+require allow_multi_inferior_tests
+
 # "info threads" while there are multiple inferiors should show
 # qualified thread IDs.
 with_test_prefix "two inferiors" {
index f4486899d73bf10aa3ddaf2286235db82d975a19..b0c873112c8a1008a2ffde7f4583df36f760499c 100644 (file)
@@ -16,6 +16,8 @@
 standard_testfile
 set executable ${testfile}
 
+require allow_multi_inferior_tests
+
 # Multiple inferiors are needed, therefore both native and extended gdbserver
 # modes are supported.  Only non-extended gdbserver is not supported.
 require !use_gdb_stub
index b41e3b23bd22b6ca2a859da6bd4cde520a61ec2e..fec31c3203a2e4301fc1cfdbfa6abbf9698115a1 100644 (file)
@@ -74,42 +74,45 @@ proc test { non_stop } {
     delete_breakpoints
 
     # Start the second inferior.
-    with_test_prefix "second inferior" {
-       # With stub targets that do reload on run, if we let the new
-       # inferior share inferior 1's connection, runto would
-       # fail because GDB is already connected to something, like
-       # e.g. with --target_board=native-gdbserver:
-       #
-       #  (gdb) kill
-       #  ...
-       #  (gdb) target remote localhost:2348
-       #  Already connected to a remote target.  Disconnect? (y or n)
-       #
-       # Instead, start the inferior with no connection, and let
-       # gdb_load/runto spawn a new remote connection/gdbserver.
-       #
-       # OTOH, with extended-remote, we must let the new inferior
-       # reuse the current connection, so that runto below can
-       # issue the "run" command, and have the inferior run on the
-       # remote target.  If we forced no connection, then "run" would
-       # either fail if "set auto-connect-native-target" is on, like
-       # the native-extended-gdbserver board enforces, or it would
-       # run the inferior on the native target, which isn't what is
-       # being tested.
-       #
-       # Since it's reload_on_run targets that need special care, we
-       # default to reusing the connection on most targets.
-       if [target_info exists gdb,do_reload_on_run] {
-           gdb_test "add-inferior -no-connection" "New inferior 2.*"
-       } else {
-           gdb_test "add-inferior" "New inferior 2.*"
-       }
-       gdb_test "inferior 2" "Switching to inferior 2 .*"
-
-       gdb_load $binfile
-
-       if ![runto setup_done] {
-           return -1
+    if {[allow_multi_inferior_tests]} {
+       with_test_prefix "second inferior" {
+           # With stub targets that do reload on run, if we let the
+           # new inferior share inferior 1's connection, runto would
+           # fail because GDB is already connected to something, like
+           # e.g. with --target_board=native-gdbserver:
+           #
+           #  (gdb) kill
+           #  ...
+           #  (gdb) target remote localhost:2348
+           #  Already connected to a remote target.  Disconnect? (y or n)
+           #
+           # Instead, start the inferior with no connection, and let
+           # gdb_load/runto spawn a new remote connection/gdbserver.
+           #
+           # OTOH, with extended-remote, we must let the new inferior
+           # reuse the current connection, so that runto below can
+           # issue the "run" command, and have the inferior run on
+           # the remote target.  If we forced no connection, then
+           # "run" would either fail if "set
+           # auto-connect-native-target" is on, like the
+           # native-extended-gdbserver board enforces, or it would
+           # run the inferior on the native target, which isn't what
+           # is being tested.
+           #
+           # Since it's reload_on_run targets that need special care,
+           # we default to reusing the connection on most targets.
+           if [target_info exists gdb,do_reload_on_run] {
+               gdb_test "add-inferior -no-connection" "New inferior 2.*"
+           } else {
+               gdb_test "add-inferior" "New inferior 2.*"
+           }
+           gdb_test "inferior 2" "Switching to inferior 2 .*"
+
+           gdb_load $binfile
+
+           if ![runto setup_done] {
+               return -1
+           }
        }
     }
 
@@ -158,13 +161,15 @@ proc test { non_stop } {
        verbose -log "xxxxx: iteration $iter"
        gdb_test -nopass "info threads"
 
-       if {$inf == 1} {
-           set inf 2
-       } else {
-           set inf 1
-       }
+       if {[allow_multi_inferior_tests]} {
+           if {$inf == 1} {
+               set inf 2
+           } else {
+               set inf 1
+           }
 
-       my_gdb_test "inferior $inf" ".*" "inferior $inf"
+           my_gdb_test "inferior $inf" ".*" "inferior $inf"
+       }
 
        my_gdb_test "print global_var = 555" " = 555" \
            "write to global_var"
index e48b83cd77f18208c8c316eb2abc30e781003012..8a1cb292c3d0eac53f3cdf85efd0c742f35645a1 100644 (file)
@@ -50,6 +50,8 @@
 
 require can_spawn_for_attach
 
+require allow_multi_inferior_tests
+
 standard_testfile
 
 set bp_lineno [gdb_get_line_number "Set breakpoint here"]
index c53db7963aff5abad3ead577a9874509a170cef6..9110617b7e10624e55a78ef8e8abb0e22ee2fa9b 100644 (file)
@@ -224,6 +224,8 @@ proc kill_and_remove_inferior {thread_set} {
 
 # Test both "all" and a thread list, because those are implemented as
 # different commands in GDB.
-foreach_with_prefix thread_set {"all" "1.1"} {
-    kill_and_remove_inferior $thread_set
+if {[allow_multi_inferior_tests]} {
+    foreach_with_prefix thread_set {"all" "1.1"} {
+       kill_and_remove_inferior $thread_set
+    }
 }
index d552039a400cf41e8d55250e23544233a0579821..1f87427755d6eda2f622bac07df2a2f248e0bd17 100644 (file)
@@ -27,6 +27,8 @@
 
 require allow_fork_tests
 
+require allow_multi_inferior_tests
+
 require !use_gdb_stub
 
 standard_testfile .c -sleep.c
index 669068536e9b8056e0d646d690736565e6740204..ef46e8f58c0f7fc63fd8e131b388b9d6b4b7f2d4 100644 (file)
@@ -5111,6 +5111,24 @@ proc allow_fork_tests {} {
     return 1
 }
 
+# Return whether we allow running testcases that want to debug
+# multiple inferiors with the same target.  Not all targets support
+# this.  Note that some tests add a second inferior but never start
+# it.  Those tests should not be skipped due to this proc returning
+# false.
+
+proc allow_multi_inferior_tests {} {
+    if {[istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"]} {
+       return 0
+    }
+
+    if {[use_gdb_stub]} {
+       return 0
+    }
+
+    return 1
+}
+
 # Return a 1 if we should run tests that require hardware breakpoints
 
 proc allow_hw_breakpoint_tests {} {