Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2011-2020 Free Software Foundation, Inc. |
9b158ba0 | 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 | ||
f8b41b00 | 16 | standard_testfile .c |
682c7f7b | 17 | |
a587b477 DE |
18 | # Fission doesn't support macros yet. Bug 15954. |
19 | if [using_fission] { | |
5b362f04 | 20 | untested "fission does not support macros yet" |
a587b477 DE |
21 | return -1 |
22 | } | |
23 | ||
4c93b1db | 24 | get_compiler_info |
682c7f7b | 25 | if ![test_compiler_info gcc*] { |
5b362f04 | 26 | untested "no compiler info" |
9b158ba0 | 27 | return -1 |
28 | } | |
29 | ||
78466714 AA |
30 | # Don't use "debug" here. Otherwise "-g" would be appended to the gcc |
31 | # command line, possibly overriding "-g3" (depending on gcc version). | |
32 | set options "additional_flags=-g3" | |
682c7f7b | 33 | |
5b362f04 | 34 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] } { |
9b158ba0 | 35 | return -1 |
36 | } | |
37 | ||
38 | if ![runto_main] { | |
5b362f04 | 39 | untested "could not run to main" |
9b158ba0 | 40 | return -1 |
41 | } | |
42 | ||
71eba9c2 | 43 | # Test various error messages. |
44 | gdb_test "info macro -- -all" \ | |
11af934b | 45 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" |
71eba9c2 | 46 | gdb_test "info macro -- -all" \ |
11af934b | 47 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" |
71eba9c2 | 48 | |
49 | gdb_test "info macro -all --" \ | |
11af934b | 50 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 51 | |
52 | gdb_test "info macro -all --" \ | |
11af934b | 53 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 54 | |
55 | gdb_test "info macro -all --" \ | |
11af934b | 56 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 57 | |
58 | gdb_test "info macro --" \ | |
11af934b | 59 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 60 | |
61 | gdb_test "info macro -- " \ | |
11af934b | 62 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 63 | gdb_test "info macro -- " \ |
11af934b | 64 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" |
71eba9c2 | 65 | |
66 | gdb_test "info macro -invalid-option" \ | |
11af934b | 67 | "Unrecognized option.*Try \"help info macro\"\." |
71eba9c2 | 68 | |
69 | gdb_test "info macro -invalid-option" \ | |
11af934b | 70 | "Unrecognized option.*Try \"help info macro\"\." |
71eba9c2 | 71 | |
72 | gdb_test "info macro -invalid-option FOO" \ | |
11af934b | 73 | "Unrecognized option.*Try \"help info macro\"\." |
71eba9c2 | 74 | gdb_test "info macro -invalid-option FOO" \ |
11af934b | 75 | "Unrecognized option.*Try \"help info macro\"\." |
71eba9c2 | 76 | |
77 | # Single macro lookups. | |
78 | gdb_test "info macro -- FOO" \ | |
11af934b | 79 | ".*#define FOO \"hello\"" |
71eba9c2 | 80 | |
81 | gdb_test "info macro -- FOO" \ | |
11af934b | 82 | ".*#define FOO \"hello\"" |
71eba9c2 | 83 | |
84 | gdb_test "info macro -- FOO" \ | |
11af934b | 85 | ".*#define FOO \"hello\"" |
71eba9c2 | 86 | |
87 | gdb_test "info macro FOO" \ | |
11af934b | 88 | ".*#define FOO \"hello\"" |
71eba9c2 | 89 | |
90 | gdb_test "info macro FOO" \ | |
11af934b | 91 | ".*#define FOO \"hello\"" |
71eba9c2 | 92 | |
93 | # Multiple macro lookups. | |
94 | set test "info macro -a FOO" | |
9b158ba0 | 95 | set r1 ".*#define FOO \"hello\"" |
96 | set r2 ".*#define FOO \" \"" | |
97 | set r3 ".*#define FOO \"world\"" | |
98 | set r4 ".*#define FOO\\(a\\) foo = a" | |
99 | set testname "$test 1" | |
100 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
101 | ||
71eba9c2 | 102 | set test "info macro -a -- FOO" |
103 | set testname "$test 1" | |
104 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
105 | ||
106 | set test "info macro -all -- FOO" | |
107 | set testname "$test 1" | |
108 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
109 | ||
110 | set test "info macro -a -- FOO" | |
11af934b | 111 | gdb_test "$test" "$r1$r2$r3$r4" |
71eba9c2 | 112 | |
113 | set test "info macro -a -- FOO" | |
11af934b | 114 | gdb_test "$test" "$r1$r2$r3$r4" |
9b158ba0 | 115 | |
d86bd7cb TV |
116 | proc gdb_test_multiple_with_read1_timeout_factor { factor command message \ |
117 | user_code } { | |
118 | with_read1_timeout_factor $factor { | |
119 | uplevel [list gdb_test_multiple $command $message $user_code] | |
120 | } | |
121 | } | |
122 | ||
9b158ba0 | 123 | set test "info macros" |
124 | set r1 ".*#define FOO \"hello\"" | |
125 | set r2 ".*#define ONE" | |
126 | set r3 ".*\r\n$gdb_prompt" | |
127 | set testname "$test 2" | |
d86bd7cb | 128 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { |
9b158ba0 | 129 | -re "$r1$r2$r3" { |
130 | pass $testname | |
131 | } | |
132 | -re ".*#define TWO.*\r\n$gdb_prompt" { | |
133 | fail $testname | |
134 | } | |
135 | -re ".*#define THREE.*\r\n$gdb_prompt" { | |
136 | fail $testname | |
137 | } | |
138 | -re ".*#define FOUR.*\r\n$gdb_prompt" { | |
139 | fail $testname | |
140 | } | |
141 | } | |
142 | gdb_test "next" ".*" "" | |
143 | ||
144 | set r1 ".*#define FOO \" \"" | |
145 | set r2 ".*#define ONE" | |
146 | set r3 ".*#define TWO" | |
147 | set r4 ".*\r\n$gdb_prompt" | |
71eba9c2 | 148 | set testname "$test 3" |
d86bd7cb | 149 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { |
9b158ba0 | 150 | -re ".*#define THREE.*\r\n$gdb_prompt" { |
151 | fail $testname | |
152 | } | |
153 | -re ".*#define FOUR.*\r\n$gdb_prompt" { | |
154 | fail $testname | |
155 | } | |
156 | -re "$r1$r2$r3$r4" { | |
157 | pass $testname | |
158 | } | |
159 | } | |
160 | gdb_test "next" ".*" "" | |
161 | ||
162 | # in alpabetical order... | |
163 | set r1 ".*#define FOO \"world\"" | |
164 | set r2 ".*#define ONE" | |
165 | set r3 ".*#define THREE" | |
166 | set r4 ".*#define TWO" | |
167 | set r5 ".*\r\n$gdb_prompt" | |
168 | set testname "$test 4" | |
d86bd7cb | 169 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { |
9b158ba0 | 170 | -re ".*#define FOUR.*\r\n$gdb_prompt" { |
171 | fail $testname | |
172 | } | |
173 | -re "$r1$r2$r3$r4$r5" { | |
174 | pass $testname | |
175 | } | |
176 | } | |
177 | # same as above with a linespec. | |
178 | set test "info macros *\$pc" | |
d86bd7cb | 179 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test { |
9b158ba0 | 180 | -re ".*#define FOUR.*\r\n$gdb_prompt" { |
181 | fail $test | |
182 | } | |
183 | -re "$r1$r2$r3$r4$r5" { | |
184 | pass $test | |
185 | } | |
186 | } | |
187 | gdb_test "next" ".*" "" | |
188 | ||
189 | set r1 ".*#define FOO \" \"" | |
190 | set r2 ".*#define ONE" | |
191 | set r3 ".*#define TWO." | |
192 | set r4 ".*\r\n$gdb_prompt" | |
9b158ba0 | 193 | set test "info macros" |
71eba9c2 | 194 | set testname "$test 5" |
d86bd7cb | 195 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test { |
9b158ba0 | 196 | -re ".*#define THREE.*\r\n$gdb_prompt" { |
197 | fail $testname | |
198 | } | |
199 | -re ".*#define FOUR.*\r\n$gdb_prompt" { | |
200 | fail $testname | |
201 | } | |
202 | -re "$r1$r2$r3$r4" { | |
203 | pass $testname | |
204 | } | |
205 | } | |
206 | gdb_test "next" ".*" "" | |
207 | gdb_test "next" ".*" "" | |
208 | ||
209 | set r1 ".*#define DEF_MACROS" | |
210 | set r2 ".*\r\n$gdb_prompt" | |
211 | set testname "$test 6" | |
d86bd7cb | 212 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { |
9b158ba0 | 213 | -re ".*#define FOO \" \".*\r\n$gdb_prompt" { |
214 | fail $testname | |
215 | } | |
216 | -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { | |
217 | fail $testname | |
218 | } | |
219 | -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { | |
220 | fail $testname | |
221 | } | |
222 | -re ".*#define FOO\\(a\\) foo = a.*" { | |
223 | fail $testname | |
224 | } | |
225 | -re ".*#define ONE.*\r\n$gdb_prompt" { | |
226 | fail $testname | |
227 | } | |
228 | -re ".*#define TWO.*\r\n$gdb_prompt" { | |
229 | fail $testname | |
230 | } | |
231 | -re ".*#define THREE.*\r\n$gdb_prompt" { | |
232 | fail $testname | |
233 | } | |
234 | -re ".*#define FOUR.*\r\n$gdb_prompt" { | |
235 | fail $testname | |
236 | } | |
237 | -re "$r1$r2" { | |
238 | pass $testname | |
239 | } | |
240 | } | |
241 | ||
242 | gdb_test "next" ".*" "" | |
243 | set r1 ".*#define DEF_MACROS" | |
244 | set r2 ".*#define FOO\\(a\\) foo = a" | |
245 | set r3 ".*#define FOUR" | |
246 | set r4 ".*\r\n$gdb_prompt" | |
247 | set testname "$test 7" | |
d86bd7cb | 248 | gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { |
9b158ba0 | 249 | -re ".*#define FOO \" \".*\r\n$gdb_prompt" { |
250 | fail $testname | |
251 | } | |
252 | -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { | |
253 | fail $testname | |
254 | } | |
255 | -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { | |
256 | fail $testname | |
257 | } | |
258 | -re ".*#define ONE.*\r\n$gdb_prompt" { | |
259 | fail $testname | |
260 | } | |
261 | -re ".*#define TWO.*\r\n$gdb_prompt" { | |
262 | fail $testname | |
263 | } | |
264 | -re ".*#define THREE.*\r\n$gdb_prompt" { | |
265 | fail $testname | |
266 | } | |
267 | -re "$r1$r2$r3$r4" { | |
268 | pass $testname | |
269 | } | |
270 | } | |
271 | ||
272 | set test "info macros info-macros.c:42" | |
273 | ||
274 | set r1 ".*define DEF_MACROS" | |
275 | set r2 ".*define ONE" | |
276 | # info macros on the line where the #define or #include is | |
277 | # fails to find the macro defined (though it works on the next line.) | |
278 | setup_kfail "gdb/NNNN" *-*-* | |
11af934b | 279 | gdb_test "$test" "$r1$r2" |