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