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