]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp
[gdb/testsuite] Use DW_FORM_ref_addr in gdb.dwarf2/enqueued-cu-base-addr.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / enqueued-cu-base-addr.exp
1 # Copyright 2020-2021 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # Check whether .debug_ranges is correctly read in during symtab expansion.
17
18 load_lib dwarf.exp
19
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if {![dwarf2_support]} {
22 return 0
23 };
24
25 standard_testfile main.c .S
26
27 set executable ${testfile}
28 set asm_file [standard_output_file ${srcfile2}]
29
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}] {
33 return -1
34 }
35
36 # Create the DWARF.
37 Dwarf::assemble $asm_file {
38 global srcdir subdir srcfile
39
40 declare_labels int_label
41 declare_labels ranges_label
42
43 set main_func \
44 [function_range main [list ${srcdir}/${subdir}/$srcfile]]
45
46 cu {} {
47 compile_unit {
48 {language @DW_LANG_C_plus_plus}
49 {name "cu1"}
50 } {
51 DW_TAG_variable {
52 {name foo}
53 {type %$int_label}
54 {const_value 1 DW_FORM_sdata}
55 }
56 }
57 }
58
59 cu {} {
60 compile_unit {
61 {language @DW_LANG_C_plus_plus}
62 {name "cu2"}
63 {ranges ${ranges_label} sec_offset}
64 {low_pc {[lindex $main_func 0]}}
65 } {
66 int_label: base_type {
67 {byte_size 4 udata}
68 {encoding @DW_ATE_signed}
69 {name int}
70 }
71 }
72 }
73
74 ranges {is_64 [is_64_target]} {
75 ranges_label: sequence {
76 range 0 [lindex $main_func 1]
77 }
78 }
79 }
80
81 if { [prepare_for_testing "failed to prepare" ${testfile} \
82 [list $srcfile $asm_file] {nodebug}] } {
83 return -1
84 }
85
86 clean_restart ${binfile}
87
88 # Expand cu1. This will enqueue cu2.
89 gdb_test "ptype foo" "type = int"
90
91 # Now check that cu2 has an address range starting at main.
92 set cu2_blockvector_re \
93 [multi_line \
94 "Symtab for file cu2 at $hex" \
95 "Read from object file \[^\r\n\]*" \
96 "Language: c\\+\\+" \
97 "" \
98 "Blockvector:" \
99 "" \
100 "block #000, \[^\r\n\]* in ($hex)..$hex" \
101 ".*"]
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)"
107 } else {
108 gdb_test "info symbol $addr" "main in section .*" \
109 $gdb_test_name
110 }
111 }
112 }