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