Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2020-2022 Free Software Foundation, Inc. |
962effa7 SM |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | # Test DW_AT_ranges attributes referencing the .debug_rnglists section using the | |
17 | # DW_FORM_sec_offset form. | |
18 | ||
19 | load_lib dwarf.exp | |
20 | ||
21 | if {![dwarf2_support]} { | |
22 | return 0 | |
23 | } | |
24 | ||
25 | foreach_with_prefix is_64 {false true} { | |
26 | if { $is_64 } { | |
27 | standard_testfile main.c -dw64.S | |
28 | set testfile ${testfile}-dw64 | |
29 | } else { | |
30 | standard_testfile main.c -dw32.S | |
31 | set testfile ${testfile}-dw32 | |
32 | } | |
33 | ||
34 | set asm_file [standard_output_file $srcfile2] | |
35 | Dwarf::assemble $asm_file { | |
36 | global is_64 | |
37 | ||
9307efbe SM |
38 | declare_labels cu1_range_list cu2_range_list cu3_range_list |
39 | declare_labels foo_range_list bar_range_list baz_range_list | |
962effa7 SM |
40 | |
41 | # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists | |
42 | # section. | |
43 | cu { | |
44 | version 5 | |
45 | is_64 $is_64 | |
46 | } { | |
47 | DW_TAG_compile_unit { | |
2b0c7f41 | 48 | {DW_AT_ranges $cu1_range_list DW_FORM_sec_offset} |
962effa7 SM |
49 | } { |
50 | DW_TAG_subprogram { | |
51 | {DW_AT_name "foo"} | |
52 | {DW_AT_ranges $foo_range_list DW_FORM_sec_offset} | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
2b0c7f41 SM |
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. | |
61 | cu { | |
62 | version 5 | |
63 | is_64 $is_64 | |
64 | } { | |
65 | DW_TAG_compile_unit { | |
66 | {DW_AT_ranges $cu2_range_list DW_FORM_sec_offset} | |
67 | {DW_AT_rnglists_base cu2_table DW_FORM_sec_offset} | |
68 | } { | |
69 | DW_TAG_subprogram { | |
70 | {DW_AT_name "bar"} | |
71 | {DW_AT_ranges $bar_range_list DW_FORM_sec_offset} | |
72 | } | |
73 | } | |
74 | } | |
75 | ||
9307efbe SM |
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 | |
78 | # offset array. | |
79 | cu { | |
80 | version 5 | |
81 | is_64 $is_64 | |
82 | } { | |
83 | DW_TAG_compile_unit { | |
84 | {DW_AT_ranges $cu3_range_list DW_FORM_sec_offset} | |
85 | } { | |
86 | DW_TAG_subprogram { | |
87 | {DW_AT_name "baz"} | |
88 | {DW_AT_ranges $baz_range_list DW_FORM_sec_offset} | |
89 | } | |
90 | } | |
91 | } | |
92 | ||
962effa7 SM |
93 | rnglists -is-64 $is_64 { |
94 | # The lists in this table are accessed by direct offset | |
95 | # (DW_FORM_sec_offset). | |
96 | table { | |
2b0c7f41 SM |
97 | # For the first CU. |
98 | cu1_range_list: list_ { | |
962effa7 SM |
99 | start_end 0x4000 0x5000 |
100 | } | |
101 | ||
102 | # For function foo. | |
103 | foo_range_list: list_ { | |
104 | start_end 0x4000 0x4010 | |
105 | } | |
106 | } | |
2b0c7f41 SM |
107 | |
108 | table -post-header-label cu2_table { | |
109 | # For the second CU. | |
110 | cu2_range_list: list_ { | |
111 | start_end 0x5000 0x6000 | |
112 | } | |
113 | ||
114 | # For the bar function. | |
115 | bar_range_list: list_ { | |
116 | start_end 0x5000 0x5010 | |
117 | } | |
118 | } | |
9307efbe SM |
119 | |
120 | table -with-offset-array false { | |
121 | # For the third CU. | |
122 | cu3_range_list: list_ { | |
123 | start_end 0x6000 0x7000 | |
124 | } | |
125 | ||
126 | # For the baz function. | |
127 | baz_range_list: list_ { | |
128 | start_end 0x6000 0x6010 | |
129 | } | |
130 | } | |
962effa7 SM |
131 | } |
132 | } | |
133 | ||
134 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
135 | [list $srcfile $asm_file] {nodebug}] } { | |
136 | return -1 | |
137 | } | |
138 | ||
139 | # Sanity checks to make sure GDB slurped the symbols correctly. | |
140 | gdb_test "p/x &foo" " = 0x4000" | |
2b0c7f41 | 141 | gdb_test "p/x &bar" " = 0x5000" |
9307efbe | 142 | gdb_test "p/x &baz" " = 0x6000" |
962effa7 | 143 | } |