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