]>
Commit | Line | Data |
---|---|---|
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 | 16 | standard_testfile .c |
682c7f7b | 17 | |
4c93b1db | 18 | get_compiler_info |
682c7f7b | 19 | if ![test_compiler_info gcc*] { |
9b158ba0 | 20 | untested ${testfile}.exp |
21 | return -1 | |
22 | } | |
23 | ||
682c7f7b DE |
24 | set options "debug additional_flags=-g3" |
25 | ||
9b158ba0 | 26 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } { |
27 | untested ${testfile}.exp | |
28 | return -1 | |
29 | } | |
30 | ||
31 | if ![runto_main] { | |
32 | untested ${testfile}.exp | |
33 | return -1 | |
34 | } | |
35 | ||
71eba9c2 | 36 | # Test various error messages. |
37 | gdb_test "info macro -- -all" \ | |
38 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ | |
39 | "info macro -- -all" | |
40 | gdb_test "info macro -- -all" \ | |
41 | "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ | |
42 | "info macro -- -all" | |
43 | ||
44 | gdb_test "info macro -all --" \ | |
45 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
46 | "info macro -all --" | |
47 | ||
48 | gdb_test "info macro -all --" \ | |
49 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
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 --" \ | |
57 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
58 | "info macro --" | |
59 | ||
60 | gdb_test "info macro -- " \ | |
61 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
62 | "'info macro -- '" | |
63 | gdb_test "info macro -- " \ | |
64 | "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ | |
65 | "'info macro -- '" | |
66 | ||
67 | gdb_test "info macro -invalid-option" \ | |
68 | "Unrecognized option.*Try \"help info macro\"\." \ | |
69 | "info macro -invalid-option 1" | |
70 | ||
71 | gdb_test "info macro -invalid-option" \ | |
72 | "Unrecognized option.*Try \"help info macro\"\." \ | |
73 | "info macro -invalid-option" | |
74 | ||
75 | gdb_test "info macro -invalid-option FOO" \ | |
76 | "Unrecognized option.*Try \"help info macro\"\." \ | |
77 | "info macro -invalid-option FOO" | |
78 | gdb_test "info macro -invalid-option FOO" \ | |
79 | "Unrecognized option.*Try \"help info macro\"\." \ | |
80 | "info macro -invalid-option FOO" | |
81 | ||
82 | # Single macro lookups. | |
83 | gdb_test "info macro -- FOO" \ | |
84 | ".*#define FOO \"hello\"" \ | |
85 | "info macro -- FOO" | |
86 | ||
87 | gdb_test "info macro -- FOO" \ | |
88 | ".*#define FOO \"hello\"" \ | |
89 | "info macro -- FOO" | |
90 | ||
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 | # Multiple macro lookups. | |
104 | set test "info macro -a FOO" | |
9b158ba0 | 105 | set r1 ".*#define FOO \"hello\"" |
106 | set r2 ".*#define FOO \" \"" | |
107 | set r3 ".*#define FOO \"world\"" | |
108 | set r4 ".*#define FOO\\(a\\) foo = a" | |
109 | set testname "$test 1" | |
110 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
111 | ||
71eba9c2 | 112 | set test "info macro -a -- FOO" |
113 | set testname "$test 1" | |
114 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
115 | ||
116 | set test "info macro -all -- FOO" | |
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" | |
122 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
123 | ||
124 | set test "info macro -a -- FOO" | |
125 | set testname "$test" | |
126 | gdb_test "$test" "$r1$r2$r3$r4" "$testname" | |
9b158ba0 | 127 | |
128 | set test "info macros" | |
129 | set r1 ".*#define FOO \"hello\"" | |
130 | set r2 ".*#define ONE" | |
131 | set r3 ".*\r\n$gdb_prompt" | |
132 | set testname "$test 2" | |
133 | gdb_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 | } | |
147 | gdb_test "next" ".*" "" | |
148 | ||
149 | set r1 ".*#define FOO \" \"" | |
150 | set r2 ".*#define ONE" | |
151 | set r3 ".*#define TWO" | |
152 | set r4 ".*\r\n$gdb_prompt" | |
71eba9c2 | 153 | set testname "$test 3" |
9b158ba0 | 154 | gdb_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 | } | |
165 | gdb_test "next" ".*" "" | |
166 | ||
167 | # in alpabetical order... | |
168 | set r1 ".*#define FOO \"world\"" | |
169 | set r2 ".*#define ONE" | |
170 | set r3 ".*#define THREE" | |
171 | set r4 ".*#define TWO" | |
172 | set r5 ".*\r\n$gdb_prompt" | |
173 | set testname "$test 4" | |
174 | gdb_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. | |
183 | set test "info macros *\$pc" | |
184 | gdb_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 | } | |
192 | gdb_test "next" ".*" "" | |
193 | ||
194 | set r1 ".*#define FOO \" \"" | |
195 | set r2 ".*#define ONE" | |
196 | set r3 ".*#define TWO." | |
197 | set r4 ".*\r\n$gdb_prompt" | |
9b158ba0 | 198 | set test "info macros" |
71eba9c2 | 199 | set testname "$test 5" |
9b158ba0 | 200 | gdb_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 | } | |
211 | gdb_test "next" ".*" "" | |
212 | gdb_test "next" ".*" "" | |
213 | ||
214 | set r1 ".*#define DEF_MACROS" | |
215 | set r2 ".*\r\n$gdb_prompt" | |
216 | set testname "$test 6" | |
217 | gdb_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 | ||
247 | gdb_test "next" ".*" "" | |
248 | set r1 ".*#define DEF_MACROS" | |
249 | set r2 ".*#define FOO\\(a\\) foo = a" | |
250 | set r3 ".*#define FOUR" | |
251 | set r4 ".*\r\n$gdb_prompt" | |
252 | set testname "$test 7" | |
253 | gdb_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 | ||
277 | set test "info macros info-macros.c:42" | |
278 | ||
279 | set r1 ".*define DEF_MACROS" | |
280 | set 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.) | |
283 | setup_kfail "gdb/NNNN" *-*-* | |
284 | gdb_test "$test" "$r1$r2" "$test" |