1 # This testcase is part of GDB
, the GNU debugger.
3 # Copyright
2018-2023 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 if {![runto setup_done
]} {
36 # Check all |
COUNT |
-COUNT | level LEVEL... with a simple command.
37 with_test_prefix
"simple command" {
38 foreach_with_prefix frame_apply_args
{
46 "level 0-0 1-1 2-2 3-3 4-4 5-5" } {
47 set cmd
"frame apply $frame_apply_args p /x 20"
50 "#0${ws}setup_done ${any}" \
51 "\\\$\[0-9]+ = 0x14${any}" \
52 "#1${ws}${any} f1 ${any}" \
53 "\\\$\[0-9]+ = 0x14${any}" \
54 "#2${ws}${any} f2 ${any}" \
55 "\\\$\[0-9]+ = 0x14${any}" \
56 "#3${ws}${any} f3 ${any}" \
57 "\\\$\[0-9]+ = 0x14${any}" \
58 "#4${ws}${any} f4 ${any}" \
59 "\\\$\[0-9]+ = 0x14${any}" \
60 "#5${ws}${any} main ${any}" \
61 "\\\$\[0-9]+ = 0x14${any}" \
63 "run a simple command on all frames"
67 # Check frame apply
on 3 innermost frames.
68 with_test_prefix
"innermost 3" {
69 foreach_with_prefix frame_apply_args
{
72 set cmd
"frame apply $frame_apply_args p /x 20"
75 "#0${ws}setup_done ${any}" \
76 "\\\$\[0-9]+ = 0x14${any}" \
77 "#1${ws}${any} f1 ${any}" \
78 "\\\$\[0-9]+ = 0x14${any}" \
79 "#2${ws}${any} f2 ${any}" \
80 "\\\$\[0-9]+ = 0x14${any}" \
82 "run a simple command on the 3 innermost frames"
86 # Check frame apply
on 3 outermost frames.
87 with_test_prefix
"outermost 3" {
88 foreach_with_prefix frame_apply_args
{
90 set cmd
"frame apply $frame_apply_args p /x 20"
93 "#3${ws}${any} f3 ${any}" \
94 "\\\$\[0-9]+ = 0x14${any}" \
95 "#4${ws}${any} f4 ${any}" \
96 "\\\$\[0-9]+ = 0x14${any}" \
97 "#5${ws}${any} main ${any}" \
98 "\\\$\[0-9]+ = 0x14${any}" \
100 "run a simple command on the 3 outermost frames"
104 # Check
-c
(continue) and
-s
(silently
continue) flags.
105 with_test_prefix
"!cont !silent flags" {
106 foreach_with_prefix frame_apply_args
{
110 set cmd
"frame apply $frame_apply_args p f3arg"
113 "#0${ws}setup_done ${any}" \
114 "No symbol \\\"f3arg\\\" in current context." \
116 "run a failing command that aborts frame apply"
120 with_test_prefix
"cont !silent flags" {
121 foreach_with_prefix frame_apply_args
{
124 set cmd
"frame apply $frame_apply_args p f3arg"
127 "#0${ws}setup_done ${any}" \
128 "No symbol \\\"f3arg\\\" in current context." \
129 "#1${ws}${any} f1 ${any}" \
130 "No symbol \\\"f3arg\\\" in current context." \
131 "#2${ws}${any} f2 ${any}" \
132 "No symbol \\\"f3arg\\\" in current context." \
133 "#3${ws}${any} f3 ${any}" \
134 "\\\$\[0-9]+ = 3${any}" \
135 "#4${ws}${any} f4 ${any}" \
136 "No symbol \\\"f3arg\\\" in current context." \
137 "#5${ws}${any} main ${any}" \
138 "No symbol \\\"f3arg\\\" in current context." \
140 "run a command failing in all frames except #3, -c to continue"
144 with_test_prefix
"!cont silent flags" {
145 foreach_with_prefix cmd_and_args
{
148 "frame apply level 0-5 -s"} {
149 set cmd
"$cmd_and_args p f3arg"
152 "#3${ws}${any} f3 ${any}" \
153 "\\\$\[0-9]+ = 3${any}" \
155 "run a command failing in all frames except #3, -s to silently continue"
160 with_test_prefix
"!quiet flag" {
161 foreach_with_prefix frame_apply_args
{
164 set cmd
"frame apply $frame_apply_args p /x 20"
167 "#0${ws}setup_done ${any}" \
168 "\\\$\[0-9]+ = 0x14${any}" \
169 "#1${ws}${any} f1 ${any}" \
170 "\\\$\[0-9]+ = 0x14${any}" \
172 "run a command, printing location"
176 with_test_prefix
"quiet flag" {
177 foreach_with_prefix frame_apply_args
{
180 set cmd
"frame apply $frame_apply_args p /x 20"
183 "\\\$\[0-9]+ = 0x14${any}" \
184 "\\\$\[0-9]+ = 0x14${any}" \
186 "run a command with -q quiet flag, printing only command results"
190 # Check multiple flags together.
191 with_test_prefix
"quiet silent flags" {
192 foreach_with_prefix frame_apply_args
{
194 "level 0-5 -q -s -q"} {
195 set cmd
"frame apply $frame_apply_args p f3arg"
197 "\\\$\[0-9]+ = 3${any}" \
198 "run a command failing in all frames except #3, -s to silently continue, quiet"
202 # Check invalid flag combinations.
203 gdb_test
"frame apply all -c -s p f3arg" \
204 "frame apply all: -c and -s are mutually exclusive" \
205 "check -c and -s cannot be used simultaneously"
207 # Check some cases of missing or wrong
args.
208 gdb_test
"frame apply" "Missing COUNT argument." "missing COUNT"
209 gdb_test
"frame apply -c" "Invalid COUNT argument." "invalid COUNT arg"
210 gdb_test
"frame apply level 4-2 p 1" "inverted range" "inverted range"
211 gdb_test
"frame apply level 0-3" \
212 "Please specify a command to apply on the selected frames" \
214 gdb_test
"faas" "Please specify a command to apply on all frames" \
215 "missing command for faas"