Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2011-2020 Free Software Foundation, Inc. |
1bfeeb0f JL |
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 | # This file was written by Justin Lebar. (justin.lebar@gmail.com) | |
cce0e923 | 17 | # And further hacked on by Doug Evans. (dje@google.com) |
1bfeeb0f | 18 | |
53a89d6e SM |
19 | load_lib completion-support.exp |
20 | ||
21 | standard_testfile | |
22 | ||
5b362f04 | 23 | if { [prepare_for_testing "failed to prepare" "skip" \ |
b63634be BE |
24 | {skip.c skip1.c } \ |
25 | {debug nowarnings}] } { | |
1bfeeb0f JL |
26 | return -1 |
27 | } | |
28 | ||
29 | set srcfile skip.c | |
30 | set srcfile1 skip1.c | |
31 | ||
1bfeeb0f | 32 | # Right after we start gdb, there's no default file or function to skip. |
21b1f8d2 | 33 | |
a79b18b5 | 34 | gdb_test "skip file" "No default file now." "skip file (no default file)" |
1bfeeb0f | 35 | gdb_test "skip function" "No default function now." |
a79b18b5 | 36 | gdb_test "skip" "No default function now." "skip (no default function)" |
1bfeeb0f | 37 | |
cce0e923 DE |
38 | # Test elided args. |
39 | ||
40 | gdb_test "skip -fi" "Missing value for -fi option." | |
41 | gdb_test "skip -file" "Missing value for -file option." | |
42 | gdb_test "skip -fu" "Missing value for -fu option." | |
43 | gdb_test "skip -function" "Missing value for -function option." | |
44 | gdb_test "skip -rfu" "Missing value for -rfu option." | |
45 | gdb_test "skip -rfunction" "Missing value for -rfunction option." | |
46 | ||
47 | # Test other invalid option combinations. | |
48 | ||
49 | gdb_test "skip -x" "Invalid skip option: -x" | |
50 | gdb_test "skip -rfu foo.* xyzzy" "Invalid argument: xyzzy" | |
51 | ||
52 | if ![runto_main] { | |
bc6c7af4 | 53 | fail "can't run to main" |
cce0e923 DE |
54 | return |
55 | } | |
1bfeeb0f | 56 | |
1bfeeb0f | 57 | # Test |info skip| with an empty skiplist. |
21b1f8d2 | 58 | |
1bfeeb0f JL |
59 | gdb_test "info skip" "Not skipping any files or functions\." "info skip empty" |
60 | ||
1bfeeb0f | 61 | # Create a skiplist entry for the current file and function. |
21b1f8d2 | 62 | |
a79b18b5 | 63 | gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)" |
85817405 | 64 | gdb_test "skip" "Function main will be skipped when stepping\." "skip (main)" |
1bfeeb0f | 65 | |
1bfeeb0f | 66 | # Create a skiplist entry for a specified file and function. |
21b1f8d2 | 67 | |
1bfeeb0f | 68 | gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\." |
85817405 | 69 | gdb_test "skip function baz" "Function baz will be skipped when stepping\." |
1bfeeb0f | 70 | |
1bfeeb0f | 71 | # Test bad skiplist entry modification commands |
21b1f8d2 | 72 | |
1bfeeb0f JL |
73 | gdb_test "skip enable 999" "No skiplist entries found with number 999." |
74 | gdb_test "skip disable 999" "No skiplist entries found with number 999." | |
75 | gdb_test "skip delete 999" "No skiplist entries found with number 999." | |
529c08b2 PW |
76 | gdb_test "skip enable a" "Arguments must be numbers or '\\$' variables." |
77 | gdb_test "skip disable a" "Arguments must be numbers or '\\$' variables." | |
78 | gdb_test "skip delete a" "Arguments must be numbers or '\\$' variables." | |
1bfeeb0f | 79 | |
1bfeeb0f | 80 | # Ask for info on a skiplist entry which doesn't exist. |
21b1f8d2 | 81 | |
1bfeeb0f JL |
82 | gdb_test "info skip 999" "No skiplist entries found with number 999." |
83 | ||
1bfeeb0f | 84 | # Does |info skip| look right? |
21b1f8d2 | 85 | |
1bfeeb0f | 86 | gdb_test "info skip" \ |
cce0e923 DE |
87 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
88 | 1\\s+y\\s+n\\s+.*$srcfile\\s+n\\s+<none>\\s* | |
89 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* | |
90 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
91 | 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" | |
1bfeeb0f | 92 | |
1bfeeb0f JL |
93 | # Right now, we have an outstanding skiplist entry on both source |
94 | # files, so when we step into the first line in main(), we should step | |
95 | # right over it and go to the second line of main(). | |
1bfeeb0f | 96 | |
cce0e923 | 97 | if ![runto_main] { |
bc6c7af4 | 98 | fail "can't run to main" |
cce0e923 DE |
99 | return |
100 | } | |
bdf7e230 | 101 | |
a79b18b5 | 102 | gdb_test "step" ".*" "step in the main" |
1bfeeb0f JL |
103 | gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" |
104 | ||
1bfeeb0f | 105 | # Now remove skip.c from the skiplist. Our first step should take us |
cce0e923 | 106 | # into foo(), and our second step should take us to the next line in main(). |
21b1f8d2 | 107 | |
bdf7e230 DE |
108 | with_test_prefix "step after deleting 1" { |
109 | gdb_test "skip delete 1" | |
110 | # Check that entry 1 is missing from |info skip| | |
111 | gdb_test "info skip" \ | |
112 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
113 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* |
114 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
115 | 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
bdf7e230 | 116 | "info skip (delete 1)" |
1bfeeb0f | 117 | |
bdf7e230 | 118 | if ![runto_main] { |
bc6c7af4 | 119 | fail "can't run to main" |
bdf7e230 DE |
120 | return |
121 | } | |
122 | ||
123 | gdb_test "step" "foo \\(\\) at.*" "step 1" | |
124 | gdb_test "step" ".*" "step 2" ; # Return from foo() | |
125 | gdb_test "step" "main \\(\\) at.*" "step 3" | |
cce0e923 | 126 | } |
1bfeeb0f | 127 | |
1bfeeb0f JL |
128 | # Now disable the skiplist entry for skip1.c. We should now |
129 | # step into foo(), then into bar(), but not into baz(). | |
21b1f8d2 | 130 | |
bdf7e230 DE |
131 | with_test_prefix "step after disabling 3" { |
132 | gdb_test "skip disable 3" | |
133 | # Is entry 3 disabled in |info skip|? | |
134 | gdb_test "info skip 3" \ | |
135 | "3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ | |
136 | "info skip shows entry as disabled" | |
137 | ||
138 | if ![runto_main] { | |
bc6c7af4 | 139 | fail "can't run to main" |
bdf7e230 DE |
140 | return |
141 | } | |
142 | ||
143 | gdb_test "step" "bar \\(\\) at.*" "step 1" | |
5024637f BE |
144 | gdb_test "step" ".*" "step 2"; # Return from bar() |
145 | # With gcc 9.2.0 we jump once back to main before entering foo here. | |
146 | # If that happens try to step a second time. | |
3be966f6 AB |
147 | gdb_test "step" "foo \\(\\) at.*" "step 3" \ |
148 | "main \\(\\) at .*\r\n$gdb_prompt " "step" | |
5024637f | 149 | gdb_test "step" ".*" "step 4"; # Return from foo() |
bdf7e230 | 150 | gdb_test "step" "main \\(\\) at.*" "step 5" |
cce0e923 | 151 | } |
1bfeeb0f | 152 | |
1bfeeb0f | 153 | # Enable skiplist entry 3 and make sure we step over it like before. |
21b1f8d2 | 154 | |
bdf7e230 DE |
155 | with_test_prefix "step after enable 3" { |
156 | gdb_test "skip enable 3" | |
157 | # Is entry 3 enabled in |info skip|? | |
158 | gdb_test "info skip 3" \ | |
159 | "3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ | |
160 | "info skip shows entry as enabled" | |
161 | ||
162 | if ![runto_main] { | |
bc6c7af4 | 163 | fail "can't run to main" |
bdf7e230 DE |
164 | return |
165 | } | |
166 | ||
167 | gdb_test "step" "foo \\(\\) at.*" "step 1" | |
168 | gdb_test "step" ".*" "step 2"; # Return from foo() | |
169 | gdb_test "step" "main \\(\\) at.*" "step 3" | |
cce0e923 | 170 | } |
1bfeeb0f | 171 | |
bdf7e230 DE |
172 | # Admin tests (disable,enable,delete). |
173 | ||
174 | with_test_prefix "admin" { | |
175 | gdb_test "skip disable" | |
176 | gdb_test "info skip" \ | |
177 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
178 | 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s* |
179 | 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
180 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
bdf7e230 | 181 | "info skip after disabling all" |
1bfeeb0f | 182 | |
bdf7e230 DE |
183 | gdb_test "skip enable" |
184 | gdb_test "info skip" \ | |
185 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
186 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* |
187 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
188 | 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
bdf7e230 | 189 | "info skip after enabling all" |
1bfeeb0f | 190 | |
bdf7e230 DE |
191 | gdb_test "skip disable 4 2-3" |
192 | gdb_test "info skip" \ | |
193 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
194 | 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s* |
195 | 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
196 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
bdf7e230 | 197 | "info skip after disabling 4 2-3" |
1bfeeb0f | 198 | |
bdf7e230 DE |
199 | gdb_test "skip enable 2-3" |
200 | gdb_test "info skip" \ | |
201 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
202 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* |
203 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
204 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
bdf7e230 | 205 | "info skip after enabling 2-3" |
1bfeeb0f | 206 | |
bdf7e230 DE |
207 | gdb_test "info skip 2-3" \ |
208 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 | 209 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* |
11af934b | 210 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" |
1bfeeb0f | 211 | |
bdf7e230 DE |
212 | gdb_test "skip delete 2 3" |
213 | gdb_test "info skip" \ | |
214 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 | 215 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ |
bdf7e230 | 216 | "info skip after deleting 2 3" |
1bfeeb0f | 217 | |
bdf7e230 DE |
218 | gdb_test "skip delete" |
219 | gdb_test "info skip" "Not skipping any files or functions\." \ | |
220 | "info skip after deleting all" | |
221 | } | |
cce0e923 DE |
222 | |
223 | # Now test skip -fi, etc. | |
224 | ||
225 | # Create a skiplist entry for a specified file and function. | |
226 | gdb_test "skip -fi skip1.c" "File .*$srcfile1 will be skipped when stepping\." | |
227 | gdb_test "skip -gfi sk*1.c" "File\\(s\\) sk\\*1.c will be skipped when stepping\." | |
228 | gdb_test "skip -fu baz" "Function baz will be skipped when stepping\." | |
229 | gdb_test "skip -rfu ^b.z$" "Function\\(s\\) \\^b\\.z\\$ will be skipped when stepping." | |
230 | ||
bdf7e230 DE |
231 | with_test_prefix "step using -fi" { |
232 | if ![runto_main] { | |
bc6c7af4 | 233 | fail "can't run to main" |
bdf7e230 DE |
234 | return |
235 | } | |
236 | ||
237 | gdb_test_no_output "skip disable" | |
238 | gdb_test_no_output "skip enable 5" | |
239 | gdb_test "step" "foo \\(\\) at.*" "step 1" | |
240 | gdb_test "step" ".*" "step 2"; # Return from foo() | |
241 | gdb_test "step" "main \\(\\) at.*" "step 3" | |
cce0e923 DE |
242 | } |
243 | ||
bdf7e230 DE |
244 | with_test_prefix "step using -gfi" { |
245 | if ![runto_main] { | |
bc6c7af4 | 246 | fail "can't run to main" |
bdf7e230 DE |
247 | return |
248 | } | |
249 | ||
250 | gdb_test_no_output "skip disable" | |
251 | gdb_test_no_output "skip enable 6" | |
252 | gdb_test "step" "foo \\(\\) at.*" "step 1" | |
253 | gdb_test "step" ".*" "step 2"; # Return from foo() | |
254 | gdb_test "step" "main \\(\\) at.*" "step 3" | |
cce0e923 DE |
255 | } |
256 | ||
bdf7e230 DE |
257 | with_test_prefix "step using -fu for baz" { |
258 | if ![runto_main] { | |
bc6c7af4 | 259 | fail "can't run to main" |
bdf7e230 DE |
260 | return |
261 | } | |
262 | ||
263 | gdb_test_no_output "skip disable" | |
264 | gdb_test_no_output "skip enable 7" | |
265 | gdb_test "step" "bar \\(\\) at.*" "step 1" | |
266 | gdb_test "step" ".*" "step 2"; # Return from bar() | |
5024637f BE |
267 | # With gcc 9.2.0 we jump once back to main before entering foo here. |
268 | # If that happens try to step a second time. | |
3be966f6 AB |
269 | gdb_test "step" "foo \\(\\) at.*" "step 3" \ |
270 | "main \\(\\) at .*\r\n$gdb_prompt " "step" | |
bdf7e230 DE |
271 | gdb_test "step" ".*" "step 4"; # Return from foo() |
272 | gdb_test "step" "main \\(\\) at.*" "step 5" | |
cce0e923 DE |
273 | } |
274 | ||
bdf7e230 DE |
275 | with_test_prefix "step using -rfu for baz" { |
276 | if ![runto_main] { | |
bc6c7af4 | 277 | fail "can't run to main" |
bdf7e230 DE |
278 | return |
279 | } | |
280 | ||
281 | gdb_test_no_output "skip disable" | |
282 | gdb_test_no_output "skip enable 8" | |
283 | gdb_test "step" "bar \\(\\) at.*" "step 1" | |
284 | gdb_test "step" ".*" "step 2"; # Return from bar() | |
5024637f BE |
285 | # With gcc 9.2.0 we jump once back to main before entering foo here. |
286 | # If that happens try to step a second time. | |
3be966f6 AB |
287 | gdb_test "step" "foo \\(\\) at.*" "step 3" \ |
288 | "main \\(\\) at .*\r\n$gdb_prompt " "step" | |
bdf7e230 DE |
289 | gdb_test "step" ".*" "step 4"; # Return from foo() |
290 | gdb_test "step" "main \\(\\) at.*" "step 5" | |
cce0e923 DE |
291 | } |
292 | ||
cce0e923 DE |
293 | # Test -fi + -fu. |
294 | ||
bdf7e230 | 295 | with_test_prefix "step using -fi + -fu" { |
aa52b601 DE |
296 | gdb_test_no_output "skip delete" |
297 | ||
298 | if ![runto test_skip_file_and_function no-message] { | |
bc6c7af4 | 299 | fail "can't run to test_skip_file_and_function" |
bdf7e230 DE |
300 | return |
301 | } | |
302 | ||
bdf7e230 DE |
303 | gdb_test "skip -fi skip1.c -fu test_skip" \ |
304 | "Function test_skip in file skip1.c will be skipped when stepping\." | |
bdf7e230 DE |
305 | # Verify we can step into skip.c:test_skip but not skip1.c:test_skip. |
306 | gdb_test "step" "test_skip \\(\\) at.*" "step 1" | |
307 | gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "step 2"; # Return from test_skip() | |
308 | gdb_test "step" "skip1_test_skip_file_and_function \\(\\) at.*" "step 3" | |
309 | gdb_test "step" ".*" "step 4"; # Skip over test_skip() | |
310 | gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "step 5"; # Return from skip1_test_skip_file_and_function() | |
cce0e923 | 311 | } |
53a89d6e SM |
312 | |
313 | with_test_prefix "skip delete completion" { | |
314 | global binfile | |
315 | clean_restart "${binfile}" | |
316 | if ![runto_main] { | |
317 | fail "can't run to main" | |
318 | return | |
319 | } | |
320 | ||
321 | # Create a bunch of skips, don't care what they are. | |
322 | for {set i 0} {$i < 12} {incr i} { | |
323 | gdb_test "skip" ".*" "add skip $i" | |
324 | } | |
325 | ||
326 | set all_numbers { "1" "10" "11" "12" "2" "3" "4" "5" "6" "7" "8" "9" } | |
327 | ||
328 | # Test completing single numbers. | |
329 | test_gdb_complete_multiple "skip delete " "" "" $all_numbers | |
330 | test_gdb_complete_multiple "skip delete " "1" "" { "1" "10" "11" "12" } | |
331 | test_gdb_complete_multiple "skip delete 2 " "" "" $all_numbers | |
332 | test_gdb_complete_unique "skip delete 11" "skip delete 11" | |
333 | ||
334 | # Test completing ranges. | |
335 | test_gdb_complete_multiple "skip delete 2-" "" "" $all_numbers | |
336 | test_gdb_complete_unique "skip delete 2-5" "skip delete 2-5" | |
337 | ||
338 | # Test cases with no completion. | |
339 | test_gdb_complete_none "skip delete 123" | |
340 | test_gdb_complete_none "skip delete a1" | |
341 | test_gdb_complete_none "skip delete 2-33" | |
342 | } | |
343 |