| 1 | # Copyright 2011-2016 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 | |
| 18 | if { [prepare_for_testing skip.exp "skip" \ |
| 19 | {skip.c skip1.c } \ |
| 20 | {debug nowarnings}] } { |
| 21 | return -1 |
| 22 | } |
| 23 | |
| 24 | set srcfile skip.c |
| 25 | set srcfile1 skip1.c |
| 26 | |
| 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 | if ![runto_main] { fail "skip tests suppressed" } |
| 35 | |
| 36 | # |
| 37 | # Test |info skip| with an empty skiplist. |
| 38 | # |
| 39 | gdb_test "info skip" "Not skipping any files or functions\." "info skip empty" |
| 40 | |
| 41 | # |
| 42 | # Create a skiplist entry for the current file and function. |
| 43 | # |
| 44 | gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)" |
| 45 | gdb_test "skip" "Function main will be skipped when stepping\." "skip (main)" |
| 46 | |
| 47 | # |
| 48 | # Create a skiplist entry for a specified file and function. |
| 49 | # |
| 50 | gdb_test "skip file skip1.c" "File .*$srcfile1 will be skipped when stepping\." |
| 51 | gdb_test "skip function baz" "Function baz will be skipped when stepping\." |
| 52 | |
| 53 | # |
| 54 | # Test bad skiplist entry modification commands |
| 55 | # |
| 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." |
| 62 | |
| 63 | # |
| 64 | # Ask for info on a skiplist entry which doesn't exist. |
| 65 | # |
| 66 | gdb_test "info skip 999" "No skiplist entries found with number 999." |
| 67 | |
| 68 | # |
| 69 | # Does |info skip| look right? |
| 70 | # |
| 71 | gdb_test "info skip" \ |
| 72 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 73 | 1\\s+file\\s+y\\s+.*$srcfile\\s* |
| 74 | 2\\s+function\\s+y\\s+main\\s* |
| 75 | 3\\s+file\\s+y\\s+$srcfile1\\s* |
| 76 | 4\\s+function\\s+y\\s+baz\\s*" |
| 77 | |
| 78 | # |
| 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(). |
| 82 | # |
| 83 | |
| 84 | if ![runto_main] { fail "skip tests suppressed" } |
| 85 | gdb_test "step" ".*" "step in the main" |
| 86 | gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" |
| 87 | |
| 88 | # |
| 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 |
| 91 | # main(). |
| 92 | # |
| 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+What\\s* |
| 97 | 2\\s+function\\s+y\\s+main\\s* |
| 98 | 3\\s+file\\s+y\\s+$srcfile1\\s* |
| 99 | 4\\s+function\\s+y\\s+baz\\s*" \ |
| 100 | "info skip (delete 1)" |
| 101 | |
| 102 | if ![runto_main] { fail "skip tests suppressed" } |
| 103 | set test "step after deleting 1" |
| 104 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" |
| 105 | gdb_test "step" ".*" "$test (2)" ; # Return from foo() |
| 106 | gdb_test "step" "main \\(\\) at.*" "$test (3)" |
| 107 | |
| 108 | # |
| 109 | # Now disable the skiplist entry for skip1.c. We should now |
| 110 | # step into foo(), then into bar(), but not into baz(). |
| 111 | # |
| 112 | gdb_test "skip disable 3" |
| 113 | # Is entry 3 disabled in |info skip|? |
| 114 | gdb_test "info skip 3" ".*\\n3\\s+file\\s+n.*" \ |
| 115 | "info skip shows entry as disabled" |
| 116 | |
| 117 | if ![runto_main] { fail "skip tests suppressed" } |
| 118 | set test "step after disabling 3" |
| 119 | gdb_test "step" "bar \\(\\) at.*" "$test (1)" |
| 120 | gdb_test "step" ".*" "$test (2)"; # Return from foo() |
| 121 | gdb_test "step" "foo \\(\\) at.*" "$test (3)" |
| 122 | gdb_test "step" ".*" "$test (4)"; # Return from bar() |
| 123 | gdb_test "step" "main \\(\\) at.*" "$test (5)" |
| 124 | |
| 125 | # |
| 126 | # Enable skiplist entry 3 and make sure we step over it like before. |
| 127 | # |
| 128 | gdb_test "skip enable 3" |
| 129 | # Is entry 3 enabled in |info skip|? |
| 130 | gdb_test "info skip 3" ".*\\n3\\s+file\\s+y.*" \ |
| 131 | "info skip shows entry as enabled" |
| 132 | if ![runto_main] { fail "skip tests suppressed" } |
| 133 | set test "step after enable 3" |
| 134 | gdb_test "step" "foo \\(\\) at.*" "$test (1)" |
| 135 | gdb_test "step" ".*" "$test (2)"; # Return from foo() |
| 136 | gdb_test "step" "main \\(\\) at.*" "$test (3)" |
| 137 | |
| 138 | gdb_test "skip disable" |
| 139 | gdb_test "info skip" \ |
| 140 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 141 | 2\\s+function\\s+n\\s+main\\s* |
| 142 | 3\\s+file\\s+n\\s+$srcfile1\\s* |
| 143 | 4\\s+function\\s+n\\s+baz\\s*" \ |
| 144 | "info skip after disabling all" |
| 145 | |
| 146 | gdb_test "skip enable" |
| 147 | gdb_test "info skip" \ |
| 148 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 149 | 2\\s+function\\s+y\\s+main\\s* |
| 150 | 3\\s+file\\s+y\\s+$srcfile1\\s* |
| 151 | 4\\s+function\\s+y\\s+baz\\s*" \ |
| 152 | "info skip after enabling all" |
| 153 | |
| 154 | gdb_test "skip disable 4 2-3" |
| 155 | gdb_test "info skip" \ |
| 156 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 157 | 2\\s+function\\s+n\\s+main\\s* |
| 158 | 3\\s+file\\s+n\\s+$srcfile1\\s* |
| 159 | 4\\s+function\\s+n\\s+baz\\s*" \ |
| 160 | "info skip after disabling 4 2-3" |
| 161 | |
| 162 | gdb_test "skip enable 2-3" |
| 163 | gdb_test "info skip" \ |
| 164 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 165 | 2\\s+function\\s+y\\s+main\\s* |
| 166 | 3\\s+file\\s+y\\s+$srcfile1\\s* |
| 167 | 4\\s+function\\s+n\\s+baz\\s*" \ |
| 168 | "info skip after enabling 2-3" |
| 169 | |
| 170 | gdb_test "info skip 2-3" \ |
| 171 | "Num\\s+Type\\s+Enb\\s+What\\s* |
| 172 | 2\\s+function\\s+y\\s+main\\s* |
| 173 | 3\\s+file\\s+y\\s+$srcfile1\\s*" \ |
| 174 | "info skip 2-3" |
| 175 | |
| 176 | gdb_test "skip delete 2 3" |
| 177 | gdb_test "info skip" \ |
| 178 | "4\\s+function\\s+n\\s+baz\\s*" \ |
| 179 | "info skip after deleting 2 3" |
| 180 | |
| 181 | gdb_test "skip delete" |
| 182 | gdb_test "info skip" "Not skipping any files or functions\." \ |
| 183 | "info skip after deleting all" |