1 # Copyright 2018-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/>.
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 require dwarf2_support
23 require is_c_compiler_gcc
25 standard_testfile main.c .c -dw.S
27 # We need to know the size of integer and address types in order to
28 # write some of the debugging info we'd like to generate.
30 # For that, we ask GDB by debugging our test program. Any program
31 # would do, but since we already have it specifically for this
32 # testcase, might as well use that.
34 if { [prepare_for_testing "failed to prepare" ${testfile} \
35 [list ${srcfile} ${srcfile2}]] } {
39 set asm_file [standard_output_file $srcfile3]
40 Dwarf::assemble $asm_file {
41 global srcdir subdir srcfile srcfile2
42 declare_labels integer_label volatile_label func_ranges_label cu_ranges_label
43 set int_size [get_sizeof "int" 4]
45 # Find start address and length for our functions.
46 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
48 lassign [function_range foo $sources] \
50 set foo_end "$foo_start + $foo_len"
52 lassign [function_range foo_low $sources] \
53 foo_low_start foo_low_len
54 set foo_low_end "$foo_low_start + $foo_low_len"
56 lassign [function_range bar $sources] \
58 set bar_end "$bar_start + $bar_len"
60 lassign [function_range baz $sources] \
62 set baz_end "$baz_start + $baz_len"
67 {name dw-ranges-psym.c}
69 {ranges ${cu_ranges_label} DW_FORM_sec_offset}
71 integer_label: DW_TAG_base_type {
72 {DW_AT_byte_size $int_size DW_FORM_sdata}
73 {DW_AT_encoding @DW_ATE_signed}
76 volatile_label: DW_TAG_volatile_type {
77 {type :$integer_label}
82 {ranges ${func_ranges_label} DW_FORM_sec_offset}
87 {low_pc $bar_start addr}
88 {high_pc $bar_len DW_FORM_data4}
93 {low_pc $baz_start addr}
94 {high_pc $baz_len DW_FORM_data4}
99 # Generate ranges data.
100 ranges {is_64 [is_64_target]} {
101 func_ranges_label: sequence {
102 range $foo_start $foo_end
103 range $foo_low_start $foo_low_end
105 cu_ranges_label: sequence {
106 range $foo_start $foo_end
107 range $foo_low_start $foo_low_end
108 range $bar_start $bar_end
109 range $baz_start $baz_end
114 if { [build_executable "failed to prepare" ${testfile} \
115 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
120 gdb_load_no_complaints $binfile
126 # "someothername" should be put into the partial symbol table, but
127 # there was a bug causing functions using DW_AT_ranges not to be.
128 # Note we use a name that is very different from the linkage name, in
129 # order to not set the breakpoint via minsyms.
130 gdb_test "break someothername" \