warn if "source" fails to open the file when from_tty == 0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info-macros.exp
1 # Copyright 2011-2013 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 ${testfile}.exp
21 return -1
22 }
23
24 get_compiler_info
25 if ![test_compiler_info gcc*] {
26 untested ${testfile}.exp
27 return -1
28 }
29
30 set options "debug additional_flags=-g3"
31
32 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } {
33 untested ${testfile}.exp
34 return -1
35 }
36
37 if ![runto_main] {
38 untested ${testfile}.exp
39 return -1
40 }
41
42 # Test various error messages.
43 gdb_test "info macro -- -all" \
44 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
45 "info macro -- -all"
46 gdb_test "info macro -- -all" \
47 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
48 "info macro -- -all"
49
50 gdb_test "info macro -all --" \
51 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
52 "info macro -all --"
53
54 gdb_test "info macro -all --" \
55 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
56 "info macro -all --"
57
58 gdb_test "info macro -all --" \
59 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
60 "info macro -all --"
61
62 gdb_test "info macro --" \
63 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
64 "info macro --"
65
66 gdb_test "info macro -- " \
67 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
68 "'info macro -- '"
69 gdb_test "info macro -- " \
70 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
71 "'info macro -- '"
72
73 gdb_test "info macro -invalid-option" \
74 "Unrecognized option.*Try \"help info macro\"\." \
75 "info macro -invalid-option 1"
76
77 gdb_test "info macro -invalid-option" \
78 "Unrecognized option.*Try \"help info macro\"\." \
79 "info macro -invalid-option"
80
81 gdb_test "info macro -invalid-option FOO" \
82 "Unrecognized option.*Try \"help info macro\"\." \
83 "info macro -invalid-option FOO"
84 gdb_test "info macro -invalid-option FOO" \
85 "Unrecognized option.*Try \"help info macro\"\." \
86 "info macro -invalid-option FOO"
87
88 # Single macro lookups.
89 gdb_test "info macro -- FOO" \
90 ".*#define FOO \"hello\"" \
91 "info macro -- FOO"
92
93 gdb_test "info macro -- FOO" \
94 ".*#define FOO \"hello\"" \
95 "info macro -- FOO"
96
97 gdb_test "info macro -- FOO" \
98 ".*#define FOO \"hello\"" \
99 "info macro -- FOO"
100
101 gdb_test "info macro FOO" \
102 ".*#define FOO \"hello\"" \
103 "info macro FOO"
104
105 gdb_test "info macro FOO" \
106 ".*#define FOO \"hello\"" \
107 "info macro FOO"
108
109 # Multiple macro lookups.
110 set test "info macro -a FOO"
111 set r1 ".*#define FOO \"hello\""
112 set r2 ".*#define FOO \" \""
113 set r3 ".*#define FOO \"world\""
114 set r4 ".*#define FOO\\(a\\) foo = a"
115 set testname "$test 1"
116 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
117
118 set test "info macro -a -- FOO"
119 set testname "$test 1"
120 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
121
122 set test "info macro -all -- FOO"
123 set testname "$test 1"
124 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
125
126 set test "info macro -a -- FOO"
127 set testname "$test"
128 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
129
130 set test "info macro -a -- FOO"
131 set testname "$test"
132 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
133
134 set test "info macros"
135 set r1 ".*#define FOO \"hello\""
136 set r2 ".*#define ONE"
137 set r3 ".*\r\n$gdb_prompt"
138 set testname "$test 2"
139 gdb_test_multiple "$test" $testname {
140 -re "$r1$r2$r3" {
141 pass $testname
142 }
143 -re ".*#define TWO.*\r\n$gdb_prompt" {
144 fail $testname
145 }
146 -re ".*#define THREE.*\r\n$gdb_prompt" {
147 fail $testname
148 }
149 -re ".*#define FOUR.*\r\n$gdb_prompt" {
150 fail $testname
151 }
152 }
153 gdb_test "next" ".*" ""
154
155 set r1 ".*#define FOO \" \""
156 set r2 ".*#define ONE"
157 set r3 ".*#define TWO"
158 set r4 ".*\r\n$gdb_prompt"
159 set testname "$test 3"
160 gdb_test_multiple "$test" $testname {
161 -re ".*#define THREE.*\r\n$gdb_prompt" {
162 fail $testname
163 }
164 -re ".*#define FOUR.*\r\n$gdb_prompt" {
165 fail $testname
166 }
167 -re "$r1$r2$r3$r4" {
168 pass $testname
169 }
170 }
171 gdb_test "next" ".*" ""
172
173 # in alpabetical order...
174 set r1 ".*#define FOO \"world\""
175 set r2 ".*#define ONE"
176 set r3 ".*#define THREE"
177 set r4 ".*#define TWO"
178 set r5 ".*\r\n$gdb_prompt"
179 set testname "$test 4"
180 gdb_test_multiple "$test" $testname {
181 -re ".*#define FOUR.*\r\n$gdb_prompt" {
182 fail $testname
183 }
184 -re "$r1$r2$r3$r4$r5" {
185 pass $testname
186 }
187 }
188 # same as above with a linespec.
189 set test "info macros *\$pc"
190 gdb_test_multiple "$test" $test {
191 -re ".*#define FOUR.*\r\n$gdb_prompt" {
192 fail $test
193 }
194 -re "$r1$r2$r3$r4$r5" {
195 pass $test
196 }
197 }
198 gdb_test "next" ".*" ""
199
200 set r1 ".*#define FOO \" \""
201 set r2 ".*#define ONE"
202 set r3 ".*#define TWO."
203 set r4 ".*\r\n$gdb_prompt"
204 set test "info macros"
205 set testname "$test 5"
206 gdb_test_multiple "$test" $test {
207 -re ".*#define THREE.*\r\n$gdb_prompt" {
208 fail $testname
209 }
210 -re ".*#define FOUR.*\r\n$gdb_prompt" {
211 fail $testname
212 }
213 -re "$r1$r2$r3$r4" {
214 pass $testname
215 }
216 }
217 gdb_test "next" ".*" ""
218 gdb_test "next" ".*" ""
219
220 set r1 ".*#define DEF_MACROS"
221 set r2 ".*\r\n$gdb_prompt"
222 set testname "$test 6"
223 gdb_test_multiple "$test" $testname {
224 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
225 fail $testname
226 }
227 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
228 fail $testname
229 }
230 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
231 fail $testname
232 }
233 -re ".*#define FOO\\(a\\) foo = a.*" {
234 fail $testname
235 }
236 -re ".*#define ONE.*\r\n$gdb_prompt" {
237 fail $testname
238 }
239 -re ".*#define TWO.*\r\n$gdb_prompt" {
240 fail $testname
241 }
242 -re ".*#define THREE.*\r\n$gdb_prompt" {
243 fail $testname
244 }
245 -re ".*#define FOUR.*\r\n$gdb_prompt" {
246 fail $testname
247 }
248 -re "$r1$r2" {
249 pass $testname
250 }
251 }
252
253 gdb_test "next" ".*" ""
254 set r1 ".*#define DEF_MACROS"
255 set r2 ".*#define FOO\\(a\\) foo = a"
256 set r3 ".*#define FOUR"
257 set r4 ".*\r\n$gdb_prompt"
258 set testname "$test 7"
259 gdb_test_multiple "$test" $testname {
260 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
261 fail $testname
262 }
263 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
264 fail $testname
265 }
266 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
267 fail $testname
268 }
269 -re ".*#define ONE.*\r\n$gdb_prompt" {
270 fail $testname
271 }
272 -re ".*#define TWO.*\r\n$gdb_prompt" {
273 fail $testname
274 }
275 -re ".*#define THREE.*\r\n$gdb_prompt" {
276 fail $testname
277 }
278 -re "$r1$r2$r3$r4" {
279 pass $testname
280 }
281 }
282
283 set test "info macros info-macros.c:42"
284
285 set r1 ".*define DEF_MACROS"
286 set r2 ".*define ONE"
287 # info macros on the line where the #define or #include is
288 # fails to find the macro defined (though it works on the next line.)
289 setup_kfail "gdb/NNNN" *-*-*
290 gdb_test "$test" "$r1$r2" "$test"
This page took 0.039523 seconds and 4 git commands to generate.