binutils-gdb/gdb/testsuite/gdb.multi/stop-all-on-exit.exp
Pedro Alves c7a2ee6491 gdb_is_target_native -> gdb_protocol_is_native
gdb_is_target_native uses "maint print target-stack", which is
unnecessary when checking whether gdb_protocol is empty would do.
Checking gdb_protocol is more efficient, and can be done before
starting GDB and running to main, unlike gdb_is_target_native.

This adds a new gdb_protocol_is_native procedure, and uses it in place
of gdb_is_target_native.

At first, I thought that we'd end up with a few testcases needing to
use gdb_is_target_native still, especially multi-target tests that
connect to targets different from the default board target, but no,
actually all uses of gdb_is_target_native could be converted.
gdb_is_target_native will be eliminated in a following patch.

In some spots, we no longer need to defer the check until after
starting GDB, so the patch adjusts accordingly.

Change-Id: Ia706232dbffac70f9d9740bcb89c609dbee5cee3
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-26 21:22:48 +01:00

63 lines
2.0 KiB
Plaintext

# This testcase is part of GDB, the GNU debugger.
# Copyright 2020-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test that in all-stop mode with multiple inferiors, GDB stops all
# threads upon receiving an exit event from one of the inferiors.
# 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".
if {![gdb_protocol_is_native]} {
untested "the test is aimed at a native target"
return 0
}
standard_testfile
if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
if {![runto_main]} {
return -1
}
# Add a second inferior that will sleep longer.
gdb_test "add-inferior -exec $binfile" "Added inferior 2.*" \
"add the second inferior"
gdb_test "inferior 2" ".*Switching to inferior 2.*"
if {![runto_main]} {
return -1
}
gdb_test "print duration=10" "= 10"
# Now continue both processes. We should get the exit event from the
# first inferior.
gdb_test_no_output "set schedule-multiple on"
gdb_continue_to_end
# GDB is expected to have stopped the other inferior. Switch to the
# slow inferior's thread. It should not be running.
gdb_test_multiple "thread 2.1" "check thread 2.1 is not running" {
-re "\\(running\\)\[\r\n\]+$gdb_prompt" {
fail $gdb_test_name
}
-re "$gdb_prompt" {
pass $gdb_test_name
}
}