Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / intbits.exp
blob9f9cea1e51fdef67ecb4483c85047712b449bac9
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.
18 load_lib dwarf.exp
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}] {
29     return -1
32 # Create the DWARF.
33 Dwarf::assemble ${asm_file} {
34     cu {} {
35         DW_TAG_compile_unit {
36             {DW_AT_language @DW_LANG_C_plus_plus}
37         } {
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}
44                 {DW_AT_name "i7"}
45                 {DW_AT_byte_size 2 DW_FORM_udata}
46                 {DW_AT_bit_size 7 DW_FORM_implicit_const}
47             }
49             DW_TAG_variable {
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"]}
54                     SPECIAL_expr}
55             }
57             u1_type: DW_TAG_base_type {
58                 {DW_AT_encoding @DW_ATE_boolean}
59                 {DW_AT_endianity @DW_END_little}
60                 {DW_AT_name "u1"}
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}
64             }
66             DW_TAG_variable {
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"]}
71                     SPECIAL_expr}
72             }
74             u17_type: DW_TAG_base_type {
75                 {DW_AT_encoding @DW_ATE_signed}
76                 {DW_AT_endianity @DW_END_little}
77                 {DW_AT_name "u17"}
78                 {DW_AT_byte_size 4 DW_FORM_udata}
79                 {DW_AT_bit_size 17 DW_FORM_udata}
80             }
82             DW_TAG_variable {
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"]}
87                     SPECIAL_expr}
88             }
90             u31_type: DW_TAG_base_type {
91                 {DW_AT_encoding @DW_ATE_unsigned}
92                 {DW_AT_endianity @DW_END_little}
93                 {DW_AT_name "u31"}
94                 {DW_AT_byte_size 4 DW_FORM_udata}
95                 {DW_AT_bit_size 31 DW_FORM_udata}
96             }
98             DW_TAG_variable {
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"]}
103                     SPECIAL_expr}
104             }
106             u31_1_type: DW_TAG_base_type {
107                 {DW_AT_encoding @DW_ATE_unsigned}
108                 {DW_AT_endianity @DW_END_little}
109                 {DW_AT_name "u31_1"}
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}
113             }
115             DW_TAG_variable {
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"]}
120                     SPECIAL_expr}
121             }
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}
130             }
132             DW_TAG_variable {
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"]}
137                     SPECIAL_expr}
138             }
140             u32_0_type: DW_TAG_base_type {
141                 {DW_AT_encoding @DW_ATE_unsigned}
142                 {DW_AT_endianity @DW_END_little}
143                 {DW_AT_name "u32_0"}
144                 {DW_AT_byte_size 4 DW_FORM_udata}
145                 {DW_AT_bit_size 0 DW_FORM_udata}
146             }
148             DW_TAG_variable {
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"]}
153                     SPECIAL_expr}
154             }
156             u0_0_type: DW_TAG_base_type {
157                 {DW_AT_encoding @DW_ATE_unsigned}
158                 {DW_AT_endianity @DW_END_little}
159                 {DW_AT_name "u0_0"}
160                 {DW_AT_byte_size 0 DW_FORM_udata}
161             }
163             DW_TAG_variable {
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"]}
168                     SPECIAL_expr}
169             }
170         }
171     }
174 if {[prepare_for_testing "failed to prepare" ${executable} \
175          [list ${asm_file} ${srcfile}] {}]} {
176     return -1
179 if {![runto_main]} {
180     return -1
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"