]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.multi/base.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.multi / base.exp
CommitLineData
8acc9f48 1# Copyright 2009-2013 Free Software Foundation, Inc.
b321dd90
PA
2
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.
7#
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.
12#
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/>.
15
16# Test multi-exec / multi-process features that work for all configurations,
17# even ones that cannot run multiple processes simultaneously.
18
19set testfile "base"
20
21set exec1 "hello"
22set srcfile1 ${exec1}.c
7bb18ae2 23set binfile1 [standard_output_file ${exec1}]
b321dd90
PA
24
25set exec2 "hangout"
26set srcfile2 ${exec2}.c
7bb18ae2 27set binfile2 [standard_output_file ${exec2}]
b321dd90
PA
28
29set exec3 "goodbye"
30set srcfile3 ${exec3}.c
7bb18ae2 31set binfile3 [standard_output_file ${exec3}]
b321dd90 32
7bb18ae2 33if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug nowarnings}] == -1 } {
b321dd90
PA
34 return -1
35}
36
7bb18ae2 37if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug nowarnings}] == -1} {
b321dd90
PA
38 return -1
39}
40
7bb18ae2 41if { [build_executable ${testfile}.exp ${exec3} "${srcfile3}" {debug nowarnings}] == -1 } {
b321dd90
PA
42 return -1
43}
44
d8053d4d 45clean_restart ${exec1}
b321dd90
PA
46
47# Add an empty inferior space, switch to it, and load a main
48# executable into it.
d8053d4d
PA
49gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
50gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2"
51gdb_test "file ${binfile2}" ".*" "load ${exec2} file in inferior 2"
b321dd90
PA
52
53# Add a new inferior space and load a main executable into it in one
54# command.
d8053d4d
PA
55gdb_test "add-inferior -exec ${binfile3}" \
56 "Added inferior 3.*" \
57 "add inferior 3 with -exec ${exec3}"
b321dd90
PA
58
59# Check that we have multiple spaces.
60
61gdb_test "info inferiors" \
62 "Executable.*${exec3}.*${exec2}.*${exec1}.*"
63
c82c0b55
MS
64# Test info inferiors with args
65
66set see1 0
67set see2 0
68set see3 0
69
70gdb_test_multiple "info inferior 2 3" "info inferior 2 3" {
71 -re ". 3 \[^\r\n\]*${exec3}" {
72 set see3 1
73 exp_continue
74 }
75 -re ". 2 \[^\r\n\]*${exec2}" {
76 set see2 1
77 exp_continue
78 }
79 -re ". 1 \[^\r\n\]*${exec1}" {
80 set see1 1
81 exp_continue
82 }
83 -re "$gdb_prompt $" {
84 if { !$see1 && $see2 && $see3 } then {
85 pass "info inferior 2 3"
86 } else {
87 fail "info inferior 2 3"
88 }
89 }
90}
91
92set see1 0
93set see2 0
94set see3 0
95
96gdb_test_multiple "info inferior 1-2" "info inferior 1-2" {
97 -re ". 3 \[^\r\n\]*${exec3}" {
98 set see3 1
99 exp_continue
100 }
101 -re ". 2 \[^\r\n\]*${exec2}" {
102 set see2 1
103 exp_continue
104 }
105 -re ". 1 \[^\r\n\]*${exec1}" {
106 set see1 1
107 exp_continue
108 }
109 -re "$gdb_prompt $" {
110 if { $see1 && $see2 && !$see3 } then {
111 pass "info inferior 1-2"
112 } else {
113 fail "info inferior 1-2"
114 }
115 }
116}
117
b321dd90
PA
118# Test that we have multiple symbol tables.
119
d8053d4d
PA
120gdb_test "inferior 1" ".*" "switch to inferior 1"
121gdb_test "info functions commonfun" \
122 "${srcfile1}.*" \
123 "'info functions commonfun' in inferior 1"
b321dd90 124
d8053d4d
PA
125gdb_test "inferior 3" ".*" "switch to inferior 3"
126gdb_test "info functions commonfun" \
127 "${srcfile3}.*" \
128 "'info functions commonfun' in inferior 3"
b321dd90 129
d8053d4d 130gdb_test "inferior 1" ".*" "switch back to inferior 1"
b321dd90 131
019ebafc 132gdb_test_no_output "set listsize 1"
b321dd90 133
d8053d4d 134gdb_test "list commonfun" "from hello.*" "list commonfun in hello"
b321dd90
PA
135
136gdb_test "print hglob" "1"
137
138gdb_test "print glob" "92" "print glob (${exec1})"
139
140
d8053d4d 141gdb_test "inferior 3" ".*" "switch to inferior 3 to print globals"
b321dd90
PA
142
143gdb_test "print gglob" "2"
144
145gdb_test "print glob" "45" "print glob (${exec3})"
146
d8053d4d 147gdb_test "list commonfun" "from goodbye.*" "list commonfun in goodbye"
b321dd90
PA
148
149
150# Let's run the hello program.
d8053d4d 151gdb_test "inferior 1" ".*" "switch to inferior 1 to run it"
b321dd90
PA
152
153if { ![runto_main] } then {
154 return -1
155}
156
f6978de9 157gdb_test "break hello" ".*"
b321dd90 158gdb_test "continue" "Breakpoint \[0-9\].*, hello.*"
af624141
MS
159
160# Now let's remove the other two
161
162gdb_test_no_output "remove-inferiors 2-3" "remove-inferiors 2-3"
163
164set see1 0
165set see2 0
166set see3 0
167
168gdb_test_multiple "info inferiors" "check remove-inferiors" {
169 -re ". 3 \[^\r\n\]*${exec3}" {
170 set see3 1
171 exp_continue
172 }
173 -re ". 2 \[^\r\n\]*${exec2}" {
174 set see2 1
175 exp_continue
176 }
177 -re ". 1 \[^\r\n\]*${exec1}" {
178 set see1 1
179 exp_continue
180 }
181 -re "$gdb_prompt $" {
182 if { $see1 && !$see2 && !$see3 } then {
183 pass "check remove-inferiors"
184 } else {
185 fail "check remove-inferiors"
186 }
187 }
188}
189