]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/info-macros.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / info-macros.exp
CommitLineData
b811d2c2 1# Copyright 2011-2020 Free Software Foundation, Inc.
9b158ba0 2
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.
7#
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.
12#
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/>.
15
f8b41b00 16standard_testfile .c
682c7f7b 17
a587b477
DE
18# Fission doesn't support macros yet. Bug 15954.
19if [using_fission] {
5b362f04 20 untested "fission does not support macros yet"
a587b477
DE
21 return -1
22}
23
4c93b1db 24get_compiler_info
682c7f7b 25if ![test_compiler_info gcc*] {
5b362f04 26 untested "no compiler info"
9b158ba0 27 return -1
28}
29
78466714
AA
30# Don't use "debug" here. Otherwise "-g" would be appended to the gcc
31# command line, possibly overriding "-g3" (depending on gcc version).
32set options "additional_flags=-g3"
682c7f7b 33
5b362f04 34if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] } {
9b158ba0 35 return -1
36}
37
38if ![runto_main] {
5b362f04 39 untested "could not run to main"
9b158ba0 40 return -1
41}
42
71eba9c2 43# Test various error messages.
44gdb_test "info macro -- -all" \
11af934b 45 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
71eba9c2 46gdb_test "info macro -- -all" \
11af934b 47 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
71eba9c2 48
49gdb_test "info macro -all --" \
11af934b 50 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 51
52gdb_test "info macro -all --" \
11af934b 53 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 54
55gdb_test "info macro -all --" \
11af934b 56 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 57
58gdb_test "info macro --" \
11af934b 59 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 60
61gdb_test "info macro -- " \
11af934b 62 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 63gdb_test "info macro -- " \
11af934b 64 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]"
71eba9c2 65
66gdb_test "info macro -invalid-option" \
11af934b 67 "Unrecognized option.*Try \"help info macro\"\."
71eba9c2 68
69gdb_test "info macro -invalid-option" \
11af934b 70 "Unrecognized option.*Try \"help info macro\"\."
71eba9c2 71
72gdb_test "info macro -invalid-option FOO" \
11af934b 73 "Unrecognized option.*Try \"help info macro\"\."
71eba9c2 74gdb_test "info macro -invalid-option FOO" \
11af934b 75 "Unrecognized option.*Try \"help info macro\"\."
71eba9c2 76
77# Single macro lookups.
78gdb_test "info macro -- FOO" \
11af934b 79 ".*#define FOO \"hello\""
71eba9c2 80
81gdb_test "info macro -- FOO" \
11af934b 82 ".*#define FOO \"hello\""
71eba9c2 83
84gdb_test "info macro -- FOO" \
11af934b 85 ".*#define FOO \"hello\""
71eba9c2 86
87gdb_test "info macro FOO" \
11af934b 88 ".*#define FOO \"hello\""
71eba9c2 89
90gdb_test "info macro FOO" \
11af934b 91 ".*#define FOO \"hello\""
71eba9c2 92
93# Multiple macro lookups.
94set test "info macro -a FOO"
9b158ba0 95set r1 ".*#define FOO \"hello\""
96set r2 ".*#define FOO \" \""
97set r3 ".*#define FOO \"world\""
98set r4 ".*#define FOO\\(a\\) foo = a"
99set testname "$test 1"
100gdb_test "$test" "$r1$r2$r3$r4" "$testname"
101
71eba9c2 102set test "info macro -a -- FOO"
103set testname "$test 1"
104gdb_test "$test" "$r1$r2$r3$r4" "$testname"
105
106set test "info macro -all -- FOO"
107set testname "$test 1"
108gdb_test "$test" "$r1$r2$r3$r4" "$testname"
109
110set test "info macro -a -- FOO"
11af934b 111gdb_test "$test" "$r1$r2$r3$r4"
71eba9c2 112
113set test "info macro -a -- FOO"
11af934b 114gdb_test "$test" "$r1$r2$r3$r4"
9b158ba0 115
d86bd7cb
TV
116proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
117 user_code } {
118 with_read1_timeout_factor $factor {
119 uplevel [list gdb_test_multiple $command $message $user_code]
120 }
121}
122
9b158ba0 123set test "info macros"
124set r1 ".*#define FOO \"hello\""
125set r2 ".*#define ONE"
126set r3 ".*\r\n$gdb_prompt"
127set testname "$test 2"
d86bd7cb 128gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 129 -re "$r1$r2$r3" {
130 pass $testname
131 }
132 -re ".*#define TWO.*\r\n$gdb_prompt" {
133 fail $testname
134 }
135 -re ".*#define THREE.*\r\n$gdb_prompt" {
136 fail $testname
137 }
138 -re ".*#define FOUR.*\r\n$gdb_prompt" {
139 fail $testname
140 }
141}
142gdb_test "next" ".*" ""
143
144set r1 ".*#define FOO \" \""
145set r2 ".*#define ONE"
146set r3 ".*#define TWO"
147set r4 ".*\r\n$gdb_prompt"
71eba9c2 148set testname "$test 3"
d86bd7cb 149gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 150 -re ".*#define THREE.*\r\n$gdb_prompt" {
151 fail $testname
152 }
153 -re ".*#define FOUR.*\r\n$gdb_prompt" {
154 fail $testname
155 }
156 -re "$r1$r2$r3$r4" {
157 pass $testname
158 }
159}
160gdb_test "next" ".*" ""
161
162# in alpabetical order...
163set r1 ".*#define FOO \"world\""
164set r2 ".*#define ONE"
165set r3 ".*#define THREE"
166set r4 ".*#define TWO"
167set r5 ".*\r\n$gdb_prompt"
168set testname "$test 4"
d86bd7cb 169gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 170 -re ".*#define FOUR.*\r\n$gdb_prompt" {
171 fail $testname
172 }
173 -re "$r1$r2$r3$r4$r5" {
174 pass $testname
175 }
176}
177# same as above with a linespec.
178set test "info macros *\$pc"
d86bd7cb 179gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
9b158ba0 180 -re ".*#define FOUR.*\r\n$gdb_prompt" {
181 fail $test
182 }
183 -re "$r1$r2$r3$r4$r5" {
184 pass $test
185 }
186}
187gdb_test "next" ".*" ""
188
189set r1 ".*#define FOO \" \""
190set r2 ".*#define ONE"
191set r3 ".*#define TWO."
192set r4 ".*\r\n$gdb_prompt"
9b158ba0 193set test "info macros"
71eba9c2 194set testname "$test 5"
d86bd7cb 195gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
9b158ba0 196 -re ".*#define THREE.*\r\n$gdb_prompt" {
197 fail $testname
198 }
199 -re ".*#define FOUR.*\r\n$gdb_prompt" {
200 fail $testname
201 }
202 -re "$r1$r2$r3$r4" {
203 pass $testname
204 }
205}
206gdb_test "next" ".*" ""
207gdb_test "next" ".*" ""
208
209set r1 ".*#define DEF_MACROS"
210set r2 ".*\r\n$gdb_prompt"
211set testname "$test 6"
d86bd7cb 212gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 213 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
214 fail $testname
215 }
216 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
217 fail $testname
218 }
219 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
220 fail $testname
221 }
222 -re ".*#define FOO\\(a\\) foo = a.*" {
223 fail $testname
224 }
225 -re ".*#define ONE.*\r\n$gdb_prompt" {
226 fail $testname
227 }
228 -re ".*#define TWO.*\r\n$gdb_prompt" {
229 fail $testname
230 }
231 -re ".*#define THREE.*\r\n$gdb_prompt" {
232 fail $testname
233 }
234 -re ".*#define FOUR.*\r\n$gdb_prompt" {
235 fail $testname
236 }
237 -re "$r1$r2" {
238 pass $testname
239 }
240}
241
242gdb_test "next" ".*" ""
243set r1 ".*#define DEF_MACROS"
244set r2 ".*#define FOO\\(a\\) foo = a"
245set r3 ".*#define FOUR"
246set r4 ".*\r\n$gdb_prompt"
247set testname "$test 7"
d86bd7cb 248gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 249 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
250 fail $testname
251 }
252 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
253 fail $testname
254 }
255 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
256 fail $testname
257 }
258 -re ".*#define ONE.*\r\n$gdb_prompt" {
259 fail $testname
260 }
261 -re ".*#define TWO.*\r\n$gdb_prompt" {
262 fail $testname
263 }
264 -re ".*#define THREE.*\r\n$gdb_prompt" {
265 fail $testname
266 }
267 -re "$r1$r2$r3$r4" {
268 pass $testname
269 }
270}
271
272set test "info macros info-macros.c:42"
273
274set r1 ".*define DEF_MACROS"
275set r2 ".*define ONE"
276# info macros on the line where the #define or #include is
277# fails to find the macro defined (though it works on the next line.)
278setup_kfail "gdb/NNNN" *-*-*
11af934b 279gdb_test "$test" "$r1$r2"