aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.multi/stop-all-on-exit.exp
blob: 5d164381a4f485bd745f0c442bcfa66445e59271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This testcase is part of GDB, the GNU debugger.

# Copyright 2020-2021 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.

standard_testfile

if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
    return -1
}

if {![runto_main]} {
    fail "starting inferior 1"
    return -1
}

# 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_is_target_native]} {
    untested "the test is aimed at a native target"
    return 0
}

# 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]} {
    fail "starting inferior 2"
    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
    }
}