1 # Copyright 2019-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/>.
18 if {[test_compiler_info gcc*] && ![supports_statement_frontiers] } {
22 # Compile the test source with USE_NEXT_INLINE_H defined (when
23 # use_header is true), or not defined.
24 proc do_test { use_header } {
25 global srcfile testfile
28 # This test will not pass due to poor debug information
29 # generated by GCC (at least upto 10.x). See
30 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
34 set options {c++ debug nowarnings optimize=-O2}
35 if { [supports_statement_frontiers] } {
36 lappend options additional_flags=-gstatement-frontiers
39 lappend options additional_flags=-DUSE_NEXT_INLINE_H
40 set executable "$testfile-with-header"
41 set hdrfile "step-and-next-inline.h"
42 set prefix "use_header"
44 set executable "$testfile-no-header"
45 set hdrfile "$srcfile"
46 set prefix "no_header"
49 if { [prepare_for_testing "failed to prepare" $executable \
50 $srcfile $options] } {
54 with_test_prefix $prefix {
56 set main_location [gdb_get_line_number "Beginning of main" $srcfile]
58 if ![runto $main_location qualified] {
62 gdb_test "bt" "\\s*\\#0\\s+main.*" "in main"
64 set line2 {\t if \(t != NULL}
65 gdb_test_multiple "step" "step into get_alias_set" {
67 gdb_test "next" $line2 $gdb_test_name
73 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
76 # It's possible that this first failure (when not using a header
77 # file) is GCC's fault, though the remaining failures would best
78 # be fixed by adding location views support (though it could be
79 # that some easier heuristic could be figured out). Still, it is
80 # not certain that the first failure wouldn't also be fixed by
81 # having location view support, so for now it is tagged as such.
82 set have_kfail [expr [test_compiler_info gcc*] && !$use_header]
85 gdb_test_multiple "next" "next step 1" {
86 -re -wrap "if \\(t->x != i\\)" {
91 -re -wrap ".*TREE_TYPE.* != 1" {
96 setup_kfail "*-*-*" symtab/25507
102 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
106 gdb_test_multiple "next" "next step 2" {
107 -re -wrap "return x;" {
112 -re -wrap ".*TREE_TYPE.* != 2" {
117 setup_kfail "*-*-*" symtab/25507
123 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
127 gdb_test_multiple "next" "next step 3" {
128 -re -wrap "return x;" {
133 -re -wrap ".*TREE_TYPE.* != 3\\)" {
138 setup_kfail "*-*-*" symtab/25507
144 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
148 gdb_test_multiple "next" "next step 4" {
149 -re -wrap "(if \\(t != NULL|\} // get_alias_set)" {
153 -re -wrap "return x;" {
158 -re -wrap "return 0.*" {
163 setup_kfail "*-*-*" symtab/25507
170 "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
174 # With the debug from GCC 10.x (and earlier) GDB is currently
175 # unable to successfully complete the following tests when we
176 # are not using a header file.
177 kfail symtab/25507 "stepping tests"
181 clean_restart ${executable}
187 gdb_test "bt" "\\s*\\#0\\s+main.*" "in main pass 2"
188 gdb_test "step" ".*" "step into get_alias_set pass 2"
189 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
190 "in get_alias_set pass 2"
191 gdb_test "step" ".*TREE_TYPE.*" "step 1"
192 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
193 "not in inline 1 pass 2"
194 gdb_test "step" ".*if \\(t->x != i\\).*" "step 2"
195 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
197 gdb_test "step" ".*TREE_TYPE.*" "step 3"
198 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
199 "not in inline 2 pass 2"
200 gdb_test "step" ".*if \\(t->x != i\\).*" "step 4"
201 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
203 gdb_test "step" ".*TREE_TYPE.*" "step 5"
204 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
205 "not in inline 3 pass 2"
206 gdb_test "step" ".*if \\(t->x != i\\).*" "step 6"
207 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
209 gdb_test "step" "return 0.*" "step 7"
211 "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
212 "not in inline 4 pass 2"