1 1.1 christos # This testcase is part of GDB, the GNU debugger. 2 1.1 christos 3 1.1.1.4 christos # Copyright 2018-2024 Free Software Foundation, Inc. 4 1.1 christos 5 1.1 christos # This program is free software; you can redistribute it and/or modify 6 1.1 christos # it under the terms of the GNU General Public License as published by 7 1.1 christos # the Free Software Foundation; either version 3 of the License, or 8 1.1 christos # (at your option) any later version. 9 1.1 christos # 10 1.1 christos # This program is distributed in the hope that it will be useful, 11 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos # GNU General Public License for more details. 14 1.1 christos # 15 1.1 christos # You should have received a copy of the GNU General Public License 16 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 1.1 christos 18 1.1 christos 19 1.1 christos # Test 'frame apply [all | COUNT | -COUNT | level LEVEL...] [FLAG]... COMMAND'. 20 1.1 christos 21 1.1 christos standard_testfile 22 1.1 christos 23 1.1 christos if { [prepare_for_testing "failed to prepare" ${testfile}] } { 24 1.1 christos return -1 25 1.1 christos } 26 1.1 christos 27 1.1.1.3 christos if {![runto setup_done]} { 28 1.1 christos return 0 29 1.1 christos } 30 1.1 christos 31 1.1 christos set any "\[^\r\n\]*" 32 1.1 christos set ws "\[ \t\]\+" 33 1.1 christos set number "\[0-9]\+" 34 1.1 christos 35 1.1 christos 36 1.1 christos # Check all | COUNT | -COUNT | level LEVEL... with a simple command. 37 1.1 christos with_test_prefix "simple command" { 38 1.1 christos foreach_with_prefix frame_apply_args { 39 1.1 christos "all" 40 1.1 christos "6" 41 1.1 christos "-6" 42 1.1 christos "level 0-5" 43 1.1 christos "level 0-3 4-5" 44 1.1 christos "level 0 1-2 3-5" 45 1.1 christos "level 0 1 2 3 4 5" 46 1.1 christos "level 0-0 1-1 2-2 3-3 4-4 5-5" } { 47 1.1 christos set cmd "frame apply $frame_apply_args p /x 20" 48 1.1 christos gdb_test $cmd \ 49 1.1 christos [multi_line \ 50 1.1 christos "#0${ws}setup_done ${any}" \ 51 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 52 1.1 christos "#1${ws}${any} f1 ${any}" \ 53 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 54 1.1 christos "#2${ws}${any} f2 ${any}" \ 55 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 56 1.1 christos "#3${ws}${any} f3 ${any}" \ 57 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 58 1.1 christos "#4${ws}${any} f4 ${any}" \ 59 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 60 1.1 christos "#5${ws}${any} main ${any}" \ 61 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 62 1.1 christos ] \ 63 1.1 christos "run a simple command on all frames" 64 1.1 christos } 65 1.1 christos } 66 1.1 christos 67 1.1 christos # Check frame apply on 3 innermost frames. 68 1.1 christos with_test_prefix "innermost 3" { 69 1.1 christos foreach_with_prefix frame_apply_args { 70 1.1 christos "3" 71 1.1 christos "level 0-2" } { 72 1.1 christos set cmd "frame apply $frame_apply_args p /x 20" 73 1.1 christos gdb_test $cmd \ 74 1.1 christos [multi_line \ 75 1.1 christos "#0${ws}setup_done ${any}" \ 76 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 77 1.1 christos "#1${ws}${any} f1 ${any}" \ 78 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 79 1.1 christos "#2${ws}${any} f2 ${any}" \ 80 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 81 1.1 christos ] \ 82 1.1 christos "run a simple command on the 3 innermost frames" 83 1.1 christos } 84 1.1 christos } 85 1.1 christos 86 1.1 christos # Check frame apply on 3 outermost frames. 87 1.1 christos with_test_prefix "outermost 3" { 88 1.1 christos foreach_with_prefix frame_apply_args { 89 1.1 christos "-3" } { 90 1.1 christos set cmd "frame apply $frame_apply_args p /x 20" 91 1.1 christos gdb_test $cmd \ 92 1.1 christos [multi_line \ 93 1.1 christos "#3${ws}${any} f3 ${any}" \ 94 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 95 1.1 christos "#4${ws}${any} f4 ${any}" \ 96 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 97 1.1 christos "#5${ws}${any} main ${any}" \ 98 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 99 1.1 christos ] \ 100 1.1 christos "run a simple command on the 3 outermost frames" 101 1.1 christos } 102 1.1 christos } 103 1.1 christos 104 1.1 christos # Check -c (continue) and -s (silently continue) flags. 105 1.1 christos with_test_prefix "!cont !silent flags" { 106 1.1 christos foreach_with_prefix frame_apply_args { 107 1.1 christos "all" 108 1.1 christos "level 0-5" 109 1.1 christos } { 110 1.1 christos set cmd "frame apply $frame_apply_args p f3arg" 111 1.1 christos gdb_test $cmd \ 112 1.1 christos [multi_line \ 113 1.1 christos "#0${ws}setup_done ${any}" \ 114 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 115 1.1 christos ] \ 116 1.1 christos "run a failing command that aborts frame apply" 117 1.1 christos } 118 1.1 christos } 119 1.1 christos 120 1.1 christos with_test_prefix "cont !silent flags" { 121 1.1 christos foreach_with_prefix frame_apply_args { 122 1.1 christos "all -c" 123 1.1 christos "level 0-5 -c"} { 124 1.1 christos set cmd "frame apply $frame_apply_args p f3arg" 125 1.1 christos gdb_test $cmd \ 126 1.1 christos [multi_line \ 127 1.1 christos "#0${ws}setup_done ${any}" \ 128 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 129 1.1 christos "#1${ws}${any} f1 ${any}" \ 130 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 131 1.1 christos "#2${ws}${any} f2 ${any}" \ 132 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 133 1.1 christos "#3${ws}${any} f3 ${any}" \ 134 1.1 christos "\\\$\[0-9]+ = 3${any}" \ 135 1.1 christos "#4${ws}${any} f4 ${any}" \ 136 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 137 1.1 christos "#5${ws}${any} main ${any}" \ 138 1.1 christos "No symbol \\\"f3arg\\\" in current context." \ 139 1.1 christos ] \ 140 1.1 christos "run a command failing in all frames except #3, -c to continue" 141 1.1 christos } 142 1.1 christos } 143 1.1 christos 144 1.1 christos with_test_prefix "!cont silent flags" { 145 1.1 christos foreach_with_prefix cmd_and_args { 146 1.1 christos "frame apply all -s" 147 1.1 christos "faas" 148 1.1 christos "frame apply level 0-5 -s"} { 149 1.1 christos set cmd "$cmd_and_args p f3arg" 150 1.1 christos gdb_test $cmd \ 151 1.1 christos [multi_line \ 152 1.1 christos "#3${ws}${any} f3 ${any}" \ 153 1.1 christos "\\\$\[0-9]+ = 3${any}" \ 154 1.1 christos ] \ 155 1.1 christos "run a command failing in all frames except #3, -s to silently continue" 156 1.1 christos } 157 1.1 christos } 158 1.1 christos 159 1.1 christos # Check quietness. 160 1.1 christos with_test_prefix "!quiet flag" { 161 1.1 christos foreach_with_prefix frame_apply_args { 162 1.1 christos "2" 163 1.1 christos "level 0-1"} { 164 1.1 christos set cmd "frame apply $frame_apply_args p /x 20" 165 1.1 christos gdb_test $cmd \ 166 1.1 christos [multi_line \ 167 1.1 christos "#0${ws}setup_done ${any}" \ 168 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 169 1.1 christos "#1${ws}${any} f1 ${any}" \ 170 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 171 1.1 christos ] \ 172 1.1 christos "run a command, printing location" 173 1.1 christos } 174 1.1 christos } 175 1.1 christos 176 1.1 christos with_test_prefix "quiet flag" { 177 1.1 christos foreach_with_prefix frame_apply_args { 178 1.1 christos "2 -q" 179 1.1 christos "level 0-1 -q"} { 180 1.1 christos set cmd "frame apply $frame_apply_args p /x 20" 181 1.1 christos gdb_test $cmd \ 182 1.1 christos [multi_line \ 183 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 184 1.1 christos "\\\$\[0-9]+ = 0x14${any}" \ 185 1.1 christos ] \ 186 1.1 christos "run a command with -q quiet flag, printing only command results" 187 1.1 christos } 188 1.1 christos } 189 1.1 christos 190 1.1 christos # Check multiple flags together. 191 1.1 christos with_test_prefix "quiet silent flags" { 192 1.1 christos foreach_with_prefix frame_apply_args { 193 1.1 christos "all -q -s -q" 194 1.1 christos "level 0-5 -q -s -q"} { 195 1.1 christos set cmd "frame apply $frame_apply_args p f3arg" 196 1.1 christos gdb_test $cmd \ 197 1.1 christos "\\\$\[0-9]+ = 3${any}" \ 198 1.1 christos "run a command failing in all frames except #3, -s to silently continue, quiet" 199 1.1 christos } 200 1.1 christos } 201 1.1 christos 202 1.1 christos # Check invalid flag combinations. 203 1.1 christos gdb_test "frame apply all -c -s p f3arg" \ 204 1.1 christos "frame apply all: -c and -s are mutually exclusive" \ 205 1.1 christos "check -c and -s cannot be used simultaneously" 206 1.1 christos 207 1.1 christos # Check some cases of missing or wrong args. 208 1.1 christos gdb_test "frame apply" "Missing COUNT argument." "missing COUNT" 209 1.1 christos gdb_test "frame apply -c" "Invalid COUNT argument." "invalid COUNT arg" 210 1.1 christos gdb_test "frame apply level 4-2 p 1" "inverted range" "inverted range" 211 1.1 christos gdb_test "frame apply level 0-3" \ 212 1.1 christos "Please specify a command to apply on the selected frames" \ 213 1.1 christos "missing command" 214 1.1.1.2 christos gdb_test "faas" "Please specify a command to apply on all frames" \ 215 1.1.1.2 christos "missing command for faas" 216