]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/data-loc.exp
gdb.dwarf2/data-loc.exp: Remove second DW_AT_upper bound in array range.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / data-loc.exp
1 # Copyright 2014 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 load_lib dwarf.exp
16
17 # This test can only be run on targets which support DWARF-2 and use gas.
18 if {![dwarf2_support]} {
19 return 0
20 }
21
22 standard_testfile data-loc.c data-loc-dw.S
23
24 # We need to know the size of integer and address types in order
25 # to write some of the debugging info we'd like to generate.
26 #
27 # For that, we ask GDB by debugging our data-loc.c program.
28 # Any program would do, but since we already have data-loc.c
29 # specifically for this testcase, might as well use that.
30
31 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
32 untested ${testfile}.exp
33 return -1
34 }
35
36 # Make some DWARF for the test.
37 set asm_file [standard_output_file $srcfile2]
38 Dwarf::assemble $asm_file {
39 cu {} {
40 DW_TAG_compile_unit {
41 {DW_AT_language @DW_LANG_Ada95}
42 {DW_AT_name foo.adb}
43 {DW_AT_comp_dir /tmp}
44 } {
45 declare_labels integer_label array_label
46
47 integer_label: DW_TAG_base_type {
48 {DW_AT_byte_size 4 DW_FORM_sdata}
49 {DW_AT_encoding @DW_ATE_signed}
50 {DW_AT_name integer}
51 }
52
53 array_label: DW_TAG_array_type {
54 {DW_AT_name foo__array_type}
55 {DW_AT_type :$integer_label}
56 {DW_AT_data_location {
57 DW_OP_push_object_address
58 DW_OP_deref
59 } SPECIAL_expr}
60 {external 1 flag}
61 } {
62 DW_TAG_subrange_type {
63 {DW_AT_type :$integer_label}
64 {DW_AT_lower_bound {
65 DW_OP_push_object_address
66 DW_OP_plus_uconst [get_sizeof "void *" 96]
67 DW_OP_deref
68 DW_OP_deref_size [get_sizeof "int" 4]
69 } SPECIAL_expr}
70 {DW_AT_upper_bound {
71 DW_OP_push_object_address
72 DW_OP_plus_uconst [get_sizeof "void *" 96]
73 DW_OP_deref
74 DW_OP_plus_uconst [get_sizeof "int" 4]
75 DW_OP_deref_size [get_sizeof "int" 4]
76 } SPECIAL_expr}
77 }
78 }
79 DW_TAG_typedef {
80 {DW_AT_name foo__array_type}
81 {DW_AT_type :$array_label}
82 }
83 DW_TAG_variable {
84 {DW_AT_name foo__three}
85 {DW_AT_type :$array_label}
86 {DW_AT_location {
87 DW_OP_addr table_1
88 } SPECIAL_expr}
89 {external 1 flag}
90 }
91 DW_TAG_variable {
92 {DW_AT_name foo__five}
93 {DW_AT_type :$array_label}
94 {DW_AT_location {
95 DW_OP_addr table_2
96 } SPECIAL_expr}
97 {external 1 flag}
98 }
99 }
100 }
101 }
102
103 # Now that we've generated the DWARF debugging info, rebuild our
104 # program using our debug info instead of the info generated by
105 # the compiler.
106
107 if { [prepare_for_testing ${testfile}.exp ${testfile} \
108 [list $srcfile $asm_file] {nodebug}] } {
109 return -1
110 }
111
112 if ![runto_main] {
113 return -1
114 }
115
116 gdb_test_no_output "set language ada"
117
118 gdb_test "print foo.three" \
119 " = \\(1, 2, 3\\)"
120
121 gdb_test "ptype foo.three" \
122 "type = array \\(1 .. 3\\) of integer"
123
124 gdb_test "print foo.three(1)" \
125 " = 1"
126
127 gdb_test "print foo.three(2)" \
128 " = 2"
129
130 gdb_test "print foo.three(3)" \
131 " = 3"
132
133 gdb_test "print foo.three'first" \
134 " = 1"
135
136 gdb_test "print foo.three'last" \
137 " = 3"
138
139 gdb_test "print foo.three'length" \
140 " = 3"
141
142 gdb_test "print foo.five" \
143 " = \\(2 => 5, 8, 13, 21, 34\\)"
144
145 gdb_test "ptype foo.five" \
146 "type = array \\(2 .. 6\\) of integer"
147
148 gdb_test "ptype foo.array_type" \
149 "type = array \\(<>\\) of integer"
150
151 gdb_test "print foo.five(2)" \
152 " = 5"
153
154 gdb_test "print foo.five(3)" \
155 " = 8"
156
157 gdb_test "print foo.five(4)" \
158 " = 13"
159
160 gdb_test "print foo.five(5)" \
161 " = 21"
162
163 gdb_test "print foo.five(6)" \
164 " = 34"
165
166 gdb_test "print foo.five'first" \
167 " = 2"
168
169 gdb_test "print foo.five'last" \
170 " = 6"
171
172 gdb_test "print foo.five'length" \
173 " = 5"
174
175 gdb_test_no_output "set lang c"
176
177 gdb_test "print foo__three" \
178 " = \\{1, 2, 3\\}"
179
180 gdb_test "ptype foo__three" \
181 "type = integer \\\[3\\\]"
182
183 gdb_test "print foo__five" \
184 " = \\{5, 8, 13, 21, 34\\}"
185
186 gdb_test "ptype foo__five" \
187 "type = integer \\\[5\\\]"
188
189 gdb_test "ptype foo__array_type" \
190 "type = integer \\\[variable length\\\]"