]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/info_qt.exp
gdb/testsuite: remove use of then keyword from gdb.base/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / info_qt.exp
CommitLineData
82b5e646
PW
1# This testcase is part of GDB, the GNU debugger.
2
4a94e368 3# Copyright 2018-2022 Free Software Foundation, Inc.
82b5e646
PW
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19# This test verifies the TYPEREGEXP and NAMEREGEXP matching logic
20# in the commands
21# info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP].
22
23
24standard_testfile
25
26if { [prepare_for_testing "failed to prepare" ${testfile}] } {
27 return -1
28}
29
65a33d75 30if {![runto setup_done]} {
82b5e646
PW
31 return 0
32}
33
34set any "\[^\r\n\]*"
35set ws "\[ \t\]\+"
36set number "\[0-9]\+"
37
38
39############# Test 'info functions'.
40
41with_test_prefix "info functions nameregexp" {
42 foreach cmd {
43 "info functions info_fun"
44 "info functions -- info_fun"
45 "info functions ^info_fun" } {
46 gdb_test $cmd \
47 [multi_line \
48 "All functions matching regular expression \".*info_fun.*\":" \
49 "" \
50 "File .*info_qt.c:" \
51 "${number}: void info_fun1\\\(void\\\);" \
52 "${number}: int info_fun2\\\(char\\\);" \
53 "${number}: int info_fun2bis\\\(char\\\);" \
54 "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \
55 "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \
56 ]
57 }
58}
59
60with_test_prefix "info functions nameregexp quiet" {
61 foreach cmd {
62 "info functions -q info_fun"
63 "info functions -q -- info_fun" } {
64 gdb_test $cmd \
65 [multi_line \
66 "" \
67 "File .*info_qt.c:" \
68 "${number}: void info_fun1\\\(void\\\);" \
69 "${number}: int info_fun2\\\(char\\\);" \
70 "${number}: int info_fun2bis\\\(char\\\);" \
71 "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \
72 "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \
73 ]
74 }
75}
76
77with_test_prefix "info functions nameregexp quiet no match" {
78 foreach cmd {
79 "info functions -q nowaythiscanmatch"
80 "info functions -q -- -q" } {
81 gdb_test_no_output $cmd
82 }
83}
84
85with_test_prefix "info functions typeregexp nameregexp" {
86 foreach cmd {
87 "info functions -t entier -q info_fun"
88 "info functions -q -t 'entier (' -- info_fun"
89 "info functions -q -t '(char, int, int)' -- info_fun"
90 "info functions -q -t 'entier (char, int, int)' -- info_fun" } {
91 gdb_test $cmd \
92 [multi_line \
93 "" \
94 "File .*info_qt.c:" \
95 "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \
96 "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \
97 ]
98 }
99}
100
101with_test_prefix "info functions typeregexp nameregexp no match" {
102 gdb_test_no_output "info functions -t ganze_Zahl -q info_fun" \
103 "quiet output info functions no matching type"
104}
105
106############# Test 'info variables'.
107
108with_test_prefix "info variables nameregexp" {
109 foreach cmd {
110 "info variables info_qt"
111 "info variables -- info_qt"
112 "info variables ^info_qt" } {
113 gdb_test $cmd \
114 [multi_line \
115 "All variables matching regular expression \".*info_qt.*\":" \
116 "" \
117 "File .*info_qt.c:" \
118 "${number}: entier info_qt_ent;" \
119 "${number}: int info_qt_inc;" \
120 ]
121 }
122}
123
124with_test_prefix "info variables nameregexp quiet no match" {
125 foreach cmd {
126 "info variables -q nowaythiscanmatch"
127 "info variables -q -- -q" } {
128 gdb_test_no_output $cmd
129 }
130}
131
132with_test_prefix "info variables typeregexp nameregexp quiet" {
133 foreach cmd {
134 "info variables -t entier -q info_qt"
135 "info variables -q -t entier -- info_qt" } {
136 gdb_test $cmd \
137 [multi_line \
138 "" \
139 "File .*info_qt.c:" \
140 "${number}: entier info_qt_ent;" \
141 ]
142 }
143}
144
145with_test_prefix "info variables typeregexp nameregexp quiet no match" {
146 gdb_test_no_output "info variables -t ganze_Zahl -q info_at" \
147 "quiet output info variables no matching type"
148}
149
150
151
152############# Test 'info args' in function setup.
153
154gdb_test "frame 1" ".* in setup .*" "set frame 1 for info args"
155
156with_test_prefix "info args matching all args" {
157 foreach cmd {
158 "info args"
159 "info args arg_"
160 "info args g"
161 "info args -- .*" } {
162 gdb_test $cmd \
163 [multi_line \
164 "arg_c = 100 'd'" \
165 "arg_i = 3" \
166 "arg_j = 4" \
167 ]
168 }
169}
170
171with_test_prefix "info args matching some args" {
172 foreach cmd {
173 "info args -t int"
174 "info args arg_[ij]"} {
175 gdb_test $cmd \
176 [multi_line \
177 "arg_i = 3" \
178 "arg_j = 4" \
179 ]
180 }
181}
182
183with_test_prefix "info args no match" {
184 gdb_test "info args nowaythiscanmatch" "No matching arguments." "no matching args"
185 gdb_test_no_output "info args -q nowaythiscanmatch" "quiet no matching args"
186 gdb_test_no_output "info args -q -t entier" "quiet no matching args with type"
187}
188
189############# Test 'info locals' in function setup.
190
191gdb_test "frame 1" ".* in setup .*" "set frame 1 for info locals"
192
193with_test_prefix "info locals matching all locals" {
194 foreach cmd {
195 "info locals"
196 "info locals loc_arg_"
197 "info locals g"
198 "info locals -- .*" } {
199 gdb_test $cmd \
200 [multi_line \
201 "loc_arg_c = 100 'd'" \
202 "loc_arg_i = 3" \
203 "loc_arg_j = 4" \
204 ]
205 }
206}
207
208with_test_prefix "info locals matching some locals" {
209 foreach cmd {
210 "info locals -t int"
211 "info locals arg_[ij]"
212 "info locals loc_arg_[ij]"} {
213 gdb_test $cmd \
214 [multi_line \
215 "loc_arg_i = 3" \
216 "loc_arg_j = 4" \
217 ]
218 }
219}
220
221with_test_prefix "info locals no match" {
222 gdb_test "info locals nowaythiscanmatch" "No matching locals." "no matching locals"
223 gdb_test_no_output "info locals -q nowaythiscanmatch" "quiet no matching locals"
224 gdb_test_no_output "info locals -q -t ganze_Zahl loc" "quiet no matching locals with type"
225}
226
227# Verify that the rest of the args is taken as a single regexp.
228with_test_prefix "rest of args as single regexp" {
229 gdb_test "info functions abc def" \
230 "All functions matching regular expression \\\"abc def\\\":" \
231 "single regexp"
232
233 gdb_test "info functions -t uvw abc def" \
0c95f9ed 234 "All functions matching regular expression \\\"abc def\\\" with type matching regular expression \\\"uvw\\\":" \
82b5e646
PW
235 "-t noquote single regexp"
236
237 gdb_test "info functions -t 'uvw xyz' abc def" \
0c95f9ed 238 "All functions matching regular expression \\\"abc def\\\" with type matching regular expression \\\"uvw xyz\\\":" \
82b5e646
PW
239 "-t quote single regexp"
240}