Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-zero-range.exp
CommitLineData
88b9d363 1# Copyright 2021-2022 Free Software Foundation, Inc.
a656ee08
TV
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 that the ".debug_ranges entry has start address of zero" complaint
17# is triggered for a loaded shared lib.
18
19load_lib dwarf.exp
20
21# This test can only be run on targets which support DWARF-2 and use gas.
22if {![dwarf2_support]} {
23 verbose "Skipping $gdb_test_file_name."
24 return 0
25}
26
27if {[skip_shlib_tests]} {
28 return 0
29}
30
31standard_testfile .c -shlib.c -dw.S
32
33# Test with both a .debug_ranges section (DWARF 4) and a .debug_rnglists
34# section (DWARF 5).
35
36foreach_with_prefix ranges_sect {ranges rnglists} {
37 set asm_file [standard_output_file ${ranges_sect}-$srcfile3]
38
39 if { $ranges_sect == "ranges" } {
40 Dwarf::assemble $asm_file {
41 global srcdir subdir srcfile2
42 declare_labels ranges_label
43
44 cu {} {
45 compile_unit {
46 {language @DW_LANG_C}
47 {name $srcfile2}
48 {ranges ${ranges_label} DW_FORM_sec_offset}
49 } {
50 subprogram {
51 {external 1 flag}
52 {name foo}
53 }
54 }
55 }
56
57 ranges {is_64 [is_64_target]} {
58 ranges_label: sequence {
59 base 0
60 range 0 1
61 }
62 }
63 }
64 } elseif { $ranges_sect == "rnglists" } {
65 Dwarf::assemble $asm_file {
66 global srcdir subdir srcfile2
67 declare_labels rnglists_label
68
69 cu {
70 version 5
71 } {
72 compile_unit {
73 {language @DW_LANG_C}
74 {name $srcfile2}
75 {ranges ${rnglists_label} DW_FORM_sec_offset}
76 } {
77 subprogram {
78 {external 1 flag}
79 {name foo}
80 }
81 }
82 }
83
84 rnglists {
85 table {
86 rnglists_label: list_ {
87 start_end 0 1
88 }
89 }
90 }
91 }
92 } else {
93 error "invalid ranges section kind"
94 }
95
96 set lib1 [standard_output_file shr1.sl]
97 set lib_opts "nodebug"
98
99 set sources [list ${srcdir}/${subdir}/$srcfile2 $asm_file]
100 if { [gdb_compile_shlib $sources ${lib1} $lib_opts] != "" } {
101 untested "failed to compile"
102 return -1
103 }
104
105 set exec_opts [list debug shlib=${lib1}]
106 set sources ${srcdir}/${subdir}/${srcfile}
107 if { [gdb_compile $sources ${binfile} executable \
108 $exec_opts] != ""} {
109 untested "failed to compile"
110 return -1
111 }
112
113 clean_restart $binfile
114
115 set readnow_p [readnow]
116
117 # Don't load the symbols for $lib1 during runto_main.
118 # Instead, we do this afterwards using "sharedlibrary $lib1".
119 gdb_test_no_output "set auto-solib-add off"
120
121 if { ![runto_main] } {
122 fail "cannot run to main."
123 return -1
124 }
125
126 set complaint_re ".debug_${ranges_sect} entry has start address of zero"
127 set re \
128 "During symbol reading: $complaint_re \\\[in module \[^\r\n\]*\\\]"
129
130 # Test for presence of complaint, with lib1 relocated.
131 with_complaints 1 {
132 set test "Zero address complaint - relocated - psymtab"
133 set have_complaint 0
134 gdb_test_multiple "sharedlibrary $lib1" $test {
135 -re -wrap $re {
136 set have_complaint 1
137 }
138 -re -wrap "" {
139 }
140 }
141
142 if { $have_complaint } {
143 pass $test
144 } else {
145 set index [have_index $lib1]
146 if { $index == "gdb_index" } {
147 kfail symtab/28159 $test
148 } else {
149 fail $test
150 }
151 }
152 }
153
154 if { ! $readnow_p } {
155 with_complaints 1 {
156 gdb_test "maint expand-symtabs $srcfile2" $re \
157 "Zero address complaint - relocated - symtab"
158 }
159 }
160
161 clean_restart
162 # Test for presence of complaint, with lib1 unrelocated.
163 with_complaints 1 {
164 gdb_load $lib1
165 set test "Zero address complaint - unrelocated - psymtab"
166 set have_complaint [regexp $re.* $gdb_file_cmd_msg]
167 if { $have_complaint } {
168 pass $test
169 } else {
170 set index [have_index $lib1]
171 if { $index == "gdb_index" } {
172 kfail symtab/28159 $test
173 } else {
174 fail $test
175 }
176 }
177 }
178
179 if { ! $readnow_p } {
180 with_complaints 1 {
181 gdb_test "maint expand-symtabs $srcfile2" $re \
182 "Zero address complaint - unrelocated - symtab"
183 }
184 }
185}
This page took 0.062956 seconds and 4 git commands to generate.