1 # Copyright 2020-2024 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/>.
16 # Test support for non-byte-sized integer base types.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 require dwarf2_support
23 standard_testfile .c .S
25 set executable ${testfile}
26 set asm_file [standard_output_file ${srcfile2}]
28 if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
33 Dwarf::assemble ${asm_file} {
36 {DW_AT_language @DW_LANG_C_plus_plus}
38 declare_labels i7_type u1_type u17_type u31_type \
39 u31_1_type u32_0_type u0_0_type be30_1_type
41 i7_type: DW_TAG_base_type {
42 {DW_AT_encoding @DW_ATE_signed}
43 {DW_AT_endianity @DW_END_little}
45 {DW_AT_byte_size 2 DW_FORM_udata}
46 {DW_AT_bit_size 7 DW_FORM_implicit_const}
50 {DW_AT_name "v_i16_m1"}
51 {DW_AT_type :${i7_type}}
52 {DW_AT_external 1 DW_FORM_flag}
53 {DW_AT_location {DW_OP_addr [gdb_target_symbol "i16_m1"]}
57 u1_type: DW_TAG_base_type {
58 {DW_AT_encoding @DW_ATE_boolean}
59 {DW_AT_endianity @DW_END_little}
61 {DW_AT_byte_size 2 DW_FORM_udata}
62 {DW_AT_bit_size 1 DW_FORM_udata}
63 {DW_AT_data_bit_offset 2 DW_FORM_udata}
67 {DW_AT_name "v_u16_1"}
68 {DW_AT_type :${u1_type}}
69 {DW_AT_external 1 DW_FORM_flag}
70 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u16_1"]}
74 u17_type: DW_TAG_base_type {
75 {DW_AT_encoding @DW_ATE_signed}
76 {DW_AT_endianity @DW_END_little}
78 {DW_AT_byte_size 4 DW_FORM_udata}
79 {DW_AT_bit_size 17 DW_FORM_udata}
83 {DW_AT_name "v_u32_m2"}
84 {DW_AT_type :${u17_type}}
85 {DW_AT_external 1 DW_FORM_flag}
86 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_m2"]}
90 u31_type: DW_TAG_base_type {
91 {DW_AT_encoding @DW_ATE_unsigned}
92 {DW_AT_endianity @DW_END_little}
94 {DW_AT_byte_size 4 DW_FORM_udata}
95 {DW_AT_bit_size 31 DW_FORM_udata}
99 {DW_AT_name "v_u32_1"}
100 {DW_AT_type :${u31_type}}
101 {DW_AT_external 1 DW_FORM_flag}
102 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1"]}
106 u31_1_type: DW_TAG_base_type {
107 {DW_AT_encoding @DW_ATE_unsigned}
108 {DW_AT_endianity @DW_END_little}
110 {DW_AT_byte_size 4 DW_FORM_udata}
111 {DW_AT_bit_size 31 DW_FORM_udata}
112 {DW_AT_data_bit_offset 1 DW_FORM_udata}
116 {DW_AT_name "v_u32_1_off"}
117 {DW_AT_type :${u31_1_type}}
118 {DW_AT_external 1 DW_FORM_flag}
119 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1_off"]}
123 be30_1_type: DW_TAG_base_type {
124 {DW_AT_encoding @DW_ATE_unsigned}
125 {DW_AT_endianity @DW_END_big}
126 {DW_AT_name "be30_1"}
127 {DW_AT_byte_size 4 DW_FORM_udata}
128 {DW_AT_bit_size 30 DW_FORM_udata}
129 {DW_AT_data_bit_offset 1 DW_FORM_udata}
133 {DW_AT_name "v_be30_1_off"}
134 {DW_AT_type :${be30_1_type}}
135 {DW_AT_external 1 DW_FORM_flag}
136 {DW_AT_location {DW_OP_addr [gdb_target_symbol "be30_1_off"]}
140 u32_0_type: DW_TAG_base_type {
141 {DW_AT_encoding @DW_ATE_unsigned}
142 {DW_AT_endianity @DW_END_little}
144 {DW_AT_byte_size 4 DW_FORM_udata}
145 {DW_AT_bit_size 0 DW_FORM_udata}
149 {DW_AT_name "v_u32_0"}
150 {DW_AT_type :${u32_0_type}}
151 {DW_AT_external 1 DW_FORM_flag}
152 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
156 u0_0_type: DW_TAG_base_type {
157 {DW_AT_encoding @DW_ATE_unsigned}
158 {DW_AT_endianity @DW_END_little}
160 {DW_AT_byte_size 0 DW_FORM_udata}
164 {DW_AT_name "v_u0_0"}
165 {DW_AT_type :${u0_0_type}}
166 {DW_AT_external 1 DW_FORM_flag}
167 {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
174 if {[prepare_for_testing "failed to prepare" ${executable} \
175 [list ${asm_file} ${srcfile}] {}]} {
183 gdb_test "print v_i16_m1" "= -1"
184 gdb_test "print v_u16_1" "= true"
185 gdb_test "print v_u32_m2" "= -2"
186 gdb_test "print v_u32_1" "= 1"
187 gdb_test "print v_u32_0" "= 0"
188 gdb_test "print v_u0_0" "= 0"
190 gdb_test "print v_i16_m1 = 7" "= 7"
191 gdb_test "print v_i16_m1" "= 7" "print v_i16_m1 after assignment"
193 gdb_test "print v_u32_1_off" "= 1"
194 gdb_test "print v_u32_1_off = 7" " = 7"
195 gdb_test "x/4xb &v_u32_1_off" ":\t0x0e\t0x00\t0x00\t0x00"
197 gdb_test "print v_be30_1_off" "= 1"
198 gdb_test "print v_be30_1_off = 7" " = 7"
199 gdb_test "x/4xb &v_be30_1_off" ":\t0x00\t0x00\t0x00\t0x0e"