1 # Copyright 2020-2021 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 if {![dwarf2_support]} {
25 standard_testfile main.c .S
27 set executable ${testfile}
28 set asm_file [standard_output_file ${srcfile2}]
30 # We need to know the size of integer types in order to write some of the
31 # debugging info we'd like to generate.
32 if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
37 Dwarf::assemble $asm_file {
38 global srcdir subdir srcfile
40 declare_labels int_label
41 declare_labels ranges_label
44 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
48 {language @DW_LANG_C_plus_plus}
54 {const_value 1 DW_FORM_sdata}
61 {language @DW_LANG_C_plus_plus}
63 {ranges ${ranges_label} sec_offset}
64 {low_pc {[lindex $main_func 0]}}
66 int_label: base_type {
68 {encoding @DW_ATE_signed}
74 ranges {is_64 [is_64_target]} {
75 ranges_label: sequence {
76 range 0 [lindex $main_func 1]
81 if { [prepare_for_testing "failed to prepare" ${testfile} \
82 [list $srcfile $asm_file] {nodebug}] } {
86 clean_restart ${binfile}
88 # Expand cu1. This will enqueue cu2.
89 gdb_test "ptype foo" "type = int"
91 # Now check that cu2 has an address range starting at main.
92 set cu2_blockvector_re \
94 "Symtab for file cu2 at $hex" \
95 "Read from object file \[^\r\n\]*" \
100 "block #000, \[^\r\n\]* in ($hex)..$hex" \
102 gdb_test_multiple "maint print symbols -objfile $binfile" "CU addr found" {
103 -re -wrap $cu2_blockvector_re {
104 set addr $expect_out(1,string)
105 if { $addr eq "0x0" } {
106 fail "$gdb_test_name (Found 0x0)"
108 gdb_test "info symbol $addr" "main in section .*" \