blob: 82abff3f146a2ba04ef6e7e6b81f15215a6ef79b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
# Copyright 2019-2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile .cc
if [get_compiler_info "c++"] {
unsupported "couldn't find a valid c++ compiler"
return -1
}
if {[test_compiler_info gcc*] && ![supports_statement_frontiers] } {
return -1
}
# Compile the test source with USE_NEXT_INLINE_H defined (when
# use_header is true), or not defined.
proc do_test { use_header } {
global srcfile testfile
if { $use_header } {
# This test will not pass due to poor debug information
# generated by GCC (at least upto 10.x). See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
return
}
set options {c++ debug nowarnings optimize=-O2}
if { [supports_statement_frontiers] } {
lappend options additional_flags=-gstatement-frontiers
}
if { $use_header } {
lappend options additional_flags=-DUSE_NEXT_INLINE_H
set executable "$testfile-with-header"
set hdrfile "step-and-next-inline.h"
set prefix "use_header"
} else {
set executable "$testfile-no-header"
set hdrfile "$srcfile"
set prefix "no_header"
}
if { [prepare_for_testing "failed to prepare" $executable \
$srcfile $options] } {
return -1
}
with_test_prefix $prefix {
set main_location [gdb_get_line_number "Beginning of main" $srcfile]
if ![runto $main_location qualified] {
return
}
gdb_test "bt" "\\s*\\#0\\s+main.*" "in main"
gdb_test "step" ".*" "step into get_alias_set"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 1"
# It's possible that this first failure (when not using a header
# file) is GCC's fault, though the remaining failures would best
# be fixed by adding location views support (though it could be
# that some easier heuristic could be figured out). Still, it is
# not certain that the first failure wouldn't also be fixed by
# having location view support, so for now it is tagged as such.
set have_kfail [expr [test_compiler_info gcc*] && !$use_header]
set ok 1
gdb_test_multiple "next" "next step 1" {
-re -wrap "if \\(t->x != i\\)" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 1" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 2"
set ok 1
gdb_test_multiple "next" "next step 2" {
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 2" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 3"
set ok 1
gdb_test_multiple "next" "next step 3" {
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 3\\)" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 4"
set ok 1
gdb_test_multiple "next" "next step 4" {
-re -wrap "(if \\(t != NULL|\} // get_alias_set)" {
send_gdb "next\n"
exp_continue
}
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap "return 0.*" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" \
"\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
"not in inline 5"
if {!$use_header} {
# With the debug from GCC 10.x (and earlier) GDB is currently
# unable to successfully complete the following tests when we
# are not using a header file.
kfail symtab/25507 "stepping tests"
return
}
clean_restart ${executable}
if ![runto_main] {
return
}
gdb_test "bt" "\\s*\\#0\\s+main.*" "in main pass 2"
gdb_test "step" ".*" "step into get_alias_set pass 2"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"in get_alias_set pass 2"
gdb_test "step" ".*TREE_TYPE.*" "step 1"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 1 pass 2"
gdb_test "step" ".*if \\(t->x != i\\).*" "step 2"
gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
"in inline 1 pass 2"
gdb_test "step" ".*TREE_TYPE.*" "step 3"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 2 pass 2"
gdb_test "step" ".*if \\(t->x != i\\).*" "step 4"
gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
"in inline 2 pass 2"
gdb_test "step" ".*TREE_TYPE.*" "step 5"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 3 pass 2"
gdb_test "step" ".*if \\(t->x != i\\).*" "step 6"
gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
"in inline 3 pass 2"
gdb_test "step" "return 0.*" "step 7"
gdb_test "bt" \
"\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
"not in inline 4 pass 2"
}
}
do_test 0
do_test 1
|