1 # Copyright 2021-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 # Check psymtabs addrmaps generated from DW_AT_ranges of functions.
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 standard_testfile -main.c .c -dw.S
28 # We need to know the size of integer and address types in order to
29 # write some of the debugging info we'd like to generate.
31 # For that, we ask GDB by debugging our test program. Any program
32 # would do, but since we already have it specifically for this
33 # testcase, might as well use that.
35 if { [prepare_for_testing "failed to prepare" ${testfile} \
36 [list ${srcfile} ${srcfile2}]] } {
40 set asm_file [standard_output_file $srcfile3]
41 Dwarf::assemble $asm_file {
42 global srcdir subdir srcfile srcfile2
43 declare_labels integer_label func_ranges_label
44 set int_size [get_sizeof "int" 4]
46 # Find start address and length for our functions.
47 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
49 lassign [function_range foo $sources] \
51 set foo_end "$foo_start + $foo_len"
53 lassign [function_range foo_low $sources] \
54 foo_low_start foo_low_len
55 set foo_low_end "$foo_low_start + $foo_low_len"
57 lassign [function_range bar $sources] \
59 set bar_end "$bar_start + $bar_len"
61 lassign [function_range baz $sources] \
63 set baz_end "$baz_start + $baz_len"
68 {name dw-ranges-psym.c}
71 integer_label: DW_TAG_base_type {
72 {DW_AT_byte_size $int_size DW_FORM_sdata}
73 {DW_AT_encoding @DW_ATE_signed}
79 {ranges ${func_ranges_label} DW_FORM_sec_offset}
84 {low_pc $bar_start addr}
85 {high_pc $bar_len DW_FORM_data4}
90 {low_pc $baz_start addr}
91 {high_pc $baz_len DW_FORM_data4}
96 # Generate ranges data. Create a hole at $foo_low_start + 1" .. $foo_low_end.
97 ranges {is_64 [is_64_target]} {
98 func_ranges_label: sequence {
99 range $foo_start $foo_end
100 range $foo_low_start "$foo_low_start + 1"
101 #range "$foo_low_start + 1" $foo_low_end
106 if { [build_executable "failed to prepare" ${testfile} \
107 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
113 gdb_load_no_complaints $binfile
119 # Generate backtrace from baz, that visits the hole in the addrmap. If
120 # the hole is there in the symbol table, but not the partial symbol table,
123 # warning: (Internal error: pc 0x555555554619 in read in psymtab, \
124 # but not in symtab.)
128 gdb_test "break baz" \
133 set re "warning: \\(Internal error: pc $hex in read in psymtab, but not in symtab\\.\\)"
134 gdb_test_multiple "bt" "" {