1 # Copyright 2015-2019 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/>.
17 # Test DW_TAG_compile_unit with no children and with neither DW_AT_low_pc nor
18 # DW_AT_high_pc but with DW_AT_ranges instead.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if {![dwarf2_support]} {
22 verbose "Skipping DW_AT_ranges test."
26 # The .c files use __attribute__.
27 if [get_compiler_info] {
31 verbose "Skipping DW_AT_ranges test."
35 standard_testfile dw2-ranges-base.c dw2-ranges-base-dw.S
37 set asm_file [standard_output_file $srcfile2]
38 Dwarf::assemble $asm_file {
39 global srcdir subdir srcfile srcfile2
40 declare_labels ranges_label
43 # Find start address and length for our functions.
45 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
47 [function_range frame2 [list ${srcdir}/${subdir}/$srcfile]]
49 [function_range frame3 [list ${srcdir}/${subdir}/$srcfile]]
51 # Very simple info for this test program. We don't care about
52 # this information being correct (w.r.t. funtion / argument types)
53 # just so long as the compilation using makes use of the
54 # .debug_ranges data then the test achieves its objective.
58 {name dw-ranges-base.c}
59 {stmt_list $L DW_FORM_sec_offset}
60 {ranges ${ranges_label} DW_FORM_sec_offset}
78 include_dir "${srcdir}/${subdir}"
79 file_name "$srcfile" 1
81 # Generate simple line table program. The line table
82 # information contained here is not correct, and we really
83 # don't care, just so long as each function has some line
84 # table data associated with it. We do make use of the fake
85 # line numbers that we pick here in the tests below.
87 {DW_LNE_set_address [lindex $main_func 0]}
88 {DW_LNS_advance_line 10}
90 {DW_LNS_advance_pc [lindex $main_func 1]}
91 {DW_LNS_advance_line 19}
95 {DW_LNE_set_address [lindex $frame2_func 0]}
96 {DW_LNS_advance_line 20}
98 {DW_LNS_advance_pc [lindex $frame2_func 1]}
99 {DW_LNS_advance_line 29}
101 {DW_LNE_end_sequence}
103 {DW_LNE_set_address [lindex $frame3_func 0]}
104 {DW_LNS_advance_line 30}
106 {DW_LNS_advance_pc [lindex $frame3_func 1]}
107 {DW_LNS_advance_line 39}
109 {DW_LNE_end_sequence}
113 # Generate ranges data. This is the point of this whole test
114 # file, we must have multiple bases specified, so we use a new
115 # base for each function.
116 ranges {is_64 [is_64_target]} {
117 ranges_label: sequence {
118 {base [lindex $main_func 0]}
119 {range 0 [lindex $main_func 1]}
120 {base [lindex $frame2_func 0]}
121 {range 0 [lindex $frame2_func 1]}
122 {base [lindex $frame3_func 0]}
123 {range 0 [lindex $frame3_func 1]}
128 if { [prepare_for_testing "failed to prepare" ${testfile} \
129 [list $srcfile $asm_file] {nodebug}] } {
137 # Make use of the line numbers we faked in the .debug_line table above.
138 gdb_test "info line main" \
139 "Line 11 of .* starts at address .* and ends at .*"
140 gdb_test "info line frame2" \
141 "Line 21 of .* starts at address .* and ends at .*"
142 gdb_test "info line frame3" \
143 "Line 31 of .* starts at address .* and ends at .*"