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 DW_AT_ranges attributes referencing the .debug_rnglists section using the
17 # DW_FORM_sec_offset form.
21 if {![dwarf2_support
]} {
25 foreach_with_prefix is_64
{false true
} {
27 standard_testfile main.c
-dw64.S
28 set testfile $
{testfile
}-dw64
30 standard_testfile main.c
-dw32.S
31 set testfile $
{testfile
}-dw32
34 set asm_file
[standard_output_file $srcfile2
]
35 Dwarf
::assemble $asm_file
{
38 declare_labels cu1_range_list cu2_range_list cu3_range_list
39 declare_labels foo_range_list bar_range_list baz_range_list
41 # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
48 {DW_AT_ranges $cu1_range_list DW_FORM_sec_offset
}
52 {DW_AT_ranges $foo_range_list DW_FORM_sec_offset
}
57 # This CU uses the DW_FORM_sec_offset form to refer to the
58 # .debug_rnglists section
, but also has the DW_AT_rnglists_base
59 # attribute present. The DW_AT_rnglists_base attribute is not used to
60 # interpret the DW_AT_ranges value
, but it should also
do no harm.
66 {DW_AT_ranges $cu2_range_list DW_FORM_sec_offset
}
67 {DW_AT_rnglists_base cu2_table DW_FORM_sec_offset
}
71 {DW_AT_ranges $bar_range_list DW_FORM_sec_offset
}
76 # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
77 # section. The corresponding contribution in the .debug_rnglists has no
84 {DW_AT_ranges $cu3_range_list DW_FORM_sec_offset
}
88 {DW_AT_ranges $baz_range_list DW_FORM_sec_offset
}
93 rnglists
{is
-64 $is_64
} {
94 # The lists in this table are accessed by direct offset
95 #
(DW_FORM_sec_offset
).
98 cu1_range_list
: list_
{
99 start_end
0x4000 0x5000
103 foo_range_list
: list_
{
104 start_end
0x4000 0x4010
108 table
{post
-header
-label cu2_table
} {
110 cu2_range_list
: list_
{
111 start_end
0x5000 0x6000
114 #
For the bar function.
115 bar_range_list
: list_
{
116 start_end
0x5000 0x5010
120 table
{with
-offset
-array false
} {
122 cu3_range_list
: list_
{
123 start_end
0x6000 0x7000
126 #
For the baz function.
127 baz_range_list
: list_
{
128 start_end
0x6000 0x6010
134 if { [prepare_for_testing
"failed to prepare" ${testfile} \
135 [list $srcfile $asm_file
] {nodebug
}] } {
139 # Sanity checks to make sure GDB slurped the symbols correctly.
140 gdb_test
"p/x &foo" " = 0x4000"
141 gdb_test
"p/x &bar" " = 0x5000"
142 gdb_test
"p/x &baz" " = 0x6000"