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 DW_AT_ranges attributes referencing the .debug_rnglists section using the
17 # DW_FORM_sec_offset form.
21 require dwarf2_support
23 foreach_with_prefix is_64 {false true} {
25 standard_testfile main.c -dw64.S
26 set testfile ${testfile}-dw64
28 standard_testfile main.c -dw32.S
29 set testfile ${testfile}-dw32
32 set asm_file [standard_output_file $srcfile2]
33 Dwarf::assemble $asm_file {
36 declare_labels cu1_range_list cu2_range_list cu3_range_list
37 declare_labels foo_range_list bar_range_list baz_range_list
39 # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
46 {DW_AT_ranges $cu1_range_list DW_FORM_sec_offset}
50 {DW_AT_ranges $foo_range_list DW_FORM_sec_offset}
55 # This CU uses the DW_FORM_sec_offset form to refer to the
56 # .debug_rnglists section, but also has the DW_AT_rnglists_base
57 # attribute present. The DW_AT_rnglists_base attribute is not used to
58 # interpret the DW_AT_ranges value, but it should also do no harm.
64 {DW_AT_ranges $cu2_range_list DW_FORM_sec_offset}
65 {DW_AT_rnglists_base cu2_table DW_FORM_sec_offset}
69 {DW_AT_ranges $bar_range_list DW_FORM_sec_offset}
74 # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
75 # section. The corresponding contribution in the .debug_rnglists has no
82 {DW_AT_ranges $cu3_range_list DW_FORM_sec_offset}
86 {DW_AT_ranges $baz_range_list DW_FORM_sec_offset}
91 rnglists {is-64 $is_64} {
92 # The lists in this table are accessed by direct offset
93 # (DW_FORM_sec_offset).
96 cu1_range_list: list_ {
97 start_end 0x4000 0x5000
101 foo_range_list: list_ {
102 start_end 0x4000 0x4010
106 table {post-header-label cu2_table} {
108 cu2_range_list: list_ {
109 start_end 0x5000 0x6000
112 # For the bar function.
113 bar_range_list: list_ {
114 start_end 0x5000 0x5010
118 table {with-offset-array false} {
120 cu3_range_list: list_ {
121 start_end 0x6000 0x7000
124 # For the baz function.
125 baz_range_list: list_ {
126 start_end 0x6000 0x6010
132 if { [prepare_for_testing "failed to prepare" ${testfile} \
133 [list $srcfile $asm_file] {nodebug}] } {
137 # Sanity checks to make sure GDB slurped the symbols correctly.
138 gdb_test "p/x &foo" " = 0x4000"
139 gdb_test "p/x &bar" " = 0x5000"
140 gdb_test "p/x &baz" " = 0x6000"