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}
19 get_compiler_info ${binfile}
20 if [test_compiler_info gcc*] {
21 lappend options additional_flags=-g3
23 untested ${testfile}.exp
27 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } {
28 untested ${testfile}.exp
33 untested ${testfile}.exp
37 # Test various error messages.
38 gdb_test "info macro -- -all" \
39 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
41 gdb_test "info macro -- -all" \
42 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
45 gdb_test "info macro -all --" \
46 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
49 gdb_test "info macro -all --" \
50 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
53 gdb_test "info macro -all --" \
54 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
57 gdb_test "info macro --" \
58 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
61 gdb_test "info macro -- " \
62 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
64 gdb_test "info macro -- " \
65 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
68 gdb_test "info macro -invalid-option" \
69 "Unrecognized option.*Try \"help info macro\"\." \
70 "info macro -invalid-option 1"
72 gdb_test "info macro -invalid-option" \
73 "Unrecognized option.*Try \"help info macro\"\." \
74 "info macro -invalid-option"
76 gdb_test "info macro -invalid-option FOO" \
77 "Unrecognized option.*Try \"help info macro\"\." \
78 "info macro -invalid-option FOO"
79 gdb_test "info macro -invalid-option FOO" \
80 "Unrecognized option.*Try \"help info macro\"\." \
81 "info macro -invalid-option FOO"
83 # Single macro lookups.
84 gdb_test "info macro -- FOO" \
85 ".*#define FOO \"hello\"" \
88 gdb_test "info macro -- FOO" \
89 ".*#define FOO \"hello\"" \
92 gdb_test "info macro -- FOO" \
93 ".*#define FOO \"hello\"" \
96 gdb_test "info macro FOO" \
97 ".*#define FOO \"hello\"" \
100 gdb_test "info macro FOO" \
101 ".*#define FOO \"hello\"" \
104 # Multiple macro lookups.
105 set test "info macro -a FOO"
106 set r1 ".*#define FOO \"hello\""
107 set r2 ".*#define FOO \" \""
108 set r3 ".*#define FOO \"world\""
109 set r4 ".*#define FOO\\(a\\) foo = a"
110 set testname "$test 1"
111 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
113 set test "info macro -a -- FOO"
114 set testname "$test 1"
115 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
117 set test "info macro -all -- FOO"
118 set testname "$test 1"
119 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
121 set test "info macro -a -- FOO"
123 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
125 set test "info macro -a -- FOO"
127 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
129 set test "info macros"
130 set r1 ".*#define FOO \"hello\""
131 set r2 ".*#define ONE"
132 set r3 ".*\r\n$gdb_prompt"
133 set testname "$test 2"
134 gdb_test_multiple "$test" $testname {
138 -re ".*#define TWO.*\r\n$gdb_prompt" {
141 -re ".*#define THREE.*\r\n$gdb_prompt" {
144 -re ".*#define FOUR.*\r\n$gdb_prompt" {
148 gdb_test "next" ".*" ""
150 set r1 ".*#define FOO \" \""
151 set r2 ".*#define ONE"
152 set r3 ".*#define TWO"
153 set r4 ".*\r\n$gdb_prompt"
154 set testname "$test 3"
155 gdb_test_multiple "$test" $testname {
156 -re ".*#define THREE.*\r\n$gdb_prompt" {
159 -re ".*#define FOUR.*\r\n$gdb_prompt" {
166 gdb_test "next" ".*" ""
168 # in alpabetical order...
169 set r1 ".*#define FOO \"world\""
170 set r2 ".*#define ONE"
171 set r3 ".*#define THREE"
172 set r4 ".*#define TWO"
173 set r5 ".*\r\n$gdb_prompt"
174 set testname "$test 4"
175 gdb_test_multiple "$test" $testname {
176 -re ".*#define FOUR.*\r\n$gdb_prompt" {
179 -re "$r1$r2$r3$r4$r5" {
183 # same as above with a linespec.
184 set test "info macros *\$pc"
185 gdb_test_multiple "$test" $test {
186 -re ".*#define FOUR.*\r\n$gdb_prompt" {
189 -re "$r1$r2$r3$r4$r5" {
193 gdb_test "next" ".*" ""
195 set r1 ".*#define FOO \" \""
196 set r2 ".*#define ONE"
197 set r3 ".*#define TWO."
198 set r4 ".*\r\n$gdb_prompt"
199 set test "info macros"
200 set testname "$test 5"
201 gdb_test_multiple "$test" $test {
202 -re ".*#define THREE.*\r\n$gdb_prompt" {
205 -re ".*#define FOUR.*\r\n$gdb_prompt" {
212 gdb_test "next" ".*" ""
213 gdb_test "next" ".*" ""
215 set r1 ".*#define DEF_MACROS"
216 set r2 ".*\r\n$gdb_prompt"
217 set testname "$test 6"
218 gdb_test_multiple "$test" $testname {
219 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
222 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
225 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
228 -re ".*#define FOO\\(a\\) foo = a.*" {
231 -re ".*#define ONE.*\r\n$gdb_prompt" {
234 -re ".*#define TWO.*\r\n$gdb_prompt" {
237 -re ".*#define THREE.*\r\n$gdb_prompt" {
240 -re ".*#define FOUR.*\r\n$gdb_prompt" {
248 gdb_test "next" ".*" ""
249 set r1 ".*#define DEF_MACROS"
250 set r2 ".*#define FOO\\(a\\) foo = a"
251 set r3 ".*#define FOUR"
252 set r4 ".*\r\n$gdb_prompt"
253 set testname "$test 7"
254 gdb_test_multiple "$test" $testname {
255 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
258 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
261 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
264 -re ".*#define ONE.*\r\n$gdb_prompt" {
267 -re ".*#define TWO.*\r\n$gdb_prompt" {
270 -re ".*#define THREE.*\r\n$gdb_prompt" {
278 set test "info macros info-macros.c:42"
280 set r1 ".*define DEF_MACROS"
281 set r2 ".*define ONE"
282 # info macros on the line where the #define or #include is
283 # fails to find the macro defined (though it works on the next line.)
284 setup_kfail "gdb/NNNN" *-*-*
285 gdb_test "$test" "$r1$r2" "$test"