1 # Copyright 2011-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 set testfile "info-macros"
17 set srcfile ${testfile}.c
18 set binfile ${objdir}/${subdir}/${testfile}
20 get_compiler_info ${binfile}
21 if ![test_compiler_info gcc*] {
22 untested ${testfile}.exp
26 set options "debug additional_flags=-g3"
28 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } {
29 untested ${testfile}.exp
34 untested ${testfile}.exp
38 # Test various error messages.
39 gdb_test "info macro -- -all" \
40 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
42 gdb_test "info macro -- -all" \
43 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
46 gdb_test "info macro -all --" \
47 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
50 gdb_test "info macro -all --" \
51 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
54 gdb_test "info macro -all --" \
55 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
58 gdb_test "info macro --" \
59 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
62 gdb_test "info macro -- " \
63 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
65 gdb_test "info macro -- " \
66 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
69 gdb_test "info macro -invalid-option" \
70 "Unrecognized option.*Try \"help info macro\"\." \
71 "info macro -invalid-option 1"
73 gdb_test "info macro -invalid-option" \
74 "Unrecognized option.*Try \"help info macro\"\." \
75 "info macro -invalid-option"
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"
84 # Single macro lookups.
85 gdb_test "info macro -- FOO" \
86 ".*#define FOO \"hello\"" \
89 gdb_test "info macro -- FOO" \
90 ".*#define FOO \"hello\"" \
93 gdb_test "info macro -- FOO" \
94 ".*#define FOO \"hello\"" \
97 gdb_test "info macro FOO" \
98 ".*#define FOO \"hello\"" \
101 gdb_test "info macro FOO" \
102 ".*#define FOO \"hello\"" \
105 # Multiple macro lookups.
106 set test "info macro -a FOO"
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"
114 set test "info macro -a -- FOO"
115 set testname "$test 1"
116 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
118 set test "info macro -all -- FOO"
119 set testname "$test 1"
120 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
122 set test "info macro -a -- FOO"
124 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
126 set test "info macro -a -- FOO"
128 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
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 {
139 -re ".*#define TWO.*\r\n$gdb_prompt" {
142 -re ".*#define THREE.*\r\n$gdb_prompt" {
145 -re ".*#define FOUR.*\r\n$gdb_prompt" {
149 gdb_test "next" ".*" ""
151 set r1 ".*#define FOO \" \""
152 set r2 ".*#define ONE"
153 set r3 ".*#define TWO"
154 set r4 ".*\r\n$gdb_prompt"
155 set testname "$test 3"
156 gdb_test_multiple "$test" $testname {
157 -re ".*#define THREE.*\r\n$gdb_prompt" {
160 -re ".*#define FOUR.*\r\n$gdb_prompt" {
167 gdb_test "next" ".*" ""
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" {
180 -re "$r1$r2$r3$r4$r5" {
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" {
190 -re "$r1$r2$r3$r4$r5" {
194 gdb_test "next" ".*" ""
196 set r1 ".*#define FOO \" \""
197 set r2 ".*#define ONE"
198 set r3 ".*#define TWO."
199 set r4 ".*\r\n$gdb_prompt"
200 set test "info macros"
201 set testname "$test 5"
202 gdb_test_multiple "$test" $test {
203 -re ".*#define THREE.*\r\n$gdb_prompt" {
206 -re ".*#define FOUR.*\r\n$gdb_prompt" {
213 gdb_test "next" ".*" ""
214 gdb_test "next" ".*" ""
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" {
223 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
226 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
229 -re ".*#define FOO\\(a\\) foo = a.*" {
232 -re ".*#define ONE.*\r\n$gdb_prompt" {
235 -re ".*#define TWO.*\r\n$gdb_prompt" {
238 -re ".*#define THREE.*\r\n$gdb_prompt" {
241 -re ".*#define FOUR.*\r\n$gdb_prompt" {
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" {
259 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
262 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
265 -re ".*#define ONE.*\r\n$gdb_prompt" {
268 -re ".*#define TWO.*\r\n$gdb_prompt" {
271 -re ".*#define THREE.*\r\n$gdb_prompt" {
279 set test "info macros info-macros.c:42"
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"