]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/arr-stride.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / arr-stride.exp
1 # Copyright 2014-2024 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 require dwarf2_support
19
20 standard_testfile main.c -dw.S
21
22 # Make some DWARF for the test.
23 set asm_file [standard_output_file $srcfile2]
24 Dwarf::assemble $asm_file {
25 cu {} {
26 DW_TAG_compile_unit {
27 {DW_AT_language @DW_LANG_Ada95}
28 {DW_AT_name foo.adb}
29 {DW_AT_comp_dir /tmp}
30 } {
31 declare_labels integer_label array_elt_label array_label \
32 big_array_label struct_label
33
34 integer_label: DW_TAG_base_type {
35 {DW_AT_byte_size 4 DW_FORM_sdata}
36 {DW_AT_encoding @DW_ATE_signed}
37 {DW_AT_name integer}
38 }
39
40 array_elt_label: DW_TAG_subrange_type {
41 {DW_AT_lower_bound 0xe0 DW_FORM_data1}
42 {DW_AT_upper_bound 0x1f DW_FORM_data1}
43 {DW_AT_name pck__item}
44 {DW_AT_type :$integer_label}
45 }
46
47 DW_TAG_typedef {
48 {DW_AT_name pck__table}
49 {DW_AT_type :$array_label}
50 }
51
52 array_label: DW_TAG_array_type {
53 {DW_AT_name pck__table}
54 {DW_AT_bit_stride 6 DW_FORM_data1}
55 {DW_AT_type :$array_elt_label}
56 } {
57 DW_TAG_subrange_type {
58 {DW_AT_type :$integer_label}
59 {DW_AT_lower_bound 0 DW_FORM_data1}
60 {DW_AT_upper_bound 4 DW_FORM_data1}
61 }
62 }
63
64 DW_TAG_typedef {
65 {DW_AT_name pck__big_table}
66 {DW_AT_type :$big_array_label}
67 }
68
69 big_array_label: DW_TAG_array_type {
70 {DW_AT_name pck__big_table}
71 {DW_AT_byte_stride 1 DW_FORM_data1}
72 {DW_AT_type :$array_elt_label}
73 } {
74 DW_TAG_subrange_type {
75 {DW_AT_type :$integer_label}
76 {DW_AT_lower_bound 0 DW_FORM_data1}
77 {DW_AT_upper_bound 4 DW_FORM_data1}
78 }
79 }
80
81 struct_label: DW_TAG_structure_type {
82 {name struct_type}
83 {byte_size 16 DW_FORM_sdata}
84 } {
85 member {
86 {name intfield}
87 {type :$integer_label}
88 {data_member_location 0 DW_FORM_sdata}
89 }
90 member {
91 {name arrayfield}
92 {type :$array_label}
93 {data_member_location 4 DW_FORM_sdata}
94 }
95 }
96
97 DW_TAG_variable {
98 {name the_struct}
99 {external 1 DW_FORM_flag}
100 {location {
101 DW_OP_const1u 1
102 DW_OP_stack_value
103 DW_OP_piece 4
104 DW_OP_piece 12
105 } SPECIAL_expr}
106 {type :$struct_label}
107 }
108 }
109 }
110 }
111
112 if { [prepare_for_testing "failed to prepare" ${testfile} \
113 [list $srcfile $asm_file] {nodebug}] } {
114 return -1
115 }
116
117 gdb_test_no_output "set language ada"
118
119 gdb_test "ptype pck.table" \
120 "type = array \\(0 \\.\\. 4\\) of pck\\.item <packed: 6-bit elements>"
121
122 gdb_test "ptype pck.big_table" \
123 "type = array \\(0 \\.\\. 4\\) of pck\\.item <packed: 8-bit elements>"
124
125 gdb_test "print the_struct" \
126 "\\(intfield => 1, arrayfield => \\(0 => <optimized out>\\)\\)"