1 # Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Justin Lebar. (justin.lebar@gmail.com)
18 if { [prepare_for_testing skip.exp "skip" \
20 {debug nowarnings}] } {
28 # Right after we start gdb, there's no default file or function to skip.
30 gdb_test "skip file" "No default file now."
31 gdb_test "skip function" "No default function now."
32 gdb_test "skip" "No default function now."
34 if ![runto_main] { fail "skip tests suppressed" }
37 # Test |info skip| with an empty skiplist.
39 gdb_test "info skip" "Not skipping any files or functions\." "info skip empty"
42 # Create a skiplist entry for the current file and function.
44 gdb_test "skip file" "File .*$srcfile will be skipped when stepping\."
45 gdb_test "skip" "Function main at .* will be skipped when stepping\."
48 # Create a skiplist entry for a specified file and function.
50 gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\."
51 gdb_test "skip function baz" "Function baz at .* will be skipped when stepping\."
54 # Test bad skiplist entry modification commands
56 gdb_test "skip enable 999" "No skiplist entries found with number 999."
57 gdb_test "skip disable 999" "No skiplist entries found with number 999."
58 gdb_test "skip delete 999" "No skiplist entries found with number 999."
59 gdb_test "skip enable a" "Args must be numbers or '\\$' variables."
60 gdb_test "skip disable a" "Args must be numbers or '\\$' variables."
61 gdb_test "skip delete a" "Args must be numbers or '\\$' variables."
64 # Ask for info on a skiplist entry which doesn't exist.
66 gdb_test "info skip 999" "No skiplist entries found with number 999."
69 # Does |info skip| look right?
71 gdb_test "info skip" \
72 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
73 1\\s+file\\s+y\\s+.*$srcfile\\s*
74 2\\s+function\\s+y\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
75 3\\s+file\\s+y\\s+.*$srcfile1\\s*
76 4\\s+function\\s+y\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*"
79 # Right now, we have an outstanding skiplist entry on both source
80 # files, so when we step into the first line in main(), we should step
81 # right over it and go to the second line of main().
84 if ![runto_main] { fail "skip tests suppressed" }
86 gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored"
89 # Now remove skip.c from the skiplist. Our first step should take us
90 # into foo(), and our second step should take us to the next line in
93 gdb_test "skip delete 1"
94 # Check that entry 1 is missing from |info skip|
95 gdb_test "info skip" \
96 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
97 2\\s+function\\s+y\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
98 3\\s+file\\s+y\\s+.*$srcfile1\\s*
99 4\\s+function\\s+y\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*"
101 if ![runto_main] { fail "skip tests suppressed" }
102 gdb_test "step" "foo \\(\\) at.*" "step after deleting 1 (1)"
103 gdb_test "step"; # Return from foo()
104 gdb_test "step" "main \\(\\) at.*" "step after deleting 1 (2)"
107 # Now disable the skiplist entry for skip1.c. We should now
108 # step into foo(), then into bar(), but not into baz().
110 gdb_test "skip disable 3"
111 # Is entry 3 disabled in |info skip|?
112 gdb_test "info skip 3" ".*\\n3\\s+file\\s+n.*" \
113 "info skip shows entry as disabled"
115 if ![runto_main] { fail "skip tests suppressed" }
116 gdb_test "step" "bar \\(\\) at.*" "step after disabling 3 (1)"
117 gdb_test "step"; # Return from foo()
118 gdb_test "step" "foo \\(\\) at.*" "step after disabling 3 (2)"
119 gdb_test "step"; # Return from bar()
120 gdb_test "step" "main \\(\\) at.*" "step after disabling 3 (3)"
123 # Enable skiplist entry 3 and make sure we step over it like before.
125 gdb_test "skip enable 3"
126 # Is entry 3 enabled in |info skip|?
127 gdb_test "info skip 3" ".*\\n3\\s+file\\s+y.*" \
128 "info skip shows entry as enabled"
129 if ![runto_main] { fail "skip tests suppressed" }
130 gdb_test "step" "foo \\(\\) at.*" "step after deleting 1 (1)"
131 gdb_test "step"; # Return from foo()
132 gdb_test "step" "main \\(\\) at.*" "step after deleting 1 (2)"
134 gdb_test "skip disable"
135 gdb_test "info skip" \
136 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
137 2\\s+function\\s+n\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
138 3\\s+file\\s+n\\s+.*$srcfile1\\s*
139 4\\s+function\\s+n\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*" \
140 "info skip after disabling all"
142 gdb_test "skip enable"
143 gdb_test "info skip" \
144 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
145 2\\s+function\\s+y\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
146 3\\s+file\\s+y\\s+.*$srcfile1\\s*
147 4\\s+function\\s+y\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*" \
148 "info skip after enabling all"
150 gdb_test "skip disable 4 2-3"
151 gdb_test "info skip" \
152 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
153 2\\s+function\\s+n\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
154 3\\s+file\\s+n\\s+.*$srcfile1\\s*
155 4\\s+function\\s+n\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*" \
156 "info skip after disabling 4 2-3"
158 gdb_test "skip enable 2-3"
159 gdb_test "info skip" \
160 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
161 2\\s+function\\s+y\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
162 3\\s+file\\s+y\\s+.*$srcfile1\\s*
163 4\\s+function\\s+n\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*" \
164 "info skip after enabling 2-3"
166 gdb_test "info skip 2-3" \
167 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s*
168 2\\s+function\\s+y\\s+0x\[0-9a-f\]+ main at .*$srcfile:\[0-9\]+\\s*
169 3\\s+file\\s+y\\s+.*$srcfile1\\s*" \
172 gdb_test "skip delete 2 3"
173 gdb_test "info skip" \
174 "4\\s+function\\s+n\\s+0x\[0-9a-f\]+ baz at .*$srcfile1:\[0-9\]+\\s*" \
175 "info skip after deleting 2 3"
177 gdb_test "skip delete"
178 gdb_test "info skip" "Not skipping any files or functions\." \
179 "info skip after deleting all"