fort_dyn_array: add basic fortran dyn array support
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / vla-value.exp
CommitLineData
3f2f83dd
KB
1# Copyright 2015 Free Software Foundation, Inc.
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
16standard_testfile "vla.f90"
17
18if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
19 {debug f90 quiet}] } {
20 return -1
21}
22
23if ![runto_main] {
24 untested "could not run to main"
25 return -1
26}
27
28# Try to access values in non allocated VLA
29gdb_breakpoint [gdb_get_line_number "vla1-init"]
30gdb_continue_to_breakpoint "vla1-init"
31gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
32gdb_test "print &vla1" \
33 " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
34 "print non-allocated &vla1"
35gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
36 "print member in non-allocated vla1 (1)"
37gdb_test "print vla1(101,202,303)" \
38 "no such vector element \\\(vector not allocated\\\)" \
39 "print member in non-allocated vla1 (2)"
40gdb_test "print vla1(5,2,18)=1" "no such vector element \\\(vector not allocated\\\)" \
41 "set member in non-allocated vla1"
42
43# Try to access value in allocated VLA
44gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
45gdb_continue_to_breakpoint "vla2-allocated"
46gdb_test "next" "\\d+(\\t|\\s)+vla1\\\(3, 6, 9\\\) = 42" \
47 "step over value assignment of vla1"
48gdb_test "print &vla1" \
49 " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
50 "print allocated &vla1"
51gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
52gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
53gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
54 "print allocated vla1(9,9,9)=1"
55
56# Try to access values in allocated VLA after specific assignment
57gdb_breakpoint [gdb_get_line_number "vla1-filled"]
58gdb_continue_to_breakpoint "vla1-filled"
59gdb_test "print vla1(3, 6, 9)" " = 42" \
60 "print allocated vla1(3,6,9) after specific assignment (filled)"
61gdb_test "print vla1(1, 3, 8)" " = 1001" \
62 "print allocated vla1(1,3,8) after specific assignment (filled)"
63gdb_test "print vla1(9, 9, 9)" " = 999" \
64 "print allocated vla1(9,9,9) after assignment in debugger (filled)"
65
66# Try to access values in undefined pointer to VLA (dangling)
67gdb_test "print pvla" " = <not associated>" "print undefined pvla"
68gdb_test "print &pvla" \
69 " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
70 "print non-associated &pvla"
71gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
72 "print undefined pvla(1,3,8)"
73
74# Try to access values in pointer to VLA and compare them
75gdb_breakpoint [gdb_get_line_number "pvla-associated"]
76gdb_continue_to_breakpoint "pvla-associated"
77gdb_test "print &pvla" \
78 " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
79 "print associated &pvla"
80gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
81gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
82gdb_test "print pvla(9, 9, 9)" " = 999" "print associated pvla(9,9,9)"
83
84# Fill values to VLA using pointer and check
85gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
86gdb_continue_to_breakpoint "pvla-re-associated"
87gdb_test "print pvla(5, 45, 20)" \
88 " = 1" "print pvla(5, 45, 20) after filled using pointer"
89gdb_test "print vla2(5, 45, 20)" \
90 " = 1" "print vla2(5, 45, 20) after filled using pointer"
91gdb_test "print pvla(7, 45, 14)" " = 2" \
92 "print pvla(7, 45, 14) after filled using pointer"
93gdb_test "print vla2(7, 45, 14)" " = 2" \
94 "print vla2(7, 45, 14) after filled using pointer"
95
96# Try to access values of deassociated VLA pointer
97gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
98gdb_continue_to_breakpoint "pvla-deassociated"
99gdb_test "print pvla(5, 45, 20)" \
100 "no such vector element \\\(vector not associated\\\)" \
101 "print pvla(5, 45, 20) after deassociated"
102gdb_test "print pvla(7, 45, 14)" \
103 "no such vector element \\\(vector not associated\\\)" \
104 "print pvla(7, 45, 14) after dissasociated"
105gdb_test "print pvla" " = <not associated>" \
106 "print vla1 after deassociated"
107
108# Try to access values of deallocated VLA
109gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
110gdb_continue_to_breakpoint "vla1-deallocated"
111gdb_test "print vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
112 "print allocated vla1(3,6,9) after specific assignment (deallocated)"
113gdb_test "print vla1(1, 3, 8)" "no such vector element \\\(vector not allocated\\\)" \
114 "print allocated vla1(1,3,8) after specific assignment (deallocated)"
115gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\\\)" \
116 "print allocated vla1(9,9,9) after assignment in debugger (deallocated)"
117
118
119# Try to assign VLA to user variable
120clean_restart ${testfile}
121
122if ![runto MAIN__] then {
123 perror "couldn't run to breakpoint MAIN__"
124 continue
125}
126gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
127gdb_continue_to_breakpoint "vla2-allocated"
128gdb_test "next" "\\d+.*vla1\\(3, 6, 9\\) = 42" "next (1)"
129
130gdb_test_no_output "set \$myvar = vla1" "set \$myvar = vla1"
131gdb_test "print \$myvar" \
132 " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
133 "print \$myvar set to vla1"
134
135gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
136gdb_test "print \$myvar(3,6,9)" " = 1311" "print \$myvar(3,6,9)"
137
138gdb_breakpoint [gdb_get_line_number "pvla-associated"]
139gdb_continue_to_breakpoint "pvla-associated"
140gdb_test_no_output "set \$mypvar = pvla" "set \$mypvar = pvla"
141gdb_test "print \$mypvar(1,3,8)" " = 1001" "print \$mypvar(1,3,8)"
142
143# deallocate pointer and make sure user defined variable still has the
144# right value.
145gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
146gdb_continue_to_breakpoint "pvla-deassociated"
147gdb_test "print \$mypvar(1,3,8)" " = 1001" \
148 "print \$mypvar(1,3,8) after deallocated"
This page took 0.028203 seconds and 4 git commands to generate.