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