1 # Copyright 2011-2014 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/>.
18 # Fission doesn't support macros yet. Bug 15954.
20 untested ${testfile}.exp
25 if ![test_compiler_info gcc*] {
26 untested ${testfile}.exp
30 set options "debug additional_flags=-g3"
32 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } {
33 untested ${testfile}.exp
38 untested ${testfile}.exp
42 # Test various error messages.
43 gdb_test "info macro -- -all" \
44 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
46 gdb_test "info macro -- -all" \
47 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
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 -all --" \
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\]" \
66 gdb_test "info macro -- " \
67 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
69 gdb_test "info macro -- " \
70 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
73 gdb_test "info macro -invalid-option" \
74 "Unrecognized option.*Try \"help info macro\"\." \
75 "info macro -invalid-option 1"
77 gdb_test "info macro -invalid-option" \
78 "Unrecognized option.*Try \"help info macro\"\." \
79 "info macro -invalid-option"
81 gdb_test "info macro -invalid-option FOO" \
82 "Unrecognized option.*Try \"help info macro\"\." \
83 "info macro -invalid-option FOO"
84 gdb_test "info macro -invalid-option FOO" \
85 "Unrecognized option.*Try \"help info macro\"\." \
86 "info macro -invalid-option FOO"
88 # Single macro lookups.
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 gdb_test "info macro FOO" \
106 ".*#define FOO \"hello\"" \
109 # Multiple macro lookups.
110 set test "info macro -a FOO"
111 set r1 ".*#define FOO \"hello\""
112 set r2 ".*#define FOO \" \""
113 set r3 ".*#define FOO \"world\""
114 set r4 ".*#define FOO\\(a\\) foo = a"
115 set testname "$test 1"
116 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
118 set test "info macro -a -- FOO"
119 set testname "$test 1"
120 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
122 set test "info macro -all -- FOO"
123 set testname "$test 1"
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 macro -a -- FOO"
132 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
134 set test "info macros"
135 set r1 ".*#define FOO \"hello\""
136 set r2 ".*#define ONE"
137 set r3 ".*\r\n$gdb_prompt"
138 set testname "$test 2"
139 gdb_test_multiple "$test" $testname {
143 -re ".*#define TWO.*\r\n$gdb_prompt" {
146 -re ".*#define THREE.*\r\n$gdb_prompt" {
149 -re ".*#define FOUR.*\r\n$gdb_prompt" {
153 gdb_test "next" ".*" ""
155 set r1 ".*#define FOO \" \""
156 set r2 ".*#define ONE"
157 set r3 ".*#define TWO"
158 set r4 ".*\r\n$gdb_prompt"
159 set testname "$test 3"
160 gdb_test_multiple "$test" $testname {
161 -re ".*#define THREE.*\r\n$gdb_prompt" {
164 -re ".*#define FOUR.*\r\n$gdb_prompt" {
171 gdb_test "next" ".*" ""
173 # in alpabetical order...
174 set r1 ".*#define FOO \"world\""
175 set r2 ".*#define ONE"
176 set r3 ".*#define THREE"
177 set r4 ".*#define TWO"
178 set r5 ".*\r\n$gdb_prompt"
179 set testname "$test 4"
180 gdb_test_multiple "$test" $testname {
181 -re ".*#define FOUR.*\r\n$gdb_prompt" {
184 -re "$r1$r2$r3$r4$r5" {
188 # same as above with a linespec.
189 set test "info macros *\$pc"
190 gdb_test_multiple "$test" $test {
191 -re ".*#define FOUR.*\r\n$gdb_prompt" {
194 -re "$r1$r2$r3$r4$r5" {
198 gdb_test "next" ".*" ""
200 set r1 ".*#define FOO \" \""
201 set r2 ".*#define ONE"
202 set r3 ".*#define TWO."
203 set r4 ".*\r\n$gdb_prompt"
204 set test "info macros"
205 set testname "$test 5"
206 gdb_test_multiple "$test" $test {
207 -re ".*#define THREE.*\r\n$gdb_prompt" {
210 -re ".*#define FOUR.*\r\n$gdb_prompt" {
217 gdb_test "next" ".*" ""
218 gdb_test "next" ".*" ""
220 set r1 ".*#define DEF_MACROS"
221 set r2 ".*\r\n$gdb_prompt"
222 set testname "$test 6"
223 gdb_test_multiple "$test" $testname {
224 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
227 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
230 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
233 -re ".*#define FOO\\(a\\) foo = a.*" {
236 -re ".*#define ONE.*\r\n$gdb_prompt" {
239 -re ".*#define TWO.*\r\n$gdb_prompt" {
242 -re ".*#define THREE.*\r\n$gdb_prompt" {
245 -re ".*#define FOUR.*\r\n$gdb_prompt" {
253 gdb_test "next" ".*" ""
254 set r1 ".*#define DEF_MACROS"
255 set r2 ".*#define FOO\\(a\\) foo = a"
256 set r3 ".*#define FOUR"
257 set r4 ".*\r\n$gdb_prompt"
258 set testname "$test 7"
259 gdb_test_multiple "$test" $testname {
260 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
263 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
266 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
269 -re ".*#define ONE.*\r\n$gdb_prompt" {
272 -re ".*#define TWO.*\r\n$gdb_prompt" {
275 -re ".*#define THREE.*\r\n$gdb_prompt" {
283 set test "info macros info-macros.c:42"
285 set r1 ".*define DEF_MACROS"
286 set r2 ".*define ONE"
287 # info macros on the line where the #define or #include is
288 # fails to find the macro defined (though it works on the next line.)
289 setup_kfail "gdb/NNNN" *-*-*
290 gdb_test "$test" "$r1$r2" "$test"