1 # Copyright 2011-2016 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 # Don't use "debug" here. Otherwise "-g" would be appended to the gcc
31 # command line, possibly overriding "-g3" (depending on gcc version).
32 set options "additional_flags=-g3"
34 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } {
35 untested ${testfile}.exp
40 untested ${testfile}.exp
44 # Test various error messages.
45 gdb_test "info macro -- -all" \
46 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
48 gdb_test "info macro -- -all" \
49 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
52 gdb_test "info macro -all --" \
53 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
56 gdb_test "info macro -all --" \
57 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
60 gdb_test "info macro -all --" \
61 "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 -- " \
69 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
71 gdb_test "info macro -- " \
72 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
75 gdb_test "info macro -invalid-option" \
76 "Unrecognized option.*Try \"help info macro\"\." \
77 "info macro -invalid-option 1"
79 gdb_test "info macro -invalid-option" \
80 "Unrecognized option.*Try \"help info macro\"\." \
81 "info macro -invalid-option"
83 gdb_test "info macro -invalid-option FOO" \
84 "Unrecognized option.*Try \"help info macro\"\." \
85 "info macro -invalid-option FOO"
86 gdb_test "info macro -invalid-option FOO" \
87 "Unrecognized option.*Try \"help info macro\"\." \
88 "info macro -invalid-option FOO"
90 # Single macro lookups.
91 gdb_test "info macro -- FOO" \
92 ".*#define FOO \"hello\"" \
95 gdb_test "info macro -- FOO" \
96 ".*#define FOO \"hello\"" \
99 gdb_test "info macro -- FOO" \
100 ".*#define FOO \"hello\"" \
103 gdb_test "info macro FOO" \
104 ".*#define FOO \"hello\"" \
107 gdb_test "info macro FOO" \
108 ".*#define FOO \"hello\"" \
111 # Multiple macro lookups.
112 set test "info macro -a FOO"
113 set r1 ".*#define FOO \"hello\""
114 set r2 ".*#define FOO \" \""
115 set r3 ".*#define FOO \"world\""
116 set r4 ".*#define FOO\\(a\\) foo = a"
117 set testname "$test 1"
118 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
120 set test "info macro -a -- FOO"
121 set testname "$test 1"
122 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
124 set test "info macro -all -- FOO"
125 set testname "$test 1"
126 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
128 set test "info macro -a -- FOO"
130 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
132 set test "info macro -a -- FOO"
134 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
136 set test "info macros"
137 set r1 ".*#define FOO \"hello\""
138 set r2 ".*#define ONE"
139 set r3 ".*\r\n$gdb_prompt"
140 set testname "$test 2"
141 gdb_test_multiple "$test" $testname {
145 -re ".*#define TWO.*\r\n$gdb_prompt" {
148 -re ".*#define THREE.*\r\n$gdb_prompt" {
151 -re ".*#define FOUR.*\r\n$gdb_prompt" {
155 gdb_test "next" ".*" ""
157 set r1 ".*#define FOO \" \""
158 set r2 ".*#define ONE"
159 set r3 ".*#define TWO"
160 set r4 ".*\r\n$gdb_prompt"
161 set testname "$test 3"
162 gdb_test_multiple "$test" $testname {
163 -re ".*#define THREE.*\r\n$gdb_prompt" {
166 -re ".*#define FOUR.*\r\n$gdb_prompt" {
173 gdb_test "next" ".*" ""
175 # in alpabetical order...
176 set r1 ".*#define FOO \"world\""
177 set r2 ".*#define ONE"
178 set r3 ".*#define THREE"
179 set r4 ".*#define TWO"
180 set r5 ".*\r\n$gdb_prompt"
181 set testname "$test 4"
182 gdb_test_multiple "$test" $testname {
183 -re ".*#define FOUR.*\r\n$gdb_prompt" {
186 -re "$r1$r2$r3$r4$r5" {
190 # same as above with a linespec.
191 set test "info macros *\$pc"
192 gdb_test_multiple "$test" $test {
193 -re ".*#define FOUR.*\r\n$gdb_prompt" {
196 -re "$r1$r2$r3$r4$r5" {
200 gdb_test "next" ".*" ""
202 set r1 ".*#define FOO \" \""
203 set r2 ".*#define ONE"
204 set r3 ".*#define TWO."
205 set r4 ".*\r\n$gdb_prompt"
206 set test "info macros"
207 set testname "$test 5"
208 gdb_test_multiple "$test" $test {
209 -re ".*#define THREE.*\r\n$gdb_prompt" {
212 -re ".*#define FOUR.*\r\n$gdb_prompt" {
219 gdb_test "next" ".*" ""
220 gdb_test "next" ".*" ""
222 set r1 ".*#define DEF_MACROS"
223 set r2 ".*\r\n$gdb_prompt"
224 set testname "$test 6"
225 gdb_test_multiple "$test" $testname {
226 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
229 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
232 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
235 -re ".*#define FOO\\(a\\) foo = a.*" {
238 -re ".*#define ONE.*\r\n$gdb_prompt" {
241 -re ".*#define TWO.*\r\n$gdb_prompt" {
244 -re ".*#define THREE.*\r\n$gdb_prompt" {
247 -re ".*#define FOUR.*\r\n$gdb_prompt" {
255 gdb_test "next" ".*" ""
256 set r1 ".*#define DEF_MACROS"
257 set r2 ".*#define FOO\\(a\\) foo = a"
258 set r3 ".*#define FOUR"
259 set r4 ".*\r\n$gdb_prompt"
260 set testname "$test 7"
261 gdb_test_multiple "$test" $testname {
262 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
265 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
268 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
271 -re ".*#define ONE.*\r\n$gdb_prompt" {
274 -re ".*#define TWO.*\r\n$gdb_prompt" {
277 -re ".*#define THREE.*\r\n$gdb_prompt" {
285 set test "info macros info-macros.c:42"
287 set r1 ".*define DEF_MACROS"
288 set r2 ".*define ONE"
289 # info macros on the line where the #define or #include is
290 # fails to find the macro defined (though it works on the next line.)
291 setup_kfail "gdb/NNNN" *-*-*
292 gdb_test "$test" "$r1$r2" "$test"