Extend "skip" command to support -file, -gfile, -function, -rfunction.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / skip.exp
CommitLineData
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
19if { [prepare_for_testing skip.exp "skip" \
20 {skip.c skip1.c } \
21 {debug nowarnings}] } {
22 return -1
23}
24
25set srcfile skip.c
26set srcfile1 skip1.c
27
1bfeeb0f 28# Right after we start gdb, there's no default file or function to skip.
21b1f8d2 29
a79b18b5 30gdb_test "skip file" "No default file now." "skip file (no default file)"
1bfeeb0f 31gdb_test "skip function" "No default function now."
a79b18b5 32gdb_test "skip" "No default function now." "skip (no default function)"
1bfeeb0f 33
cce0e923
DE
34# Test elided args.
35
36gdb_test "skip -fi" "Missing value for -fi option."
37gdb_test "skip -file" "Missing value for -file option."
38gdb_test "skip -fu" "Missing value for -fu option."
39gdb_test "skip -function" "Missing value for -function option."
40gdb_test "skip -rfu" "Missing value for -rfu option."
41gdb_test "skip -rfunction" "Missing value for -rfunction option."
42
43# Test other invalid option combinations.
44
45gdb_test "skip -x" "Invalid skip option: -x"
46gdb_test "skip -rfu foo.* xyzzy" "Invalid argument: xyzzy"
47
48if ![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
55gdb_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 59gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)"
85817405 60gdb_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 64gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\."
85817405 65gdb_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
69gdb_test "skip enable 999" "No skiplist entries found with number 999."
70gdb_test "skip disable 999" "No skiplist entries found with number 999."
71gdb_test "skip delete 999" "No skiplist entries found with number 999."
72gdb_test "skip enable a" "Args must be numbers or '\\$' variables."
73gdb_test "skip disable a" "Args must be numbers or '\\$' variables."
74gdb_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
78gdb_test "info skip 999" "No skiplist entries found with number 999."
79
1bfeeb0f 80# Does |info skip| look right?
21b1f8d2 81
1bfeeb0f 82gdb_test "info skip" \
cce0e923
DE
83 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
841\\s+y\\s+n\\s+.*$srcfile\\s+n\\s+<none>\\s*
852\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
863\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
874\\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
93if ![runto_main] {
94 fail "Can't run to main"
95 return
96}
a79b18b5 97gdb_test "step" ".*" "step in the main"
1bfeeb0f
JL
98gdb_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
103gdb_test "skip delete 1"
104# Check that entry 1 is missing from |info skip|
105gdb_test "info skip" \
cce0e923
DE
106 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1072\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
1083\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
1094\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
a79b18b5 110 "info skip (delete 1)"
1bfeeb0f 111
cce0e923
DE
112if ![runto_main] {
113 fail "Can't run to main"
114 return
115}
9482b9fb
DE
116set test "step after deleting 1"
117gdb_test "step" "foo \\(\\) at.*" "$test (1)"
118gdb_test "step" ".*" "$test (2)" ; # Return from foo()
119gdb_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
124gdb_test "skip disable 3"
125# Is entry 3 disabled in |info skip|?
cce0e923
DE
126gdb_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
130if ![runto_main] {
131 fail "Can't run to main"
132 return
133}
9482b9fb
DE
134set test "step after disabling 3"
135gdb_test "step" "bar \\(\\) at.*" "$test (1)"
136gdb_test "step" ".*" "$test (2)"; # Return from foo()
137gdb_test "step" "foo \\(\\) at.*" "$test (3)"
138gdb_test "step" ".*" "$test (4)"; # Return from bar()
139gdb_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
143gdb_test "skip enable 3"
144# Is entry 3 enabled in |info skip|?
cce0e923
DE
145gdb_test "info skip 3" \
146 "3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \
147 "info skip shows entry as enabled"
148if ![runto_main] {
149 fail "Can't run to main"
150 return
151}
9482b9fb
DE
152set test "step after enable 3"
153gdb_test "step" "foo \\(\\) at.*" "$test (1)"
154gdb_test "step" ".*" "$test (2)"; # Return from foo()
155gdb_test "step" "main \\(\\) at.*" "$test (3)"
1bfeeb0f
JL
156
157gdb_test "skip disable"
158gdb_test "info skip" \
cce0e923
DE
159 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1602\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s*
1613\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
1624\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
163 "info skip after disabling all"
1bfeeb0f
JL
164
165gdb_test "skip enable"
166gdb_test "info skip" \
cce0e923
DE
167 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1682\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
1693\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
1704\\s+y\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
171 "info skip after enabling all"
1bfeeb0f
JL
172
173gdb_test "skip disable 4 2-3"
174gdb_test "info skip" \
cce0e923
DE
175 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1762\\s+n\\s+n\\s+<none>\\s+n\\s+main\\s*
1773\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
1784\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
179 "info skip after disabling 4 2-3"
1bfeeb0f
JL
180
181gdb_test "skip enable 2-3"
182gdb_test "info skip" \
cce0e923
DE
183 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1842\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
1853\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*
1864\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
187 "info skip after enabling 2-3"
1bfeeb0f
JL
188
189gdb_test "info skip 2-3" \
cce0e923
DE
190 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1912\\s+y\\s+n\\s+<none>\\s+n\\s+main\\s*
1923\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \
193 "info skip 2-3"
1bfeeb0f
JL
194
195gdb_test "skip delete 2 3"
196gdb_test "info skip" \
cce0e923
DE
197 "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1984\\s+n\\s+n\\s+<none>\\s+n\\s+baz\\s*" \
199 "info skip after deleting 2 3"
1bfeeb0f
JL
200
201gdb_test "skip delete"
202gdb_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.
208gdb_test "skip -fi skip1.c" "File .*$srcfile1 will be skipped when stepping\."
209gdb_test "skip -gfi sk*1.c" "File\\(s\\) sk\\*1.c will be skipped when stepping\."
210gdb_test "skip -fu baz" "Function baz will be skipped when stepping\."
211gdb_test "skip -rfu ^b.z$" "Function\\(s\\) \\^b\\.z\\$ will be skipped when stepping."
212
213if ![runto_main] {
214 fail "Can't run to main"
215 return
216}
217
218set test "step using -fi"
219gdb_test_no_output "skip disable"
220gdb_test_no_output "skip enable 5"
221gdb_test "step" "foo \\(\\) at.*" "$test (1)"
222gdb_test "step" ".*" "$test (2)"; # Return from foo()
223gdb_test "step" "main \\(\\) at.*" "$test (3)"
224
225if ![runto_main] {
226 fail "Can't run to main"
227 return
228}
229
230set test "step using -gfi"
231gdb_test_no_output "skip disable"
232gdb_test_no_output "skip enable 6"
233gdb_test "step" "foo \\(\\) at.*" "$test (1)"
234gdb_test "step" ".*" "$test (2)"; # Return from foo()
235gdb_test "step" "main \\(\\) at.*" "$test (3)"
236
237if ![runto_main] {
238 fail "Can't run to main"
239 return
240}
241
242set test "step using -fu for baz"
243gdb_test_no_output "skip disable"
244gdb_test_no_output "skip enable 7"
245gdb_test "step" "bar \\(\\) at.*" "$test (1)"
246gdb_test "step" ".*" "$test (2)"; # Return from bar()
247gdb_test "step" "foo \\(\\) at.*" "$test (3)"
248gdb_test "step" ".*" "$test (4)"; # Return from foo()
249gdb_test "step" "main \\(\\) at.*" "$test (5)"
250
251if ![runto_main] {
252 fail "Can't run to main"
253 return
254}
255
256set test "step using -rfu for baz"
257gdb_test_no_output "skip disable"
258gdb_test_no_output "skip enable 8"
259gdb_test "step" "bar \\(\\) at.*" "$test (1)"
260gdb_test "step" ".*" "$test (2)"; # Return from bar()
261gdb_test "step" "foo \\(\\) at.*" "$test (3)"
262gdb_test "step" ".*" "$test (4)"; # Return from foo()
263gdb_test "step" "main \\(\\) at.*" "$test (5)"
264
265# Test -fi + -fu.
266
267if ![runto_main] {
268 fail "Can't run to main"
269 return
270}
271
272set test "step using -fi + -fu"
273gdb_test_no_output "skip delete"
274gdb_test "skip -fi skip1.c -fu test_skip" \
275 "Function test_skip in file skip1.c will be skipped when stepping\."
276gdb_breakpoint "test_skip_file_and_function"
277gdb_breakpoint "end_test_skip_file_and_function"
278gdb_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.
280gdb_test "step" "test_skip \\(\\) at.*" "$test (1)"
281gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "$test (2)"; # Return from test_skip()
282gdb_test "step" "skip1_test_skip_file_and_function \\(\\) at.*" "$test (4)"
283gdb_test "step" ".*" "$test (5)"; # Skip over test_skip()
284gdb_test "step" "test_skip_file_and_function \\(\\) at.*" "$test (6)"; # Return from skip1_test_skip_file_and_function()
This page took 0.546102 seconds and 4 git commands to generate.