Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 2011-2017 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 | |
5b362f04 | 19 | if { [prepare_for_testing "failed to prepare" "skip" \ |
1bfeeb0f JL |
20 | {skip.c skip1.c } \ |
21 | {debug nowarnings}] } { | |
22 | return -1 | |
23 | } | |
24 | ||
25 | set srcfile skip.c | |
26 | set srcfile1 skip1.c | |
27 | ||
1bfeeb0f | 28 | # Right after we start gdb, there's no default file or function to skip. |
21b1f8d2 | 29 | |
a79b18b5 | 30 | gdb_test "skip file" "No default file now." "skip file (no default file)" |
1bfeeb0f | 31 | gdb_test "skip function" "No default function now." |
a79b18b5 | 32 | gdb_test "skip" "No default function now." "skip (no default function)" |
1bfeeb0f | 33 | |
cce0e923 DE |
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] { | |
bc6c7af4 | 49 | fail "can't run to main" |
cce0e923 DE |
50 | return |
51 | } | |
1bfeeb0f | 52 | |
1bfeeb0f | 53 | # Test |info skip| with an empty skiplist. |
21b1f8d2 | 54 | |
1bfeeb0f JL |
55 | gdb_test "info skip" "Not skipping any files or functions\." "info skip empty" |
56 | ||
1bfeeb0f | 57 | # Create a skiplist entry for the current file and function. |
21b1f8d2 | 58 | |
a79b18b5 | 59 | gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)" |
85817405 | 60 | gdb_test "skip" "Function main will be skipped when stepping\." "skip (main)" |
1bfeeb0f | 61 | |
1bfeeb0f | 62 | # Create a skiplist entry for a specified file and function. |
21b1f8d2 | 63 | |
1bfeeb0f | 64 | gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\." |
85817405 | 65 | gdb_test "skip function baz" "Function baz will be skipped when stepping\." |
1bfeeb0f | 66 | |
1bfeeb0f | 67 | # Test bad skiplist entry modification commands |
21b1f8d2 | 68 | |
1bfeeb0f JL |
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 | ||
1bfeeb0f | 76 | # Ask for info on a skiplist entry which doesn't exist. |
21b1f8d2 | 77 | |
1bfeeb0f JL |
78 | gdb_test "info skip 999" "No skiplist entries found with number 999." |
79 | ||
1bfeeb0f | 80 | # Does |info skip| look right? |
21b1f8d2 | 81 | |
1bfeeb0f | 82 | gdb_test "info skip" \ |
cce0e923 DE |
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*" | |
1bfeeb0f | 88 | |
1bfeeb0f JL |
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(). | |
1bfeeb0f | 92 | |
cce0e923 | 93 | if ![runto_main] { |
bc6c7af4 | 94 | fail "can't run to main" |
cce0e923 DE |
95 | return |
96 | } | |
bdf7e230 | 97 | |
a79b18b5 | 98 | gdb_test "step" ".*" "step in the main" |
1bfeeb0f JL |
99 | gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" |
100 | ||
1bfeeb0f | 101 | # Now remove skip.c from the skiplist. Our first step should take us |
cce0e923 | 102 | # into foo(), and our second step should take us to the next line in main(). |
21b1f8d2 | 103 | |
bdf7e230 DE |
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* | |
cce0e923 DE |
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*" \ | |
bdf7e230 | 112 | "info skip (delete 1)" |
1bfeeb0f | 113 | |
bdf7e230 | 114 | if ![runto_main] { |
bc6c7af4 | 115 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 | 122 | } |
1bfeeb0f | 123 | |
1bfeeb0f JL |
124 | # Now disable the skiplist entry for skip1.c. We should now |
125 | # step into foo(), then into bar(), but not into baz(). | |
21b1f8d2 | 126 | |
bdf7e230 DE |
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] { | |
bc6c7af4 | 135 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 | 144 | } |
1bfeeb0f | 145 | |
1bfeeb0f | 146 | # Enable skiplist entry 3 and make sure we step over it like before. |
21b1f8d2 | 147 | |
bdf7e230 DE |
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] { | |
bc6c7af4 | 156 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 | 163 | } |
1bfeeb0f | 164 | |
bdf7e230 DE |
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* | |
cce0e923 DE |
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*" \ | |
bdf7e230 | 174 | "info skip after disabling all" |
1bfeeb0f | 175 | |
bdf7e230 DE |
176 | gdb_test "skip enable" |
177 | gdb_test "info skip" \ | |
178 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* | |
cce0e923 DE |
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*" \ | |
bdf7e230 | 182 | "info skip after enabling all" |
1bfeeb0f | 183 | |
bdf7e230 DE |
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* | |
cce0e923 DE |
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*" \ | |
bdf7e230 | 190 | "info skip after disabling 4 2-3" |
1bfeeb0f | 191 | |
bdf7e230 DE |
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* | |
cce0e923 DE |
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*" \ | |
bdf7e230 | 198 | "info skip after enabling 2-3" |
1bfeeb0f | 199 | |
bdf7e230 DE |
200 | gdb_test "info skip 2-3" \ |
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*" \ | |
bdf7e230 | 204 | "info skip 2-3" |
1bfeeb0f | 205 | |
bdf7e230 DE |
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* | |
cce0e923 | 209 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ |
bdf7e230 | 210 | "info skip after deleting 2 3" |
1bfeeb0f | 211 | |
bdf7e230 DE |
212 | gdb_test "skip delete" |
213 | gdb_test "info skip" "Not skipping any files or functions\." \ | |
214 | "info skip after deleting all" | |
215 | } | |
cce0e923 DE |
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 | ||
bdf7e230 DE |
225 | with_test_prefix "step using -fi" { |
226 | if ![runto_main] { | |
bc6c7af4 | 227 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 DE |
236 | } |
237 | ||
bdf7e230 DE |
238 | with_test_prefix "step using -gfi" { |
239 | if ![runto_main] { | |
bc6c7af4 | 240 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 DE |
249 | } |
250 | ||
bdf7e230 DE |
251 | with_test_prefix "step using -fu for baz" { |
252 | if ![runto_main] { | |
bc6c7af4 | 253 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 DE |
264 | } |
265 | ||
bdf7e230 DE |
266 | with_test_prefix "step using -rfu for baz" { |
267 | if ![runto_main] { | |
bc6c7af4 | 268 | fail "can't run to main" |
bdf7e230 DE |
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" | |
cce0e923 DE |
279 | } |
280 | ||
cce0e923 DE |
281 | # Test -fi + -fu. |
282 | ||
bdf7e230 | 283 | with_test_prefix "step using -fi + -fu" { |
aa52b601 DE |
284 | gdb_test_no_output "skip delete" |
285 | ||
286 | if ![runto test_skip_file_and_function no-message] { | |
bc6c7af4 | 287 | fail "can't run to test_skip_file_and_function" |
bdf7e230 DE |
288 | return |
289 | } | |
290 | ||
bdf7e230 DE |
291 | gdb_test "skip -fi skip1.c -fu test_skip" \ |
292 | "Function test_skip in file skip1.c will be skipped when stepping\." | |
bdf7e230 DE |
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() | |
cce0e923 | 299 | } |