1 # Copyright 2018-2023 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 ![is_c_compiler_gcc] {
27 unsupported "gcc required for this test"
31 standard_testfile main.c .c -dw.S
33 # We need to know the size of integer and address types in order to
34 # write some of the debugging info we'd like to generate.
36 # For that, we ask GDB by debugging our test program. Any program
37 # would do, but since we already have it specifically for this
38 # testcase, might as well use that.
40 if { [prepare_for_testing "failed to prepare" ${testfile} \
41 [list ${srcfile} ${srcfile2}]] } {
45 set asm_file [standard_output_file $srcfile3]
46 Dwarf::assemble $asm_file {
47 global srcdir subdir srcfile srcfile2
48 declare_labels integer_label volatile_label func_ranges_label cu_ranges_label
49 set int_size [get_sizeof "int" 4]
51 # Find start address and length for our functions.
52 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
54 lassign [function_range foo $sources] \
56 set foo_end "$foo_start + $foo_len"
58 lassign [function_range foo_low $sources] \
59 foo_low_start foo_low_len
60 set foo_low_end "$foo_low_start + $foo_low_len"
62 lassign [function_range bar $sources] \
64 set bar_end "$bar_start + $bar_len"
66 lassign [function_range baz $sources] \
68 set baz_end "$baz_start + $baz_len"
73 {name dw-ranges-psym.c}
75 {ranges ${cu_ranges_label} DW_FORM_sec_offset}
77 integer_label: DW_TAG_base_type {
78 {DW_AT_byte_size $int_size DW_FORM_sdata}
79 {DW_AT_encoding @DW_ATE_signed}
82 volatile_label: DW_TAG_volatile_type {
83 {type :$integer_label}
88 {ranges ${func_ranges_label} DW_FORM_sec_offset}
93 {low_pc $bar_start addr}
94 {high_pc $bar_len DW_FORM_data4}
99 {low_pc $baz_start addr}
100 {high_pc $baz_len DW_FORM_data4}
105 # Generate ranges data.
106 ranges {is_64 [is_64_target]} {
107 func_ranges_label: sequence {
108 range $foo_start $foo_end
109 range $foo_low_start $foo_low_end
111 cu_ranges_label: sequence {
112 range $foo_start $foo_end
113 range $foo_low_start $foo_low_end
114 range $bar_start $bar_end
115 range $baz_start $baz_end
120 if { [build_executable "failed to prepare" ${testfile} \
121 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
126 gdb_load_no_complaints $binfile
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" \