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