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