]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-vla-fortran.exp
Eliminate spurious returns from the test suite
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-vla-fortran.exp
CommitLineData
213516ef 1# Copyright 2015-2023 Free Software Foundation, Inc.
3f2f83dd
KB
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
0bf21fbd
GB
16# Verify that, using the MI, we can evaluate a simple Fortran Variable
17# Length Array (VLA).
18
57b7402d 19require allow_fortran_tests
3f2f83dd
KB
20
21load_lib mi-support.exp
9e9af4be 22load_lib fortran.exp
3f2f83dd
KB
23set MIFLAGS "-i=mi"
24
25gdb_exit
26if [mi_gdb_start] {
cdd42066 27 return
3f2f83dd
KB
28}
29
30standard_testfile vla.f90
31
32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
33 {debug f90}] != "" } {
5b362f04 34 untested "failed to compile"
3f2f83dd
KB
35 return -1
36}
37
9e9af4be
BH
38# Depending on the compiler being used,
39# the type names can be printed differently.
40set real [fortran_real4]
41
3f2f83dd
KB
42mi_delete_breakpoints
43mi_gdb_reinitialize_dir $srcdir/$subdir
44mi_gdb_load ${binfile}
45
46set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
5d2cbaa5
AB
47mi_create_breakpoint "-t vla.f90:$bp_lineno" \
48 "insert breakpoint at line $bp_lineno (vla not allocated)" \
49 -number 1 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
50mi_run_cmd
51mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
52 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
53mi_gdb_test "500-data-evaluate-expression vla1" \
5bd68487 54 "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, before allocation"
3f2f83dd 55
584a927c 56mi_create_varobj_checked vla1_not_allocated vla1 "$real, allocatable \\(:\\)" \
3f2f83dd
KB
57 "create local variable vla1_not_allocated"
58mi_gdb_test "501-var-info-type vla1_not_allocated" \
584a927c 59 "501\\^done,type=\"$real, allocatable \\(:\\)\"" \
3f2f83dd
KB
60 "info type variable vla1_not_allocated"
61mi_gdb_test "502-var-show-format vla1_not_allocated" \
62 "502\\^done,format=\"natural\"" \
63 "show format variable vla1_not_allocated"
64mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
65 "503\\^done,value=\"\\\[0\\\]\"" \
66 "eval variable vla1_not_allocated"
67mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
9e9af4be 68 "$real" "get children of vla1_not_allocated"
3f2f83dd
KB
69
70
71
72set bp_lineno [gdb_get_line_number "vla1-allocated"]
5d2cbaa5
AB
73mi_create_breakpoint "-t vla.f90:$bp_lineno" \
74 "insert breakpoint at line $bp_lineno (vla allocated)" \
75 -number 2 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
76mi_run_cmd
77mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
78 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
79mi_gdb_test "510-data-evaluate-expression vla1" \
6f2f1a3a 80 "510\\^done,value=\"\\(.*\\)\"" "evaluate allocated vla"
3f2f83dd 81
bc68014d 82mi_create_varobj_checked vla1_allocated vla1 "$real, allocatable \\\(5\\\)" \
3f2f83dd
KB
83 "create local variable vla1_allocated"
84mi_gdb_test "511-var-info-type vla1_allocated" \
bc68014d 85 "511\\^done,type=\"$real, allocatable \\\(5\\\)\"" \
3f2f83dd
KB
86 "info type variable vla1_allocated"
87mi_gdb_test "512-var-show-format vla1_allocated" \
88 "512\\^done,format=\"natural\"" \
89 "show format variable vla1_allocated"
90mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
91 "513\\^done,value=\"\\\[5\\\]\"" \
92 "eval variable vla1_allocated"
93mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
9e9af4be 94 "$real" "get children of vla1_allocated"
3f2f83dd
KB
95
96
97set bp_lineno [gdb_get_line_number "vla1-filled"]
5d2cbaa5
AB
98mi_create_breakpoint "-t vla.f90:$bp_lineno" \
99 "insert breakpoint at line $bp_lineno" \
100 -number 3 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
101mi_run_cmd
102mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
103 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
104mi_gdb_test "520-data-evaluate-expression vla1" \
5bd68487 105 "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla, filled all 1s"
3f2f83dd
KB
106
107
108set bp_lineno [gdb_get_line_number "vla1-modified"]
5d2cbaa5
AB
109mi_create_breakpoint "-t vla.f90:$bp_lineno" \
110 "insert breakpoint at line $bp_lineno" \
111 -number 4 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
112mi_run_cmd
113mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
114 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
115mi_gdb_test "530-data-evaluate-expression vla1" \
5bd68487 116 "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla, contents modified"
3f2f83dd 117mi_gdb_test "540-data-evaluate-expression vla1(1)" \
5bd68487 118 "540\\^done,value=\"1\"" "evaluate filled vla(1)"
3f2f83dd 119mi_gdb_test "550-data-evaluate-expression vla1(2)" \
5bd68487 120 "550\\^done,value=\"42\"" "evaluate filled vla(2)"
3f2f83dd 121mi_gdb_test "560-data-evaluate-expression vla1(4)" \
5bd68487 122 "560\\^done,value=\"24\"" "evaluate filled vla(4)"
3f2f83dd
KB
123
124
125set bp_lineno [gdb_get_line_number "vla1-deallocated"]
5d2cbaa5
AB
126mi_create_breakpoint "-t vla.f90:$bp_lineno" \
127 "insert breakpoint at line $bp_lineno" \
128 -number 5 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
129mi_run_cmd
130mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
131 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
132mi_gdb_test "570-data-evaluate-expression vla1" \
5bd68487 133 "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, after deallocation"
3f2f83dd
KB
134
135
136set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
b4365d02
AB
137mi_create_breakpoint "-t vla.f90:$bp_lineno" \
138 "insert breakpoint at line $bp_lineno" \
139 -number 6 -disp "del" -func "vla" ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
140mi_run_cmd
141mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
142 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
3f2f83dd
KB
143
144
37a8db1a
AB
145set test "evaluate not associated vla"
146send_gdb "580-data-evaluate-expression pvla2\n"
147gdb_expect {
148 -re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
149 pass $test
150
584a927c 151 mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
37a8db1a
AB
152 "create local variable pvla2_not_associated"
153 mi_gdb_test "581-var-info-type pvla2_not_associated" \
584a927c 154 "581\\^done,type=\"$real \\(:,:\\)\"" \
37a8db1a
AB
155 "info type variable pvla2_not_associated"
156 mi_gdb_test "582-var-show-format pvla2_not_associated" \
157 "582\\^done,format=\"natural\"" \
158 "show format variable pvla2_not_associated"
159 mi_gdb_test "583-var-evaluate-expression pvla2_not_associated" \
160 "583\\^done,value=\"\\\[0\\\]\"" \
161 "eval variable pvla2_not_associated"
162 mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
9e9af4be 163 "$real" "get children of pvla2_not_associated"
37a8db1a
AB
164 }
165 -re "580\\^error,msg=\"value contents too large \\(\[0-9\]+ bytes\\).*${mi_gdb_prompt}$" {
166 # Undefined behaviour in gfortran.
167 xfail $test
168 }
169 -re "${mi_gdb_prompt}$" {
170 fail $test
171 }
172 timeout {
173 fail "$test (timeout)"
174 }
175}
176
3f2f83dd 177set bp_lineno [gdb_get_line_number "pvla2-associated"]
5d2cbaa5
AB
178mi_create_breakpoint "-t vla.f90:$bp_lineno" \
179 "insert breakpoint at line $bp_lineno" \
180 -number 7 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
181mi_run_cmd
182mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
183 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
184mi_gdb_test "590-data-evaluate-expression pvla2" \
c8d5abea 185 "590\\^done,value=\"\\(\\(2, 2, 2, 2, 2\\) \\(2, 2, 2, 2, 2\\)\\)\"" \
3f2f83dd
KB
186 "evaluate associated vla"
187
188mi_create_varobj_checked pvla2_associated pvla2 \
9e9af4be 189 "$real \\\(5,2\\\)" "create local variable pvla2_associated"
3f2f83dd 190mi_gdb_test "591-var-info-type pvla2_associated" \
9e9af4be 191 "591\\^done,type=\"$real \\\(5,2\\\)\"" \
3f2f83dd
KB
192 "info type variable pvla2_associated"
193mi_gdb_test "592-var-show-format pvla2_associated" \
194 "592\\^done,format=\"natural\"" \
195 "show format variable pvla2_associated"
196mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
197 "593\\^done,value=\"\\\[2\\\]\"" \
198 "eval variable pvla2_associated"
199
200
201set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
5d2cbaa5
AB
202mi_create_breakpoint "-t vla.f90:$bp_lineno" \
203 "insert breakpoint at line $bp_lineno" \
204 -number 8 -disp del -func vla ".*vla.f90" $bp_lineno $hex
3f2f83dd
KB
205mi_run_cmd
206mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
207 { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
208mi_gdb_test "600-data-evaluate-expression pvla2" \
209 "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
210
211mi_gdb_exit