Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / enqueued-cu-base-addr.exp
blobe4e028874d92faa8255d4c2fb840033819738bb4
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.
18 load_lib dwarf.exp
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}]
28 # Create the DWARF.
29 Dwarf::assemble $asm_file {
30     global srcdir subdir srcfile
32     declare_labels int_label
33     declare_labels ranges_label
35     set main_func \
36         [function_range main [list ${srcdir}/${subdir}/$srcfile]]
38     cu {} {
39         compile_unit {
40             {language @DW_LANG_C_plus_plus}
41             {name "cu1"}
42         } {
43             DW_TAG_variable {
44                 {name foo}
45                 {type %$int_label}
46                 {const_value 1 DW_FORM_sdata}
47             }
48         }
49     }
51     cu {} {
52         compile_unit {
53             {language @DW_LANG_C_plus_plus}
54             {name "cu2"}
55             {ranges ${ranges_label} sec_offset}
56             {low_pc {[lindex $main_func 0]}}
57         } {
58             int_label: base_type {
59                 {byte_size 4 udata}
60                 {encoding @DW_ATE_signed}
61                 {name int}
62             }
63         }
64     }
66     ranges {is_64 [is_64_target]} {
67         ranges_label: sequence {
68             range 0 [lindex $main_func 1]
69         }
70     }
73 if { [prepare_for_testing "failed to prepare" ${testfile} \
74           [list $srcfile $asm_file] {nodebug}] } {
75     return -1
78 # Expand cu1.  This will enqueue cu2.
79 set cu1_expanded 0
80 gdb_test_multiple "ptype foo" "" {
81     -re -wrap "type = int" {
82         set cu1_expanded 1
83         pass $gdb_test_name
84     }
87 require {expr $cu1_expanded == 1}
89 # Now check that cu2 has an address range starting at main.
90 set cu2_blockvector_re \
91     [multi_line \
92          "Symtab for file cu2 at $hex" \
93          "Read from object file \[^\r\n\]*" \
94          "Language: c\\+\\+" \
95          "" \
96          "Blockvector:" \
97          "" \
98          "block #000, \[^\r\n\]* in ($hex)..$hex" \
99          ".*"]
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)"
105         } else {
106             gdb_test "info symbol $addr" "main in section .*" \
107                 $gdb_test_name
108         }
109     }