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