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