[gdb/testsuite] Split up multi-exec test-cases
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / frameapply.exp
CommitLineData
3606ccab
PW
1# This testcase is part of GDB, the GNU debugger.
2
b811d2c2 3# Copyright 2018-2020 Free Software Foundation, Inc.
3606ccab
PW
4
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.
9#
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.
14#
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/>.
17
18
19# Test 'frame apply [all | COUNT | -COUNT | level LEVEL...] [FLAG]... COMMAND'.
20
21standard_testfile
22
23if { [prepare_for_testing "failed to prepare" ${testfile}] } {
24 return -1
25}
26
27clean_restart ${binfile}
28
29
30if ![runto setup_done] then {
31 fail "can't run to setup_done"
32 return 0
33}
34
35set any "\[^\r\n\]*"
36set ws "\[ \t\]\+"
37set number "\[0-9]\+"
38
39
40# Check all | COUNT | -COUNT | level LEVEL... with a simple command.
41with_test_prefix "simple command" {
42 foreach_with_prefix frame_apply_args {
43 "all"
44 "6"
45 "-6"
46 "level 0-5"
47 "level 0-3 4-5"
48 "level 0 1-2 3-5"
49 "level 0 1 2 3 4 5"
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"
52 gdb_test $cmd \
53 [multi_line \
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}" \
66 ] \
67 "run a simple command on all frames"
68 }
69}
70
71# Check frame apply on 3 innermost frames.
72with_test_prefix "innermost 3" {
73 foreach_with_prefix frame_apply_args {
74 "3"
75 "level 0-2" } {
76 set cmd "frame apply $frame_apply_args p /x 20"
77 gdb_test $cmd \
78 [multi_line \
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}" \
85 ] \
86 "run a simple command on the 3 innermost frames"
87 }
88}
89
90# Check frame apply on 3 outermost frames.
91with_test_prefix "outermost 3" {
92 foreach_with_prefix frame_apply_args {
93 "-3" } {
94 set cmd "frame apply $frame_apply_args p /x 20"
95 gdb_test $cmd \
96 [multi_line \
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}" \
103 ] \
104 "run a simple command on the 3 outermost frames"
105 }
106}
107
108# Check -c (continue) and -s (silently continue) flags.
109with_test_prefix "!cont !silent flags" {
110 foreach_with_prefix frame_apply_args {
111 "all"
112 "level 0-5"
113 } {
114 set cmd "frame apply $frame_apply_args p f3arg"
115 gdb_test $cmd \
116 [multi_line \
117 "#0${ws}setup_done ${any}" \
118 "No symbol \\\"f3arg\\\" in current context." \
119 ] \
120 "run a failing command that aborts frame apply"
121 }
122}
123
124with_test_prefix "cont !silent flags" {
125 foreach_with_prefix frame_apply_args {
126 "all -c"
127 "level 0-5 -c"} {
128 set cmd "frame apply $frame_apply_args p f3arg"
129 gdb_test $cmd \
130 [multi_line \
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." \
143 ] \
144 "run a command failing in all frames except #3, -c to continue"
145 }
146}
147
148with_test_prefix "!cont silent flags" {
149 foreach_with_prefix cmd_and_args {
150 "frame apply all -s"
151 "faas"
152 "frame apply level 0-5 -s"} {
153 set cmd "$cmd_and_args p f3arg"
154 gdb_test $cmd \
155 [multi_line \
156 "#3${ws}${any} f3 ${any}" \
157 "\\\$\[0-9]+ = 3${any}" \
158 ] \
159 "run a command failing in all frames except #3, -s to silently continue"
160 }
161}
162
163# Check quietness.
164with_test_prefix "!quiet flag" {
165 foreach_with_prefix frame_apply_args {
166 "2"
167 "level 0-1"} {
168 set cmd "frame apply $frame_apply_args p /x 20"
169 gdb_test $cmd \
170 [multi_line \
171 "#0${ws}setup_done ${any}" \
172 "\\\$\[0-9]+ = 0x14${any}" \
173 "#1${ws}${any} f1 ${any}" \
174 "\\\$\[0-9]+ = 0x14${any}" \
175 ] \
176 "run a command, printing location"
177 }
178}
179
180with_test_prefix "quiet flag" {
181 foreach_with_prefix frame_apply_args {
182 "2 -q"
183 "level 0-1 -q"} {
184 set cmd "frame apply $frame_apply_args p /x 20"
185 gdb_test $cmd \
186 [multi_line \
187 "\\\$\[0-9]+ = 0x14${any}" \
188 "\\\$\[0-9]+ = 0x14${any}" \
189 ] \
190 "run a command with -q quiet flag, printing only command results"
191 }
192}
193
194# Check multiple flags together.
195with_test_prefix "quiet silent flags" {
196 foreach_with_prefix frame_apply_args {
197 "all -q -s -q"
198 "level 0-5 -q -s -q"} {
199 set cmd "frame apply $frame_apply_args p f3arg"
200 gdb_test $cmd \
201 "\\\$\[0-9]+ = 3${any}" \
202 "run a command failing in all frames except #3, -s to silently continue, quiet"
203 }
204}
205
206# Check invalid flag combinations.
207gdb_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"
210
211# Check some cases of missing or wrong args.
212gdb_test "frame apply" "Missing COUNT argument." "missing COUNT"
213gdb_test "frame apply -c" "Invalid COUNT argument." "invalid COUNT arg"
214gdb_test "frame apply level 4-2 p 1" "inverted range" "inverted range"
215gdb_test "frame apply level 0-3" \
216 "Please specify a command to apply on the selected frames" \
217 "missing command"
e0fad1ea
PW
218gdb_test "faas" "Please specify a command to apply on all frames" \
219 "missing command for faas"
This page took 0.308977 seconds and 4 git commands to generate.