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