forked from Imagelibrary/binutils-gdb
gdb testsuite: Introduce allow_multi_inferior_tests and use it throughout
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
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
# commands.
|
||||
|
||||
require can_spawn_for_attach
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
standard_testfile
|
||||
set executable $testfile
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
require allow_btrace_tests
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
require !use_gdb_stub
|
||||
|
||||
standard_testfile
|
||||
|
||||
@@ -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" \
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
# Test attaching to multiple threaded programs.
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
standard_testfile
|
||||
|
||||
require can_spawn_for_attach
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
standard_testfile
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
require !use_gdb_stub
|
||||
|
||||
if {[build_executable "failed to prepare" $testfile $srcfile]} {
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
standard_testfile
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
require !use_gdb_stub
|
||||
|
||||
if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}] {
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
standard_testfile .c -other.c
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
require !use_gdb_stub
|
||||
|
||||
set srcfile_other ${srcfile2}
|
||||
|
||||
@@ -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".
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 .*"
|
||||
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
|
||||
gdb_load $binfile
|
||||
|
||||
if ![runto setup_done] {
|
||||
return -1
|
||||
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"
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
require allow_fork_tests
|
||||
|
||||
require allow_multi_inferior_tests
|
||||
|
||||
require !use_gdb_stub
|
||||
|
||||
standard_testfile .c -sleep.c
|
||||
|
||||
@@ -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 {} {
|
||||
|
||||
Reference in New Issue
Block a user