Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2020-2021 Free Software Foundation, Inc. |
20a5fcbd TT |
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 | # Test support for non-byte-sized integer base types. | |
17 | ||
18 | load_lib dwarf.exp | |
19 | ||
20 | # This test can only be run on targets which support DWARF-2 and use gas. | |
21 | if {![dwarf2_support]} { | |
22 | return 0 | |
23 | } | |
24 | ||
25 | standard_testfile .c .S | |
26 | ||
27 | set executable ${testfile} | |
28 | set asm_file [standard_output_file ${srcfile2}] | |
29 | ||
30 | if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | # Create the DWARF. | |
35 | Dwarf::assemble ${asm_file} { | |
36 | cu {} { | |
37 | DW_TAG_compile_unit { | |
38 | {DW_AT_language @DW_LANG_C_plus_plus} | |
39 | } { | |
40 | declare_labels i7_type u1_type u17_type u31_type \ | |
41 | u31_1_type u32_0_type u0_0_type be30_1_type | |
42 | ||
43 | i7_type: DW_TAG_base_type { | |
44 | {DW_AT_encoding @DW_ATE_signed} | |
45 | {DW_AT_endianity @DW_END_little} | |
46 | {DW_AT_name "i7"} | |
47 | {DW_AT_byte_size 2 DW_FORM_udata} | |
48 | {DW_AT_bit_size 7 DW_FORM_udata} | |
49 | } | |
50 | ||
51 | DW_TAG_variable { | |
52 | {DW_AT_name "v_i16_m1"} | |
53 | {DW_AT_type :${i7_type}} | |
54 | {DW_AT_external 1 DW_FORM_flag} | |
55 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "i16_m1"]} | |
56 | SPECIAL_expr} | |
57 | } | |
58 | ||
59 | u1_type: DW_TAG_base_type { | |
60 | {DW_AT_encoding @DW_ATE_boolean} | |
61 | {DW_AT_endianity @DW_END_little} | |
62 | {DW_AT_name "u1"} | |
63 | {DW_AT_byte_size 2 DW_FORM_udata} | |
64 | {DW_AT_bit_size 1 DW_FORM_udata} | |
65 | {DW_AT_data_bit_offset 2 DW_FORM_udata} | |
66 | } | |
67 | ||
68 | DW_TAG_variable { | |
69 | {DW_AT_name "v_u16_1"} | |
70 | {DW_AT_type :${u1_type}} | |
71 | {DW_AT_external 1 DW_FORM_flag} | |
72 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u16_1"]} | |
73 | SPECIAL_expr} | |
74 | } | |
75 | ||
76 | u17_type: DW_TAG_base_type { | |
77 | {DW_AT_encoding @DW_ATE_signed} | |
78 | {DW_AT_endianity @DW_END_little} | |
79 | {DW_AT_name "u17"} | |
80 | {DW_AT_byte_size 4 DW_FORM_udata} | |
81 | {DW_AT_bit_size 17 DW_FORM_udata} | |
82 | } | |
83 | ||
84 | DW_TAG_variable { | |
85 | {DW_AT_name "v_u32_m2"} | |
86 | {DW_AT_type :${u17_type}} | |
87 | {DW_AT_external 1 DW_FORM_flag} | |
88 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_m2"]} | |
89 | SPECIAL_expr} | |
90 | } | |
91 | ||
92 | u31_type: DW_TAG_base_type { | |
93 | {DW_AT_encoding @DW_ATE_unsigned} | |
94 | {DW_AT_endianity @DW_END_little} | |
95 | {DW_AT_name "u31"} | |
96 | {DW_AT_byte_size 4 DW_FORM_udata} | |
97 | {DW_AT_bit_size 31 DW_FORM_udata} | |
98 | } | |
99 | ||
100 | DW_TAG_variable { | |
101 | {DW_AT_name "v_u32_1"} | |
102 | {DW_AT_type :${u31_type}} | |
103 | {DW_AT_external 1 DW_FORM_flag} | |
104 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1"]} | |
105 | SPECIAL_expr} | |
106 | } | |
107 | ||
108 | u31_1_type: DW_TAG_base_type { | |
109 | {DW_AT_encoding @DW_ATE_unsigned} | |
110 | {DW_AT_endianity @DW_END_little} | |
111 | {DW_AT_name "u31_1"} | |
112 | {DW_AT_byte_size 4 DW_FORM_udata} | |
113 | {DW_AT_bit_size 31 DW_FORM_udata} | |
114 | {DW_AT_data_bit_offset 1 DW_FORM_udata} | |
115 | } | |
116 | ||
117 | DW_TAG_variable { | |
118 | {DW_AT_name "v_u32_1_off"} | |
119 | {DW_AT_type :${u31_1_type}} | |
120 | {DW_AT_external 1 DW_FORM_flag} | |
121 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1_off"]} | |
122 | SPECIAL_expr} | |
123 | } | |
124 | ||
125 | be30_1_type: DW_TAG_base_type { | |
126 | {DW_AT_encoding @DW_ATE_unsigned} | |
127 | {DW_AT_endianity @DW_END_big} | |
128 | {DW_AT_name "be30_1"} | |
129 | {DW_AT_byte_size 4 DW_FORM_udata} | |
130 | {DW_AT_bit_size 30 DW_FORM_udata} | |
131 | {DW_AT_data_bit_offset 1 DW_FORM_udata} | |
132 | } | |
133 | ||
134 | DW_TAG_variable { | |
135 | {DW_AT_name "v_be30_1_off"} | |
136 | {DW_AT_type :${be30_1_type}} | |
137 | {DW_AT_external 1 DW_FORM_flag} | |
138 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "be30_1_off"]} | |
139 | SPECIAL_expr} | |
140 | } | |
141 | ||
142 | u32_0_type: DW_TAG_base_type { | |
143 | {DW_AT_encoding @DW_ATE_unsigned} | |
144 | {DW_AT_endianity @DW_END_little} | |
145 | {DW_AT_name "u32_0"} | |
146 | {DW_AT_byte_size 4 DW_FORM_udata} | |
147 | {DW_AT_bit_size 0 DW_FORM_udata} | |
148 | } | |
149 | ||
150 | DW_TAG_variable { | |
151 | {DW_AT_name "v_u32_0"} | |
152 | {DW_AT_type :${u32_0_type}} | |
153 | {DW_AT_external 1 DW_FORM_flag} | |
154 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]} | |
155 | SPECIAL_expr} | |
156 | } | |
157 | ||
158 | u0_0_type: DW_TAG_base_type { | |
159 | {DW_AT_encoding @DW_ATE_unsigned} | |
160 | {DW_AT_endianity @DW_END_little} | |
161 | {DW_AT_name "u0_0"} | |
162 | {DW_AT_byte_size 0 DW_FORM_udata} | |
163 | } | |
164 | ||
165 | DW_TAG_variable { | |
166 | {DW_AT_name "v_u0_0"} | |
167 | {DW_AT_type :${u0_0_type}} | |
168 | {DW_AT_external 1 DW_FORM_flag} | |
169 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]} | |
170 | SPECIAL_expr} | |
171 | } | |
172 | } | |
173 | } | |
174 | } | |
175 | ||
176 | if {[prepare_for_testing "failed to prepare" ${executable} \ | |
177 | [list ${asm_file} ${srcfile}] {}]} { | |
178 | return -1 | |
179 | } | |
180 | ||
181 | if {![runto_main]} { | |
182 | return -1 | |
183 | } | |
184 | ||
185 | gdb_test "print v_i16_m1" "= -1" | |
186 | gdb_test "print v_u16_1" "= true" | |
187 | gdb_test "print v_u32_m2" "= -2" | |
188 | gdb_test "print v_u32_1" "= 1" | |
189 | gdb_test "print v_u32_0" "= 0" | |
190 | gdb_test "print v_u0_0" "= 0" | |
191 | ||
192 | gdb_test "print v_i16_m1 = 7" "= 7" | |
193 | gdb_test "print v_i16_m1" "= 7" "print v_i16_m1 after assignment" | |
194 | ||
195 | gdb_test "print v_u32_1_off" "= 1" | |
196 | gdb_test "print v_u32_1_off = 7" " = 7" | |
197 | gdb_test "x/4xb &v_u32_1_off" ":\t0x0e\t0x00\t0x00\t0x00" | |
198 | ||
199 | gdb_test "print v_be30_1_off" "= 1" | |
200 | gdb_test "print v_be30_1_off = 7" " = 7" | |
201 | gdb_test "x/4xb &v_be30_1_off" ":\t0x00\t0x00\t0x00\t0x0e" |