Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2011-2016 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 JL |
18 | |
19 | if { [prepare_for_testing skip.exp "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 | ||
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] { | |
49 | fail "Can't run to main" | |
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 DE |
93 | if ![runto_main] { |
94 | fail "Can't run to main" | |
95 | return | |
96 | } | |
a79b18b5 | 97 | gdb_test "step" ".*" "step in the main" |
1bfeeb0f JL |
98 | gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" |
99 | ||
1bfeeb0f | 100 | # Now remove skip.c from the skiplist. Our first step should take us |
cce0e923 | 101 | # into foo(), and our second step should take us to the next line in main(). |
21b1f8d2 | 102 | |
1bfeeb0f JL |
103 | gdb_test "skip delete 1" |
104 | # Check that entry 1 is missing from |info skip| | |
105 | gdb_test "info skip" \ | |
cce0e923 DE |
106 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
107 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* | |
108 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
109 | 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
a79b18b5 | 110 | "info skip (delete 1)" |
1bfeeb0f | 111 | |
cce0e923 DE |
112 | if ![runto_main] { |
113 | fail "Can't run to main" | |
114 | return | |
115 | } | |
9482b9fb DE |
116 | set test "step after deleting 1" |
117 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" | |
118 | gdb_test "step" ".*" "$test (2)" ; # Return from foo() | |
119 | gdb_test "step" "main \\(\\) at.*" "$test (3)" | |
1bfeeb0f | 120 | |
1bfeeb0f JL |
121 | # Now disable the skiplist entry for skip1.c. We should now |
122 | # step into foo(), then into bar(), but not into baz(). | |
21b1f8d2 | 123 | |
1bfeeb0f JL |
124 | gdb_test "skip disable 3" |
125 | # Is entry 3 disabled in |info skip|? | |
cce0e923 DE |
126 | gdb_test "info skip 3" \ |
127 | "3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ | |
128 | "info skip shows entry as disabled" | |
1bfeeb0f | 129 | |
cce0e923 DE |
130 | if ![runto_main] { |
131 | fail "Can't run to main" | |
132 | return | |
133 | } | |
9482b9fb DE |
134 | set test "step after disabling 3" |
135 | gdb_test "step" "bar \\(\\) at.*" "$test (1)" | |
136 | gdb_test "step" ".*" "$test (2)"; # Return from foo() | |
137 | gdb_test "step" "foo \\(\\) at.*" "$test (3)" | |
138 | gdb_test "step" ".*" "$test (4)"; # Return from bar() | |
139 | gdb_test "step" "main \\(\\) at.*" "$test (5)" | |
1bfeeb0f | 140 | |
1bfeeb0f | 141 | # Enable skiplist entry 3 and make sure we step over it like before. |
21b1f8d2 | 142 | |
1bfeeb0f JL |
143 | gdb_test "skip enable 3" |
144 | # Is entry 3 enabled in |info skip|? | |
cce0e923 DE |
145 | gdb_test "info skip 3" \ |
146 | "3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ | |
147 | "info skip shows entry as enabled" | |
148 | if ![runto_main] { | |
149 | fail "Can't run to main" | |
150 | return | |
151 | } | |
9482b9fb DE |
152 | set test "step after enable 3" |
153 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" | |
154 | gdb_test "step" ".*" "$test (2)"; # Return from foo() | |
155 | gdb_test "step" "main \\(\\) at.*" "$test (3)" | |
1bfeeb0f JL |
156 | |
157 | gdb_test "skip disable" | |
158 | gdb_test "info skip" \ | |
cce0e923 DE |
159 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
160 | 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s* | |
161 | 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
162 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
163 | "info skip after disabling all" | |
1bfeeb0f JL |
164 | |
165 | gdb_test "skip enable" | |
166 | gdb_test "info skip" \ | |
cce0e923 DE |
167 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
168 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* | |
169 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
170 | 4\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
171 | "info skip after enabling all" | |
1bfeeb0f JL |
172 | |
173 | gdb_test "skip disable 4 2-3" | |
174 | gdb_test "info skip" \ | |
cce0e923 DE |
175 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
176 | 2\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s* | |
177 | 3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
178 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
179 | "info skip after disabling 4 2-3" | |
1bfeeb0f JL |
180 | |
181 | gdb_test "skip enable 2-3" | |
182 | gdb_test "info skip" \ | |
cce0e923 DE |
183 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
184 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* | |
185 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s* | |
186 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
187 | "info skip after enabling 2-3" | |
1bfeeb0f JL |
188 | |
189 | gdb_test "info skip 2-3" \ | |
cce0e923 DE |
190 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
191 | 2\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s* | |
192 | 3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ | |
193 | "info skip 2-3" | |
1bfeeb0f JL |
194 | |
195 | gdb_test "skip delete 2 3" | |
196 | gdb_test "info skip" \ | |
cce0e923 DE |
197 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
198 | 4\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \ | |
199 | "info skip after deleting 2 3" | |
1bfeeb0f JL |
200 | |
201 | gdb_test "skip delete" | |
202 | gdb_test "info skip" "Not skipping any files or functions\." \ | |
cce0e923 DE |
203 | "info skip after deleting all" |
204 | ||
205 | # Now test skip -fi, etc. | |
206 | ||
207 | # Create a skiplist entry for a specified file and function. | |
208 | gdb_test "skip -fi skip1.c" "File .*$srcfile1 will be skipped when stepping\." | |
209 | gdb_test "skip -gfi sk*1.c" "File\\(s\\) sk\\*1.c will be skipped when stepping\." | |
210 | gdb_test "skip -fu baz" "Function baz will be skipped when stepping\." | |
211 | gdb_test "skip -rfu ^b.z$" "Function\\(s\\) \\^b\\.z\\$ will be skipped when stepping." | |
212 | ||
213 | if ![runto_main] { | |
214 | fail "Can't run to main" | |
215 | return | |
216 | } | |
217 | ||
218 | set test "step using -fi" | |
219 | gdb_test_no_output "skip disable" | |
220 | gdb_test_no_output "skip enable 5" | |
221 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" | |
222 | gdb_test "step" ".*" "$test (2)"; # Return from foo() | |
223 | gdb_test "step" "main \\(\\) at.*" "$test (3)" | |
224 | ||
225 | if ![runto_main] { | |
226 | fail "Can't run to main" | |
227 | return | |
228 | } | |
229 | ||
230 | set test "step using -gfi" | |
231 | gdb_test_no_output "skip disable" | |
232 | gdb_test_no_output "skip enable 6" | |
233 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" | |
234 | gdb_test "step" ".*" "$test (2)"; # Return from foo() | |
235 | gdb_test "step" "main \\(\\) at.*" "$test (3)" | |
236 | ||
237 | if ![runto_main] { | |
238 | fail "Can't run to main" | |
239 | return | |
240 | } | |
241 | ||
242 | set test "step using -fu for baz" | |
243 | gdb_test_no_output "skip disable" | |
244 | gdb_test_no_output "skip enable 7" | |
245 | gdb_test "step" "bar \\(\\) at.*" "$test (1)" | |
246 | gdb_test "step" ".*" "$test (2)"; # Return from bar() | |
247 | gdb_test "step" "foo \\(\\) at.*" "$test (3)" | |
248 | gdb_test "step" ".*" "$test (4)"; # Return from foo() | |
249 | gdb_test "step" "main \\(\\) at.*" "$test (5)" | |
250 | ||
251 | if ![runto_main] { | |
252 | fail "Can't run to main" | |
253 | return | |
254 | } | |
255 | ||
256 | set test "step using -rfu for baz" | |
257 | gdb_test_no_output "skip disable" | |
258 | gdb_test_no_output "skip enable 8" | |
259 | gdb_test "step" "bar \\(\\) at.*" "$test (1)" | |
260 | gdb_test "step" ".*" "$test (2)"; # Return from bar() | |
261 | gdb_test "step" "foo \\(\\) at.*" "$test (3)" | |
262 | gdb_test "step" ".*" "$test (4)"; # Return from foo() | |
263 | gdb_test "step" "main \\(\\) at.*" "$test (5)" | |
264 | ||
265 | # Test -fi + -fu. | |
266 | ||
267 | if ![runto_main] { | |
268 | fail "Can't run to main" | |
269 | return | |
270 | } | |
271 | ||
272 | set test "step using -fi + -fu" | |
273 | gdb_test_no_output "skip delete" | |
274 | gdb_test "skip -fi skip1.c -fu test_skip" \ | |
275 | "Function test_skip in file skip1.c will be skipped when stepping\." | |
276 | gdb_breakpoint "test_skip_file_and_function" | |
277 | gdb_breakpoint "end_test_skip_file_and_function" | |
278 | gdb_test "call test_skip_file_and_function ()" "silently stop." | |
279 | # Verify we can step into skip.c:test_skip but not skip1.c:test_skip. | |
280 | gdb_test "step" "test_skip \\(\\) at.*" "$test (1)" | |
281 | gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "$test (2)"; # Return from test_skip() | |
282 | gdb_test "step" "skip1_test_skip_file_and_function \\(\\) at.*" "$test (4)" | |
283 | gdb_test "step" ".*" "$test (5)"; # Skip over test_skip() | |
284 | gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "$test (6)"; # Return from skip1_test_skip_file_and_function() |