1 # Copyright 2009-2022 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test multi-exec / multi-process features that work for all configurations,
17 # even ones that cannot run multiple processes simultaneously.
22 set srcfile1 ${exec1}.c
23 set binfile1 [standard_output_file ${exec1}]
26 set srcfile2 ${exec2}.c
27 set binfile2 [standard_output_file ${exec2}]
30 set srcfile3 ${exec3}.c
31 set binfile3 [standard_output_file ${exec3}]
33 if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug}] == -1 } {
37 if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug}] == -1} {
41 if { [build_executable ${testfile}.exp ${exec3} "${srcfile3}" {debug}] == -1 } {
45 clean_restart ${exec1}
47 gdb_test {print $_inferior} " = 1"
49 # Add an empty inferior, switch to it, and load a main executable into
51 gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
52 gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2"
53 gdb_test "file ${binfile2}" ".*" "load ${exec2} file in inferior 2"
55 gdb_test {print $_inferior} " = 2" "print \$_inferior after switching"
57 # Add a new inferior and load a main executable into it in one
59 gdb_test "add-inferior -exec ${binfile3}" \
60 "Added inferior 3.*" \
61 "add inferior 3 with -exec ${exec3}"
63 # Check that we have multiple inferiors.
65 gdb_test "info inferiors" \
66 "Executable.*${exec1}.*${exec2}.*${exec3}.*"
68 # Test info inferiors with args
74 gdb_test_multiple "info inferior 2 3" "info inferior 2 3" {
75 -re ". 1 \[^\r\n\]*${exec1}" {
79 -re ". 2 \[^\r\n\]*${exec2}" {
83 -re ". 3 \[^\r\n\]*${exec3}" {
88 if {!$see1 && $see2 && $see3} {
89 pass "info inferior 2 3"
91 fail "info inferior 2 3"
100 gdb_test_multiple "info inferior 1-2" "info inferior 1-2" {
101 -re ". 1 \[^\r\n\]*${exec1}" {
105 -re ". 2 \[^\r\n\]*${exec2}" {
109 -re ". 3 \[^\r\n\]*${exec3}" {
113 -re "$gdb_prompt $" {
114 if {$see1 && $see2 && !$see3} {
115 pass "info inferior 1-2"
117 fail "info inferior 1-2"
122 # Test that we have multiple symbol tables.
124 gdb_test "inferior 1" ".*" "switch to inferior 1"
125 gdb_test "info functions commonfun" \
127 "'info functions commonfun' in inferior 1"
129 gdb_test "inferior 3" ".*" "switch to inferior 3"
130 gdb_test "info functions commonfun" \
132 "'info functions commonfun' in inferior 3"
134 gdb_test "inferior 1" ".*" "switch back to inferior 1"
136 gdb_test_no_output "set listsize 1"
138 gdb_test "list commonfun" "from hello.*" "list commonfun in hello"
140 gdb_test "print hglob" "1"
142 gdb_test "print glob" "92" "print glob (${exec1})"
145 gdb_test "inferior 3" ".*" "switch to inferior 3 to print globals"
147 gdb_test "print gglob" "2"
149 gdb_test "print glob" "45" "print glob (${exec3})"
151 gdb_test "list commonfun" "from goodbye.*" "list commonfun in goodbye"
154 # Let's run the hello program.
155 gdb_test "inferior 1" ".*" "switch to inferior 1 to run it"
161 gdb_test "break hello" ".*"
162 gdb_test "continue" "Breakpoint \[0-9\].*, hello.*"
164 # Now let's remove the other two
166 gdb_test_no_output "remove-inferiors 2-3" "remove-inferiors 2-3"
172 gdb_test_multiple "info inferiors" "check remove-inferiors" {
173 -re ". 3 \[^\r\n\]*${exec3}" {
177 -re ". 2 \[^\r\n\]*${exec2}" {
181 -re ". 1 \[^\r\n\]*${exec1}" {
185 -re "$gdb_prompt $" {
186 if {$see1 && !$see2 && !$see3} {
187 pass "check remove-inferiors"
189 fail "check remove-inferiors"