[gdb/testsuite] Capture many-headers.exp progress and output in gdb.log
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info-macros.exp
1 # Copyright 2011-2020 Free Software Foundation, Inc.
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 .c
17
18 # Fission doesn't support macros yet. Bug 15954.
19 if [using_fission] {
20 untested "fission does not support macros yet"
21 return -1
22 }
23
24 get_compiler_info
25 if ![test_compiler_info gcc*] {
26 untested "no compiler info"
27 return -1
28 }
29
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"
33
34 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] } {
35 return -1
36 }
37
38 if ![runto_main] {
39 untested "could not run to main"
40 return -1
41 }
42
43 # Test various error messages.
44 gdb_test "info macro -- -all" \
45 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
46 gdb_test "info macro -- -all" \
47 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
48
49 gdb_test "info macro -all --" \
50 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
51
52 gdb_test "info macro -all --" \
53 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
54
55 gdb_test "info macro -all --" \
56 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
57
58 gdb_test "info macro --" \
59 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
60
61 gdb_test "info macro -- " \
62 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
63 gdb_test "info macro -- " \
64 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
65
66 gdb_test "info macro -invalid-option" \
67 "Unrecognized option.*Try \"help info macro\"\."
68
69 gdb_test "info macro -invalid-option" \
70 "Unrecognized option.*Try \"help info macro\"\."
71
72 gdb_test "info macro -invalid-option FOO" \
73 "Unrecognized option.*Try \"help info macro\"\."
74 gdb_test "info macro -invalid-option FOO" \
75 "Unrecognized option.*Try \"help info macro\"\."
76
77 # Single macro lookups.
78 gdb_test "info macro -- FOO" \
79 ".*#define FOO \"hello\""
80
81 gdb_test "info macro -- FOO" \
82 ".*#define FOO \"hello\""
83
84 gdb_test "info macro -- FOO" \
85 ".*#define FOO \"hello\""
86
87 gdb_test "info macro FOO" \
88 ".*#define FOO \"hello\""
89
90 gdb_test "info macro FOO" \
91 ".*#define FOO \"hello\""
92
93 # Multiple macro lookups.
94 set test "info macro -a FOO"
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
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"
111 gdb_test "$test" "$r1$r2$r3$r4"
112
113 set test "info macro -a -- FOO"
114 gdb_test "$test" "$r1$r2$r3$r4"
115
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
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"
128 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
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"
148 set testname "$test 3"
149 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
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"
169 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
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"
179 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
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"
193 set test "info macros"
194 set testname "$test 5"
195 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
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"
212 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
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"
248 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
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" *-*-*
279 gdb_test "$test" "$r1$r2"
This page took 0.047443 seconds and 4 git commands to generate.