]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | set testfile "info-macros" | |
17 | set srcfile ${testfile}.c | |
18 | set binfile ${objdir}/${subdir}/${testfile} | |
682c7f7b | 19 | |
9b158ba0 | 20 | get_compiler_info ${binfile} |
682c7f7b | 21 | if ![test_compiler_info gcc*] { |
9b158ba0 | 22 | untested ${testfile}.exp |
23 | return -1 | |
24 | } | |
25 | ||
682c7f7b DE |
26 | set options "debug additional_flags=-g3" |
27 | ||
9b158ba0 | 28 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } { |
29 | untested ${testfile}.exp | |
30 | return -1 | |
31 | } | |
32 | ||
33 | if ![runto_main] { | |
34 | untested ${testfile}.exp | |
35 | return -1 | |
36 | } | |
37 | ||
71eba9c2 | 38 | # Test various error messages. |
39 | gdb_test "info macro -- -all" \ | |
40 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ | |
41 | "info macro -- -all" | |
42 | gdb_test "info macro -- -all" \ | |
43 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ | |
44 | "info macro -- -all" | |
45 | ||
46 | gdb_test "info macro -all --" \ | |
47 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
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 --" \ | |
59 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
60 | "info macro --" | |
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 | gdb_test "info macro -- " \ | |
66 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
67 | "'info macro -- '" | |
68 | ||
69 | gdb_test "info macro -invalid-option" \ | |
70 | "Unrecognized option.*Try \"help info macro\"\." \ | |
71 | "info macro -invalid-option 1" | |
72 | ||
73 | gdb_test "info macro -invalid-option" \ | |
74 | "Unrecognized option.*Try \"help info macro\"\." \ | |
75 | "info macro -invalid-option" | |
76 | ||
77 | gdb_test "info macro -invalid-option FOO" \ | |
78 | "Unrecognized option.*Try \"help info macro\"\." \ | |
79 | "info macro -invalid-option FOO" | |
80 | gdb_test "info macro -invalid-option FOO" \ | |
81 | "Unrecognized option.*Try \"help info macro\"\." \ | |
82 | "info macro -invalid-option FOO" | |
83 | ||
84 | # Single macro lookups. | |
85 | gdb_test "info macro -- FOO" \ | |
86 | ".*#define FOO \"hello\"" \ | |
87 | "info macro -- FOO" | |
88 | ||
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 | # Multiple macro lookups. | |
106 | set test "info macro -a FOO" | |
9b158ba0 | 107 | set r1 ".*#define FOO \"hello\"" |
108 | set r2 ".*#define FOO \" \"" | |
109 | set r3 ".*#define FOO \"world\"" | |
110 | set r4 ".*#define FOO\\(a\\) foo = a" | |
111 | set testname "$test 1" | |
112 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
113 | ||
71eba9c2 | 114 | set test "info macro -a -- FOO" |
115 | set testname "$test 1" | |
116 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
117 | ||
118 | set test "info macro -all -- FOO" | |
119 | set testname "$test 1" | |
120 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
121 | ||
122 | set test "info macro -a -- FOO" | |
123 | set testname "$test" | |
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" | |
9b158ba0 | 129 | |
130 | set test "info macros" | |
131 | set r1 ".*#define FOO \"hello\"" | |
132 | set r2 ".*#define ONE" | |
133 | set r3 ".*\r\n$gdb_prompt" | |
134 | set testname "$test 2" | |
135 | gdb_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 | } | |
149 | gdb_test "next" ".*" "" | |
150 | ||
151 | set r1 ".*#define FOO \" \"" | |
152 | set r2 ".*#define ONE" | |
153 | set r3 ".*#define TWO" | |
154 | set r4 ".*\r\n$gdb_prompt" | |
71eba9c2 | 155 | set testname "$test 3" |
9b158ba0 | 156 | gdb_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 | } | |
167 | gdb_test "next" ".*" "" | |
168 | ||
169 | # in alpabetical order... | |
170 | set r1 ".*#define FOO \"world\"" | |
171 | set r2 ".*#define ONE" | |
172 | set r3 ".*#define THREE" | |
173 | set r4 ".*#define TWO" | |
174 | set r5 ".*\r\n$gdb_prompt" | |
175 | set testname "$test 4" | |
176 | gdb_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. | |
185 | set test "info macros *\$pc" | |
186 | gdb_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 | } | |
194 | gdb_test "next" ".*" "" | |
195 | ||
196 | set r1 ".*#define FOO \" \"" | |
197 | set r2 ".*#define ONE" | |
198 | set r3 ".*#define TWO." | |
199 | set r4 ".*\r\n$gdb_prompt" | |
9b158ba0 | 200 | set test "info macros" |
71eba9c2 | 201 | set testname "$test 5" |
9b158ba0 | 202 | gdb_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 | } | |
213 | gdb_test "next" ".*" "" | |
214 | gdb_test "next" ".*" "" | |
215 | ||
216 | set r1 ".*#define DEF_MACROS" | |
217 | set r2 ".*\r\n$gdb_prompt" | |
218 | set testname "$test 6" | |
219 | gdb_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 | ||
249 | gdb_test "next" ".*" "" | |
250 | set r1 ".*#define DEF_MACROS" | |
251 | set r2 ".*#define FOO\\(a\\) foo = a" | |
252 | set r3 ".*#define FOUR" | |
253 | set r4 ".*\r\n$gdb_prompt" | |
254 | set testname "$test 7" | |
255 | gdb_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 | ||
279 | set test "info macros info-macros.c:42" | |
280 | ||
281 | set r1 ".*define DEF_MACROS" | |
282 | set 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.) | |
285 | setup_kfail "gdb/NNNN" *-*-* | |
286 | gdb_test "$test" "$r1$r2" "$test" |