1 # Copyright
2014-2022 Free Software Foundation
, Inc.
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.
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.
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
/>.
17 # This test can only be run
on targets which support DWARF
-2 and use gas.
18 if {![dwarf2_support
]} {
22 standard_testfile .c
-dw.S
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.
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.
31 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
35 # Make some DWARF for the test.
36 set asm_file [standard_output_file $srcfile2]
37 Dwarf::assemble $asm_file {
40 {DW_AT_language @DW_LANG_Ada95}
44 declare_labels integer_label array_label array_ptr_label
45 set int_size [get_sizeof "int" 4]
46 set voidp_size [get_sizeof "void *" 96]
48 integer_label: DW_TAG_base_type {
49 {DW_AT_byte_size $int_size DW_FORM_sdata}
50 {DW_AT_encoding @DW_ATE_signed}
54 array_label: DW_TAG_array_type {
55 {DW_AT_name foo__array_type}
56 {DW_AT_type :$integer_label}
57 {DW_AT_data_location {
58 DW_OP_push_object_address
63 DW_TAG_subrange_type {
64 {DW_AT_type :$integer_label}
66 DW_OP_push_object_address
67 DW_OP_plus_uconst $voidp_size
69 DW_OP_deref_size $int_size
72 DW_OP_push_object_address
73 DW_OP_plus_uconst $voidp_size
75 DW_OP_plus_uconst $int_size
76 DW_OP_deref_size $int_size
80 array_ptr_label: DW_TAG_typedef {
81 {DW_AT_name foo__array_type}
82 {DW_AT_type :$array_label}
85 {DW_AT_name foo__three}
86 {DW_AT_type :$array_label}
88 DW_OP_addr [gdb_target_symbol table_1]
93 {DW_AT_name foo__three_tdef}
94 {DW_AT_type :$array_ptr_label}
96 DW_OP_addr [gdb_target_symbol table_1]
101 {DW_AT_name foo__five}
102 {DW_AT_type :$array_label}
104 DW_OP_addr [gdb_target_symbol table_2]
109 {DW_AT_name foo__five_tdef}
110 {DW_AT_type :$array_ptr_label}
112 DW_OP_addr [gdb_target_symbol table_2]
120 # Now that we've generated the DWARF debugging
info, rebuild our
121 #
program using our debug
info instead of the
info generated by
124 if { [prepare_for_testing
"failed to prepare" ${testfile} \
125 [list $srcfile $asm_file
] {nodebug
}] } {
133 gdb_test_no_output
"set language ada"
137 gdb_test
"print foo.three" \
140 gdb_test
"ptype foo.three" \
141 "type = array \\(<>\\) of integer"
143 gdb_test
"print foo.three(1)" \
146 gdb_test
"print foo.three(2)" \
149 gdb_test
"print foo.three(3)" \
152 gdb_test
"print foo.three'first" \
155 gdb_test
"print foo.three'last" \
158 gdb_test
"print foo.three'length" \
163 gdb_test
"print foo.three_tdef.all" \
166 gdb_test
"ptype foo.three_tdef" \
167 "type = access array \\(<>\\) of integer"
169 gdb_test
"print foo.three_tdef(1)" \
172 gdb_test
"print foo.three_tdef(2)" \
175 gdb_test
"print foo.three_tdef(3)" \
178 gdb_test
"print foo.three_tdef'first" \
181 gdb_test
"print foo.three_tdef'last" \
184 gdb_test
"print foo.three_tdef'length" \
187 gdb_test
"print foo.five" \
188 " = \\(2 => 5, 8, 13, 21, 34\\)"
190 gdb_test
"ptype foo.five" \
191 "type = array \\(<>\\) of integer"
193 gdb_test
"ptype foo.array_type" \
194 "type = array \\(<>\\) of integer"
198 gdb_test
"print foo.five(2)" \
201 gdb_test
"print foo.five(3)" \
204 gdb_test
"print foo.five(4)" \
207 gdb_test
"print foo.five(5)" \
210 gdb_test
"print foo.five(6)" \
213 gdb_test
"print foo.five'first" \
216 gdb_test
"print foo.five'last" \
219 gdb_test
"print foo.five'length" \
224 gdb_test
"print foo.five_tdef.all" \
225 " = \\(2 => 5, 8, 13, 21, 34\\)"
227 gdb_test
"ptype foo.five_tdef" \
228 "type = access array \\(<>\\) of integer"
230 gdb_test
"print foo.five_tdef(2)" \
233 gdb_test
"print foo.five_tdef(3)" \
236 gdb_test
"print foo.five_tdef(4)" \
239 gdb_test
"print foo.five_tdef(5)" \
242 gdb_test
"print foo.five_tdef(6)" \
245 gdb_test
"print foo.five_tdef'first" \
248 gdb_test
"print foo.five_tdef'last" \
251 gdb_test
"print foo.five_tdef'length" \