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