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