1 # Copyright 2020-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/>.
16 # Check whether .debug_ranges is correctly read in during symtab expansion.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 require dwarf2_support
23 standard_testfile main.c .S
25 set executable ${testfile}
26 set asm_file [standard_output_file ${srcfile2}]
29 Dwarf::assemble $asm_file {
30 global srcdir subdir srcfile
32 declare_labels int_label
33 declare_labels ranges_label
36 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
40 {language @DW_LANG_C_plus_plus}
46 {const_value 1 DW_FORM_sdata}
53 {language @DW_LANG_C_plus_plus}
55 {ranges ${ranges_label} sec_offset}
56 {low_pc {[lindex $main_func 0]}}
58 int_label: base_type {
60 {encoding @DW_ATE_signed}
66 ranges {is_64 [is_64_target]} {
67 ranges_label: sequence {
68 range 0 [lindex $main_func 1]
73 if { [prepare_for_testing "failed to prepare" ${testfile} \
74 [list $srcfile $asm_file] {nodebug}] } {
78 # Expand cu1. This will enqueue cu2.
80 gdb_test_multiple "ptype foo" "" {
81 -re -wrap "type = int" {
87 require {expr $cu1_expanded == 1}
89 # Now check that cu2 has an address range starting at main.
90 set cu2_blockvector_re \
92 "Symtab for file cu2 at $hex" \
93 "Read from object file \[^\r\n\]*" \
98 "block #000, \[^\r\n\]* in ($hex)..$hex" \
100 gdb_test_multiple "maint print symbols -source cu2" "CU addr found" {
101 -re -wrap $cu2_blockvector_re {
102 set addr $expect_out(1,string)
103 if { $addr eq "0x0" } {
104 fail "$gdb_test_name (Found 0x0)"
106 gdb_test "info symbol $addr" "main in section .*" \