Add "info connections" command, "info inferiors" connection number/string
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / kill-detach-inferiors-cmd.exp
CommitLineData
e3ae3c43
PP
1# This testcase is part of GDB, the GNU debugger.
2#
b811d2c2 3# Copyright 2015-2020 Free Software Foundation, Inc.
e3ae3c43
PP
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18# Test the basic operation of the "kill inferiors" and "detach inferiors"
19# commands.
20
21if ![can_spawn_for_attach] {
22 return 0
23}
24
25standard_testfile
26set executable $testfile
27
5b362f04 28if [prepare_for_testing "failed to prepare" $executable] {
e3ae3c43
PP
29 return -1
30}
31
32runto_main
33
34# Add another forked inferior process.
121b3efd 35gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
e3ae3c43 36gdb_test "inferior 2" "Switching to inferior 2.*"
3453e7e4 37gdb_test "file $binfile" "Reading symbols from .*" "load binary"
e3ae3c43
PP
38gdb_test "start" "Temporary breakpoint.*Starting program.*"
39
40# Add an attached inferior process.
41set test_spawn_id [spawn_wait_for_attach $binfile]
42set test_pid [spawn_id_get_pid $test_spawn_id]
121b3efd 43gdb_test "add-inferior" "Added inferior 3 on connection .*" "add inferior 3"
e3ae3c43
PP
44gdb_test "inferior 3" "Switching to inferior 3.*"
45gdb_test "attach $test_pid" "Attaching to process.*" "attach to pid"
46
47# Kill the first two inferiors, and detach the third.
48gdb_test_no_output "kill inferiors 1 2"
49gdb_test "inferior 1" "Switching to inferior 1.*"
50gdb_test "kill" "The program is not being run.*"
51gdb_test "detach inferiors 3" "Detaching from program.*process $test_pid.*"
52
53# No inferiors should be running anymore.
54gdb_test "kill inferiors 1 2 3" \
55 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
56gdb_test "detach inferiors 1 2 3" \
57 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
58
59gdb_test "kill inferiors 10" \
60 "ID 10 not known.*"
61
62kill_wait_spawned_process $test_spawn_id
This page took 0.529766 seconds and 4 git commands to generate.