1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2018-2019 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Test 'frame apply [all | COUNT | -COUNT | level LEVEL...] [FLAG]... COMMAND'.
23 if { [prepare_for_testing "failed to prepare" ${testfile}] } {
27 clean_restart ${binfile}
30 if ![runto setup_done] then {
31 fail "can't run to setup_done"
40 # Check all | COUNT | -COUNT | level LEVEL... with a simple command.
41 with_test_prefix "simple command" {
42 foreach_with_prefix frame_apply_args {
50 "level 0-0 1-1 2-2 3-3 4-4 5-5" } {
51 set cmd "frame apply $frame_apply_args p /x 20"
54 "#0${ws}setup_done ${any}" \
55 "\\\$\[0-9]+ = 0x14${any}" \
56 "#1${ws}${any} f1 ${any}" \
57 "\\\$\[0-9]+ = 0x14${any}" \
58 "#2${ws}${any} f2 ${any}" \
59 "\\\$\[0-9]+ = 0x14${any}" \
60 "#3${ws}${any} f3 ${any}" \
61 "\\\$\[0-9]+ = 0x14${any}" \
62 "#4${ws}${any} f4 ${any}" \
63 "\\\$\[0-9]+ = 0x14${any}" \
64 "#5${ws}${any} main ${any}" \
65 "\\\$\[0-9]+ = 0x14${any}" \
67 "run a simple command on all frames"
71 # Check frame apply on 3 innermost frames.
72 with_test_prefix "innermost 3" {
73 foreach_with_prefix frame_apply_args {
76 set cmd "frame apply $frame_apply_args p /x 20"
79 "#0${ws}setup_done ${any}" \
80 "\\\$\[0-9]+ = 0x14${any}" \
81 "#1${ws}${any} f1 ${any}" \
82 "\\\$\[0-9]+ = 0x14${any}" \
83 "#2${ws}${any} f2 ${any}" \
84 "\\\$\[0-9]+ = 0x14${any}" \
86 "run a simple command on the 3 innermost frames"
90 # Check frame apply on 3 outermost frames.
91 with_test_prefix "outermost 3" {
92 foreach_with_prefix frame_apply_args {
94 set cmd "frame apply $frame_apply_args p /x 20"
97 "#3${ws}${any} f3 ${any}" \
98 "\\\$\[0-9]+ = 0x14${any}" \
99 "#4${ws}${any} f4 ${any}" \
100 "\\\$\[0-9]+ = 0x14${any}" \
101 "#5${ws}${any} main ${any}" \
102 "\\\$\[0-9]+ = 0x14${any}" \
104 "run a simple command on the 3 outermost frames"
108 # Check -c (continue) and -s (silently continue) flags.
109 with_test_prefix "!cont !silent flags" {
110 foreach_with_prefix frame_apply_args {
114 set cmd "frame apply $frame_apply_args p f3arg"
117 "#0${ws}setup_done ${any}" \
118 "No symbol \\\"f3arg\\\" in current context." \
120 "run a failing command that aborts frame apply"
124 with_test_prefix "cont !silent flags" {
125 foreach_with_prefix frame_apply_args {
128 set cmd "frame apply $frame_apply_args p f3arg"
131 "#0${ws}setup_done ${any}" \
132 "No symbol \\\"f3arg\\\" in current context." \
133 "#1${ws}${any} f1 ${any}" \
134 "No symbol \\\"f3arg\\\" in current context." \
135 "#2${ws}${any} f2 ${any}" \
136 "No symbol \\\"f3arg\\\" in current context." \
137 "#3${ws}${any} f3 ${any}" \
138 "\\\$\[0-9]+ = 3${any}" \
139 "#4${ws}${any} f4 ${any}" \
140 "No symbol \\\"f3arg\\\" in current context." \
141 "#5${ws}${any} main ${any}" \
142 "No symbol \\\"f3arg\\\" in current context." \
144 "run a command failing in all frames except #3, -c to continue"
148 with_test_prefix "!cont silent flags" {
149 foreach_with_prefix cmd_and_args {
152 "frame apply level 0-5 -s"} {
153 set cmd "$cmd_and_args p f3arg"
156 "#3${ws}${any} f3 ${any}" \
157 "\\\$\[0-9]+ = 3${any}" \
159 "run a command failing in all frames except #3, -s to silently continue"
164 with_test_prefix "!quiet flag" {
165 foreach_with_prefix frame_apply_args {
168 set cmd "frame apply $frame_apply_args p /x 20"
171 "#0${ws}setup_done ${any}" \
172 "\\\$\[0-9]+ = 0x14${any}" \
173 "#1${ws}${any} f1 ${any}" \
174 "\\\$\[0-9]+ = 0x14${any}" \
176 "run a command, printing location"
180 with_test_prefix "quiet flag" {
181 foreach_with_prefix frame_apply_args {
184 set cmd "frame apply $frame_apply_args p /x 20"
187 "\\\$\[0-9]+ = 0x14${any}" \
188 "\\\$\[0-9]+ = 0x14${any}" \
190 "run a command with -q quiet flag, printing only command results"
194 # Check multiple flags together.
195 with_test_prefix "quiet silent flags" {
196 foreach_with_prefix frame_apply_args {
198 "level 0-5 -q -s -q"} {
199 set cmd "frame apply $frame_apply_args p f3arg"
201 "\\\$\[0-9]+ = 3${any}" \
202 "run a command failing in all frames except #3, -s to silently continue, quiet"
206 # Check invalid flag combinations.
207 gdb_test "frame apply all -c -s p f3arg" \
208 "frame apply all: -c and -s are mutually exclusive" \
209 "check -c and -s cannot be used simultaneously"
211 # Check some cases of missing or wrong args.
212 gdb_test "frame apply" "Missing COUNT argument." "missing COUNT"
213 gdb_test "frame apply -c" "Invalid COUNT argument." "invalid COUNT arg"
214 gdb_test "frame apply level 4-2 p 1" "inverted range" "inverted range"
215 gdb_test "frame apply level 0-3" \
216 "Please specify a command to apply on the selected frames" \