]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2019-2024 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 | ||
16 | standard_testfile .cc | |
17 | ||
eb24648c | 18 | if {[test_compiler_info gcc*] && ![supports_statement_frontiers] } { |
2ac70237 TV |
19 | return -1 |
20 | } | |
21 | ||
8c95582d AB |
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 | |
26 | ||
1313c56e AB |
27 | if { $use_header } { |
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 | |
31 | return | |
32 | } | |
33 | ||
eb24648c GB |
34 | set options {c++ debug nowarnings optimize=-O2} |
35 | if { [supports_statement_frontiers] } { | |
4ff509e7 | 36 | lappend options additional_flags=-gstatement-frontiers |
eb24648c | 37 | } |
8c95582d AB |
38 | if { $use_header } { |
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" | |
43 | } else { | |
44 | set executable "$testfile-no-header" | |
45 | set hdrfile "$srcfile" | |
46 | set prefix "no_header" | |
47 | } | |
48 | ||
49 | if { [prepare_for_testing "failed to prepare" $executable \ | |
50 | $srcfile $options] } { | |
51 | return -1 | |
52 | } | |
53 | ||
54 | with_test_prefix $prefix { | |
55 | ||
e3e4224e CL |
56 | set main_location [gdb_get_line_number "Beginning of main" $srcfile] |
57 | ||
58 | if ![runto $main_location qualified] { | |
8c95582d AB |
59 | return |
60 | } | |
61 | ||
62 | gdb_test "bt" "\\s*\\#0\\s+main.*" "in main" | |
b1b0f69c TV |
63 | set line1 {\t\{} |
64 | set line2 {\t if \(t != NULL} | |
65 | gdb_test_multiple "step" "step into get_alias_set" { | |
66 | -re -wrap $line1 { | |
67 | gdb_test "next" $line2 $gdb_test_name | |
68 | } | |
69 | -re -wrap $line2 { | |
70 | pass $gdb_test_name | |
71 | } | |
72 | } | |
8c95582d AB |
73 | gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \ |
74 | "not in inline 1" | |
5f335689 | 75 | |
8c95582d AB |
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. | |
5f335689 TV |
82 | set have_kfail [expr [test_compiler_info gcc*] && !$use_header] |
83 | ||
84 | set ok 1 | |
85 | gdb_test_multiple "next" "next step 1" { | |
86 | -re -wrap "if \\(t->x != i\\)" { | |
87 | set ok 0 | |
88 | send_gdb "next\n" | |
89 | exp_continue | |
90 | } | |
91 | -re -wrap ".*TREE_TYPE.* != 1" { | |
92 | if { $ok } { | |
93 | pass $gdb_test_name | |
94 | } else { | |
95 | if { $have_kfail } { | |
96 | setup_kfail "*-*-*" symtab/25507 | |
97 | } | |
98 | fail $gdb_test_name | |
99 | } | |
100 | } | |
eb24648c | 101 | } |
8c95582d AB |
102 | gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \ |
103 | "not in inline 2" | |
5f335689 TV |
104 | |
105 | set ok 1 | |
106 | gdb_test_multiple "next" "next step 2" { | |
107 | -re -wrap "return x;" { | |
108 | set ok 0 | |
109 | send_gdb "next\n" | |
110 | exp_continue | |
111 | } | |
112 | -re -wrap ".*TREE_TYPE.* != 2" { | |
113 | if { $ok } { | |
114 | pass $gdb_test_name | |
115 | } else { | |
116 | if { $have_kfail } { | |
117 | setup_kfail "*-*-*" symtab/25507 | |
118 | } | |
119 | fail $gdb_test_name | |
120 | } | |
121 | } | |
122 | } | |
8c95582d AB |
123 | gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \ |
124 | "not in inline 3" | |
5f335689 TV |
125 | |
126 | set ok 1 | |
127 | gdb_test_multiple "next" "next step 3" { | |
128 | -re -wrap "return x;" { | |
129 | set ok 0 | |
130 | send_gdb "next\n" | |
131 | exp_continue | |
132 | } | |
133 | -re -wrap ".*TREE_TYPE.* != 3\\)" { | |
134 | if { $ok } { | |
135 | pass $gdb_test_name | |
136 | } else { | |
137 | if { $have_kfail } { | |
138 | setup_kfail "*-*-*" symtab/25507 | |
139 | } | |
140 | fail $gdb_test_name | |
141 | } | |
142 | } | |
eb24648c | 143 | } |
8c95582d AB |
144 | gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \ |
145 | "not in inline 4" | |
5f335689 TV |
146 | |
147 | set ok 1 | |
148 | gdb_test_multiple "next" "next step 4" { | |
149 | -re -wrap "(if \\(t != NULL|\} // get_alias_set)" { | |
150 | send_gdb "next\n" | |
151 | exp_continue | |
152 | } | |
153 | -re -wrap "return x;" { | |
154 | set ok 0 | |
155 | send_gdb "next\n" | |
156 | exp_continue | |
157 | } | |
158 | -re -wrap "return 0.*" { | |
159 | if { $ok } { | |
160 | pass $gdb_test_name | |
161 | } else { | |
162 | if { $have_kfail } { | |
163 | setup_kfail "*-*-*" symtab/25507 | |
164 | } | |
165 | fail $gdb_test_name | |
166 | } | |
167 | } | |
168 | } | |
8c95582d AB |
169 | gdb_test "bt" \ |
170 | "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \ | |
171 | "not in inline 5" | |
172 | ||
173 | if {!$use_header} { | |
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" | |
178 | return | |
179 | } | |
180 | ||
181 | clean_restart ${executable} | |
182 | ||
183 | if ![runto_main] { | |
8c95582d AB |
184 | return |
185 | } | |
186 | ||
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}:.*" \ | |
196 | "in inline 1 pass 2" | |
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}:.*" \ | |
202 | "in inline 2 pass 2" | |
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}:.*" \ | |
208 | "in inline 3 pass 2" | |
209 | gdb_test "step" "return 0.*" "step 7" | |
210 | gdb_test "bt" \ | |
211 | "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \ | |
212 | "not in inline 4 pass 2" | |
213 | } | |
214 | } | |
215 | ||
216 | do_test 0 | |
217 | do_test 1 |