1 # Copyright
2020-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
/>.
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 if {![dwarf2_support
]} {
25 standard_testfile .c .S
27 set executable $
{testfile
}
28 set asm_file
[standard_output_file $
{srcfile2
}]
30 if [prepare_for_testing
"failed to prepare" ${testfile} ${srcfile}] {
35 Dwarf
::assemble $
{asm_file
} {
38 {DW_AT_language @DW_LANG_C_plus_plus
}
40 declare_labels i7_type u1_type u17_type u31_type \
41 u31_1_type u32_0_type u0_0_type be30_1_type
43 i7_type
: DW_TAG_base_type
{
44 {DW_AT_encoding @DW_ATE_signed
}
45 {DW_AT_endianity @DW_END_little
}
47 {DW_AT_byte_size
2 DW_FORM_udata
}
48 {DW_AT_bit_size
7 DW_FORM_udata
}
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"]}
59 u1_type
: DW_TAG_base_type
{
60 {DW_AT_encoding @DW_ATE_boolean
}
61 {DW_AT_endianity @DW_END_little
}
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
}
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"]}
76 u17_type
: DW_TAG_base_type
{
77 {DW_AT_encoding @DW_ATE_signed
}
78 {DW_AT_endianity @DW_END_little
}
80 {DW_AT_byte_size
4 DW_FORM_udata
}
81 {DW_AT_bit_size
17 DW_FORM_udata
}
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"]}
92 u31_type
: DW_TAG_base_type
{
93 {DW_AT_encoding @DW_ATE_unsigned
}
94 {DW_AT_endianity @DW_END_little
}
96 {DW_AT_byte_size
4 DW_FORM_udata
}
97 {DW_AT_bit_size
31 DW_FORM_udata
}
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"]}
108 u31_1_type
: DW_TAG_base_type
{
109 {DW_AT_encoding @DW_ATE_unsigned
}
110 {DW_AT_endianity @DW_END_little
}
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
}
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"]}
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
}
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"]}
142 u32_0_type
: DW_TAG_base_type
{
143 {DW_AT_encoding @DW_ATE_unsigned
}
144 {DW_AT_endianity @DW_END_little
}
146 {DW_AT_byte_size
4 DW_FORM_udata
}
147 {DW_AT_bit_size
0 DW_FORM_udata
}
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"]}
158 u0_0_type
: DW_TAG_base_type
{
159 {DW_AT_encoding @DW_ATE_unsigned
}
160 {DW_AT_endianity @DW_END_little
}
162 {DW_AT_byte_size
0 DW_FORM_udata
}
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"]}
176 if {[prepare_for_testing
"failed to prepare" ${executable} \
177 [list $
{asm_file
} $
{srcfile
}] {}]} {
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"
192 gdb_test
"print v_i16_m1 = 7" "= 7"
193 gdb_test
"print v_i16_m1" "= 7" "print v_i16_m1 after assignment"
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"
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"