1 # Copyright 2011-2024 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.
19 require !using_fission
21 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug macros}] } {
29 # Test various error messages.
30 gdb_test "info macro -- -all" \
31 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
32 gdb_test "info macro -- -all" \
33 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+"
35 gdb_test "info macro -all --" \
36 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
38 gdb_test "info macro -all --" \
39 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
41 gdb_test "info macro -all --" \
42 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
44 gdb_test "info macro --" \
45 "You must follow.*with the name.*you want to see.*\[^\r\n\]*"
47 gdb_test "info macro -- " \
48 "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \
50 gdb_test "info macro -- " \
51 "You must follow.*with the name.*you want to see.*\[^\r\n\]*" \
54 gdb_test "info macro -invalid-option" \
55 "Unrecognized option.*Try \"help info macro\"\."
57 gdb_test "info macro -invalid-option" \
58 "Unrecognized option.*Try \"help info macro\"\."
60 gdb_test "info macro -invalid-option FOO" \
61 "Unrecognized option.*Try \"help info macro\"\."
62 gdb_test "info macro -invalid-option FOO" \
63 "Unrecognized option.*Try \"help info macro\"\."
65 # Single macro lookups.
66 gdb_test "info macro -- FOO" \
67 ".*#define FOO \"hello\""
69 gdb_test "info macro -- FOO" \
70 ".*#define FOO \"hello\""
72 gdb_test "info macro -- FOO" \
73 ".*#define FOO \"hello\""
75 gdb_test "info macro FOO" \
76 ".*#define FOO \"hello\""
78 gdb_test "info macro FOO" \
79 ".*#define FOO \"hello\""
81 # Multiple macro lookups.
82 set test "info macro -a FOO"
83 set r1 ".*#define FOO \"hello\""
84 set r2 ".*#define FOO \" \""
85 set r3 ".*#define FOO \"world\""
86 set r4 ".*#define FOO\\(a\\) foo = a"
87 set testname "$test 1"
88 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
90 set test "info macro -a -- FOO"
91 set testname "$test 1"
92 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
94 set test "info macro -all -- FOO"
95 set testname "$test 1"
96 gdb_test "$test" "$r1$r2$r3$r4" "$testname"
98 set test "info macro -a -- FOO"
99 gdb_test "$test" "$r1$r2$r3$r4"
101 set test "info macro -a -- FOO"
102 gdb_test "$test" "$r1$r2$r3$r4"
104 set test "info macros"
105 set r1 "#define FOO \"hello\""
107 set testname "$test 2"
108 gdb_test_lines $test $testname $r1.*$r2 \
109 -re-not "#define TWO" \
110 -re-not "#define THREE" \
111 -re-not "#define FOUR"
113 gdb_test "next" "" "next, 1"
115 set r1 "#define FOO \" \""
118 set testname "$test 3"
119 gdb_test_lines $test $testname $r1.*$r2.*$r3 \
120 -re-not "#define THREE" \
121 -re-not "#define FOUR"
123 gdb_test "next" "" "next, 2"
125 # in alphabetical order...
126 set r1 "#define FOO \"world\""
128 set r3 "#define THREE"
130 set testname "$test 4"
131 gdb_test_lines $test $testname $r1.*$r2.*$r3.*$r4 \
132 -re-not "#define FOUR"
134 # same as above with a linespec.
135 set test "info macros *\$pc"
136 gdb_test_lines $test "" $r1.*$r2.*$r3.*$r4 \
137 -re-not "#define FOUR"
138 gdb_test "next" "" "next, 3"
140 set r1 "#define FOO \" \""
142 set r3 "#define TWO."
143 set test "info macros"
144 set testname "$test 5"
145 gdb_test_lines $test $testname $r1.*$r2.*$r3 \
146 -re-not "#define THREE" \
147 -re-not "#define FOUR"
148 gdb_test "next" "" "next, 4"
149 gdb_test "next" "" "next, 5"
151 set r1 "#define DEF_MACROS"
152 set testname "$test 6"
153 gdb_test_lines $test $testname $r1 \
154 -re-not "#define FOO" \
155 -re-not "#define ONE" \
156 -re-not "#define TWO" \
157 -re-not "#define THREE" \
158 -re-not "#define FOUR"
160 gdb_test "next" "" "next, 6"
161 set r1 "#define DEF_MACROS"
162 set r2 "#define FOO\\(a\\) foo = a"
163 set r3 "#define FOUR"
164 set testname "$test 7"
165 gdb_test_lines $test $testname $r1.*$r2.*$r3 \
166 -re-not "#define FOO \" \"" \
167 -re-not "#define FOO \"hello\"" \
168 -re-not "#define FOO \"world\"" \
169 -re-not "#define ONE" \
170 -re-not "#define TWO" \
171 -re-not "#define THREE"
173 set test "info macros info-macros.c:42"
175 set r1 "#define DEF_MACROS "
177 gdb_test_lines "$test" "" [multi_line \