Update copyright year range in all GDB files
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / skip.exp
1 # Copyright 2011-2018 Free Software Foundation, Inc.
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)
17 # And further hacked on by Doug Evans. (dje@google.com)
18
19 if { [prepare_for_testing "failed to prepare" "skip" \
20 {skip.c skip1.c } \
21 {debug nowarnings}] } {
22 return -1
23 }
24
25 set srcfile skip.c
26 set srcfile1 skip1.c
27
28 # Right after we start gdb, there's no default file or function to skip.
29
30 gdb_test "skip file" "No default file now." "skip file (no default file)"
31 gdb_test "skip function" "No default function now."
32 gdb_test "skip" "No default function now." "skip (no default function)"
33
34 # Test elided args.
35
36 gdb_test "skip -fi" "Missing value for -fi option."
37 gdb_test "skip -file" "Missing value for -file option."
38 gdb_test "skip -fu" "Missing value for -fu option."
39 gdb_test "skip -function" "Missing value for -function option."
40 gdb_test "skip -rfu" "Missing value for -rfu option."
41 gdb_test "skip -rfunction" "Missing value for -rfunction option."
42
43 # Test other invalid option combinations.
44
45 gdb_test "skip -x" "Invalid skip option: -x"
46 gdb_test "skip -rfu foo.* xyzzy" "Invalid argument: xyzzy"
47
48 if ![runto_main] {
49 fail "can't run to main"
50 return
51 }
52
53 # Test |info skip| with an empty skiplist.
54
55 gdb_test "info skip" "Not skipping any files or functions\." "info skip empty"
56
57 # Create a skiplist entry for the current file and function.
58
59 gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)"
60 gdb_test "skip" "Function main will be skipped when stepping\." "skip (main)"
61
62 # Create a skiplist entry for a specified file and function.
63
64 gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\."
65 gdb_test "skip function baz" "Function baz will be skipped when stepping\."
66
67 # Test bad skiplist entry modification commands
68
69 gdb_test "skip enable 999" "No skiplist entries found with number 999."
70 gdb_test "skip disable 999" "No skiplist entries found with number 999."
71 gdb_test "skip delete 999" "No skiplist entries found with number 999."
72 gdb_test "skip enable a" "Args must be numbers or '\\$' variables."
73 gdb_test "skip disable a" "Args must be numbers or '\\$' variables."
74 gdb_test "skip delete a" "Args must be numbers or '\\$' variables."
75
76 # Ask for info on a skiplist entry which doesn't exist.
77
78 gdb_test "info skip 999" "No skiplist entries found with number 999."
79
80 # Does |info skip| look right?
81
82 gdb_test "info skip" \
83 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
84 1\\s+y\\s+n\\s+.*$srcfile\\s+n\\s+<none>\\s*
85 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
86 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
87 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*"
88
89 # Right now, we have an outstanding skiplist entry on both source
90 # files, so when we step into the first line in main(), we should step
91 # right over it and go to the second line of main().
92
93 if ![runto_main] {
94 fail "can't run to main"
95 return
96 }
97
98 gdb_test "step" ".*" "step in the main"
99 gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored"
100
101 # Now remove skip.c from the skiplist. Our first step should take us
102 # into foo(), and our second step should take us to the next line in main().
103
104 with_test_prefix "step after deleting 1" {
105 gdb_test "skip delete 1"
106 # Check that entry 1 is missing from |info skip|
107 gdb_test "info skip" \
108 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
109 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
110 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
111 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
112 "info skip (delete 1)"
113
114 if ![runto_main] {
115 fail "can't run to main"
116 return
117 }
118
119 gdb_test "step" "foo \\(\\) at.*" "step 1"
120 gdb_test "step" ".*" "step 2" ; # Return from foo()
121 gdb_test "step" "main \\(\\) at.*" "step 3"
122 }
123
124 # Now disable the skiplist entry for skip1.c. We should now
125 # step into foo(), then into bar(), but not into baz().
126
127 with_test_prefix "step after disabling 3" {
128 gdb_test "skip disable 3"
129 # Is entry 3 disabled in |info skip|?
130 gdb_test "info skip 3" \
131 "3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \
132 "info skip shows entry as disabled"
133
134 if ![runto_main] {
135 fail "can't run to main"
136 return
137 }
138
139 gdb_test "step" "bar \\(\\) at.*" "step 1"
140 gdb_test "step" ".*" "step 2"; # Return from foo()
141 gdb_test "step" "foo \\(\\) at.*" "step 3"
142 gdb_test "step" ".*" "step 4"; # Return from bar()
143 gdb_test "step" "main \\(\\) at.*" "step 5"
144 }
145
146 # Enable skiplist entry 3 and make sure we step over it like before.
147
148 with_test_prefix "step after enable 3" {
149 gdb_test "skip enable 3"
150 # Is entry 3 enabled in |info skip|?
151 gdb_test "info skip 3" \
152 "3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \
153 "info skip shows entry as enabled"
154
155 if ![runto_main] {
156 fail "can't run to main"
157 return
158 }
159
160 gdb_test "step" "foo \\(\\) at.*" "step 1"
161 gdb_test "step" ".*" "step 2"; # Return from foo()
162 gdb_test "step" "main \\(\\) at.*" "step 3"
163 }
164
165 # Admin tests (disable,enable,delete).
166
167 with_test_prefix "admin" {
168 gdb_test "skip disable"
169 gdb_test "info skip" \
170 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
171 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s*
172 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
173 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
174 "info skip after disabling all"
175
176 gdb_test "skip enable"
177 gdb_test "info skip" \
178 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
179 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
180 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
181 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
182 "info skip after enabling all"
183
184 gdb_test "skip disable 4 2-3"
185 gdb_test "info skip" \
186 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
187 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s*
188 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
189 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
190 "info skip after disabling 4 2-3"
191
192 gdb_test "skip enable 2-3"
193 gdb_test "info skip" \
194 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
195 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
196 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
197 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
198 "info skip after enabling 2-3"
199
200 gdb_test "info skip 2-3" \
201 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
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 "info skip 2-3"
205
206 gdb_test "skip delete 2 3"
207 gdb_test "info skip" \
208 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
209 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
210 "info skip after deleting 2 3"
211
212 gdb_test "skip delete"
213 gdb_test "info skip" "Not skipping any files or functions\." \
214 "info skip after deleting all"
215 }
216
217 # Now test skip -fi, etc.
218
219 # Create a skiplist entry for a specified file and function.
220 gdb_test "skip -fi skip1.c" "File .*$srcfile1 will be skipped when stepping\."
221 gdb_test "skip -gfi sk*1.c" "File\\(s\\) sk\\*1.c will be skipped when stepping\."
222 gdb_test "skip -fu baz" "Function baz will be skipped when stepping\."
223 gdb_test "skip -rfu ^b.z$" "Function\\(s\\) \\^b\\.z\\$ will be skipped when stepping."
224
225 with_test_prefix "step using -fi" {
226 if ![runto_main] {
227 fail "can't run to main"
228 return
229 }
230
231 gdb_test_no_output "skip disable"
232 gdb_test_no_output "skip enable 5"
233 gdb_test "step" "foo \\(\\) at.*" "step 1"
234 gdb_test "step" ".*" "step 2"; # Return from foo()
235 gdb_test "step" "main \\(\\) at.*" "step 3"
236 }
237
238 with_test_prefix "step using -gfi" {
239 if ![runto_main] {
240 fail "can't run to main"
241 return
242 }
243
244 gdb_test_no_output "skip disable"
245 gdb_test_no_output "skip enable 6"
246 gdb_test "step" "foo \\(\\) at.*" "step 1"
247 gdb_test "step" ".*" "step 2"; # Return from foo()
248 gdb_test "step" "main \\(\\) at.*" "step 3"
249 }
250
251 with_test_prefix "step using -fu for baz" {
252 if ![runto_main] {
253 fail "can't run to main"
254 return
255 }
256
257 gdb_test_no_output "skip disable"
258 gdb_test_no_output "skip enable 7"
259 gdb_test "step" "bar \\(\\) at.*" "step 1"
260 gdb_test "step" ".*" "step 2"; # Return from bar()
261 gdb_test "step" "foo \\(\\) at.*" "step 3"
262 gdb_test "step" ".*" "step 4"; # Return from foo()
263 gdb_test "step" "main \\(\\) at.*" "step 5"
264 }
265
266 with_test_prefix "step using -rfu for baz" {
267 if ![runto_main] {
268 fail "can't run to main"
269 return
270 }
271
272 gdb_test_no_output "skip disable"
273 gdb_test_no_output "skip enable 8"
274 gdb_test "step" "bar \\(\\) at.*" "step 1"
275 gdb_test "step" ".*" "step 2"; # Return from bar()
276 gdb_test "step" "foo \\(\\) at.*" "step 3"
277 gdb_test "step" ".*" "step 4"; # Return from foo()
278 gdb_test "step" "main \\(\\) at.*" "step 5"
279 }
280
281 # Test -fi + -fu.
282
283 with_test_prefix "step using -fi + -fu" {
284 gdb_test_no_output "skip delete"
285
286 if ![runto test_skip_file_and_function no-message] {
287 fail "can't run to test_skip_file_and_function"
288 return
289 }
290
291 gdb_test "skip -fi skip1.c -fu test_skip" \
292 "Function test_skip in file skip1.c will be skipped when stepping\."
293 # Verify we can step into skip.c:test_skip but not skip1.c:test_skip.
294 gdb_test "step" "test_skip \\(\\) at.*" "step 1"
295 gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "step 2"; # Return from test_skip()
296 gdb_test "step" "skip1_test_skip_file_and_function \\(\\) at.*" "step 3"
297 gdb_test "step" ".*" "step 4"; # Skip over test_skip()
298 gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "step 5"; # Return from skip1_test_skip_file_and_function()
299 }
This page took 0.041491 seconds and 5 git commands to generate.