1 # Copyright 2011-2019 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 "fission does not support macros yet"
25 if ![test_compiler_info gcc*] {
26 untested "no compiler info"
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 "failed to prepare" ${testfile} ${srcfile} $options] } {
39 untested "could not run to main"
43 # Test various error messages.
44 gdb_test "info macro -- -all" \
45 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
47 gdb_test "info macro -- -all" \
48 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
51 gdb_test "info macro -all --" \
52 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
55 gdb_test "info macro -all --" \
56 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
59 gdb_test "info macro -all --" \
60 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
63 gdb_test "info macro --" \
64 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
67 gdb_test "info macro -- " \
68 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
70 gdb_test "info macro -- " \
71 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
74 gdb_test "info macro -invalid-option" \
75 "Unrecognized option.*Try \"help info macro\"\." \
76 "info macro -invalid-option 1"
78 gdb_test "info macro -invalid-option" \
79 "Unrecognized option.*Try \"help info macro\"\." \
80 "info macro -invalid-option"
82 gdb_test "info macro -invalid-option FOO" \
83 "Unrecognized option.*Try \"help info macro\"\." \
84 "info macro -invalid-option FOO"
85 gdb_test "info macro -invalid-option FOO" \
86 "Unrecognized option.*Try \"help info macro\"\." \
87 "info macro -invalid-option FOO"
89 # Single macro lookups.
90 gdb_test "info macro -- FOO" \
91 ".*#define FOO \"hello\"" \
94 gdb_test "info macro -- FOO" \
95 ".*#define FOO \"hello\"" \
98 gdb_test "info macro -- FOO" \
99 ".*#define FOO \"hello\"" \
102 gdb_test "info macro FOO" \
103 ".*#define FOO \"hello\"" \
106 gdb_test "info macro FOO" \
107 ".*#define FOO \"hello\"" \
110 # Multiple macro lookups.
111 set test "info macro -a FOO"
112 set r1 ".*#define FOO \"hello\""
113 set r2 ".*#define FOO \" \""
114 set r3 ".*#define FOO \"world\""
115 set r4 ".*#define FOO\\(a\\) foo = a"
116 set testname "$test 1"
117 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
119 set test "info macro -a -- FOO"
120 set testname "$test 1"
121 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
123 set test "info macro -all -- FOO"
124 set testname "$test 1"
125 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
127 set test "info macro -a -- FOO"
129 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
131 set test "info macro -a -- FOO"
133 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
135 proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
137 with_read1_timeout_factor $factor {
138 uplevel [list gdb_test_multiple $command $message $user_code]
142 set test "info macros"
143 set r1 ".*#define FOO \"hello\""
144 set r2 ".*#define ONE"
145 set r3 ".*\r\n$gdb_prompt"
146 set testname "$test 2"
147 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
151 -re ".*#define TWO.*\r\n$gdb_prompt" {
154 -re ".*#define THREE.*\r\n$gdb_prompt" {
157 -re ".*#define FOUR.*\r\n$gdb_prompt" {
161 gdb_test "next" ".*" ""
163 set r1 ".*#define FOO \" \""
164 set r2 ".*#define ONE"
165 set r3 ".*#define TWO"
166 set r4 ".*\r\n$gdb_prompt"
167 set testname "$test 3"
168 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
169 -re ".*#define THREE.*\r\n$gdb_prompt" {
172 -re ".*#define FOUR.*\r\n$gdb_prompt" {
179 gdb_test "next" ".*" ""
181 # in alpabetical order...
182 set r1 ".*#define FOO \"world\""
183 set r2 ".*#define ONE"
184 set r3 ".*#define THREE"
185 set r4 ".*#define TWO"
186 set r5 ".*\r\n$gdb_prompt"
187 set testname "$test 4"
188 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
189 -re ".*#define FOUR.*\r\n$gdb_prompt" {
192 -re "$r1$r2$r3$r4$r5" {
196 # same as above with a linespec.
197 set test "info macros *\$pc"
198 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
199 -re ".*#define FOUR.*\r\n$gdb_prompt" {
202 -re "$r1$r2$r3$r4$r5" {
206 gdb_test "next" ".*" ""
208 set r1 ".*#define FOO \" \""
209 set r2 ".*#define ONE"
210 set r3 ".*#define TWO."
211 set r4 ".*\r\n$gdb_prompt"
212 set test "info macros"
213 set testname "$test 5"
214 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
215 -re ".*#define THREE.*\r\n$gdb_prompt" {
218 -re ".*#define FOUR.*\r\n$gdb_prompt" {
225 gdb_test "next" ".*" ""
226 gdb_test "next" ".*" ""
228 set r1 ".*#define DEF_MACROS"
229 set r2 ".*\r\n$gdb_prompt"
230 set testname "$test 6"
231 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
232 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
235 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
238 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
241 -re ".*#define FOO\\(a\\) foo = a.*" {
244 -re ".*#define ONE.*\r\n$gdb_prompt" {
247 -re ".*#define TWO.*\r\n$gdb_prompt" {
250 -re ".*#define THREE.*\r\n$gdb_prompt" {
253 -re ".*#define FOUR.*\r\n$gdb_prompt" {
261 gdb_test "next" ".*" ""
262 set r1 ".*#define DEF_MACROS"
263 set r2 ".*#define FOO\\(a\\) foo = a"
264 set r3 ".*#define FOUR"
265 set r4 ".*\r\n$gdb_prompt"
266 set testname "$test 7"
267 gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
268 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
271 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
274 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
277 -re ".*#define ONE.*\r\n$gdb_prompt" {
280 -re ".*#define TWO.*\r\n$gdb_prompt" {
283 -re ".*#define THREE.*\r\n$gdb_prompt" {
291 set test "info macros info-macros.c:42"
293 set r1 ".*define DEF_MACROS"
294 set r2 ".*define ONE"
295 # info macros on the line where the #define or #include is
296 # fails to find the macro defined (though it works on the next line.)
297 setup_kfail "gdb/NNNN" *-*-*
298 gdb_test "$test" "$r1$r2" "$test"