1 # Copyright 2018-2020 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/>.
18 # Test that psymbols are made when DW_AT_ranges is used.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if {![dwarf2_support]} {
22 unsupported "dwarf2 support required for this test"
26 if [get_compiler_info] {
30 unsupported "gcc required for this test"
34 standard_testfile main.c .c -dw.S
36 # We need to know the size of integer and address types in order to
37 # write some of the debugging info we'd like to generate.
39 # For that, we ask GDB by debugging our test program. Any program
40 # would do, but since we already have it specifically for this
41 # testcase, might as well use that.
43 if { [prepare_for_testing "failed to prepare" ${testfile} \
44 [list ${srcfile} ${srcfile2}]] } {
48 set asm_file [standard_output_file $srcfile3]
49 Dwarf::assemble $asm_file {
50 global srcdir subdir srcfile srcfile2
51 declare_labels integer_label volatile_label func_ranges_label cu_ranges_label
52 set int_size [get_sizeof "int" 4]
54 # Find start address and length for our functions.
55 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
57 lassign [function_range foo $sources] \
59 set foo_end "$foo_start + $foo_len"
61 lassign [function_range foo_low $sources] \
62 foo_low_start foo_low_len
63 set foo_low_end "$foo_low_start + $foo_low_len"
65 lassign [function_range bar $sources] \
67 set bar_end "$bar_start + $bar_len"
69 lassign [function_range baz $sources] \
71 set baz_end "$baz_start + $baz_len"
76 {name dw-ranges-psym.c}
78 {ranges ${cu_ranges_label} DW_FORM_sec_offset}
80 integer_label: DW_TAG_base_type {
81 {DW_AT_byte_size $int_size DW_FORM_sdata}
82 {DW_AT_encoding @DW_ATE_signed}
85 volatile_label: DW_TAG_volatile_type {
86 {type :$integer_label}
91 {ranges ${func_ranges_label} DW_FORM_sec_offset}
96 {low_pc $bar_start addr}
97 {high_pc $bar_len DW_FORM_data4}
102 {low_pc $baz_start addr}
103 {high_pc $baz_len DW_FORM_data4}
108 # Generate ranges data.
109 ranges {is_64 [is_64_target]} {
110 func_ranges_label: sequence {
111 range $foo_start $foo_end
112 range $foo_low_start $foo_low_end
114 cu_ranges_label: sequence {
115 range $foo_start $foo_end
116 range $foo_low_start $foo_low_end
117 range $bar_start $bar_end
118 range $baz_start $baz_end
123 if { [prepare_for_testing "failed to prepare" ${testfile} \
124 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
132 # "someothername" should be put into the partial symbol table, but
133 # there was a bug causing functions using DW_AT_ranges not to be.
134 # Note we use a name that is very different from the linkage name, in
135 # order to not set the breakpoint via minsyms.
136 gdb_test "break someothername" \