[gdb/testsuite] Factor out lib/valgrind.exp
[external/binutils.git] / gdb / testsuite / gdb.base / info_qt.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2018 Free Software Foundation, Inc.
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
24 standard_testfile
25
26 if { [prepare_for_testing "failed to prepare" ${testfile}] } {
27     return -1
28 }
29
30 clean_restart ${binfile}
31
32 if ![runto setup_done] then {
33     fail "can't run to setup_done"
34     return 0
35 }
36
37 set any "\[^\r\n\]*"
38 set ws "\[ \t\]\+"
39 set number "\[0-9]\+"
40
41
42 ############# Test 'info functions'.
43
44 with_test_prefix "info functions nameregexp" {
45     foreach cmd {
46         "info functions info_fun"
47         "info functions -- info_fun"
48         "info functions ^info_fun" } {
49             gdb_test $cmd \
50                 [multi_line \
51                      "All functions matching regular expression \".*info_fun.*\":" \
52                      "" \
53                      "File .*info_qt.c:" \
54                      "${number}:        void info_fun1\\\(void\\\);" \
55                      "${number}:        int info_fun2\\\(char\\\);" \
56                      "${number}:        int info_fun2bis\\\(char\\\);" \
57                      "${number}:        entier info_fun2xxx\\\(char, int, int\\\);" \
58                      "${number}:        entier info_fun2yyy\\\(char, int, int\\\);" \
59                     ]
60     }
61 }
62
63 with_test_prefix "info functions nameregexp quiet" {
64     foreach cmd {
65         "info functions -q info_fun"
66         "info functions -q -- info_fun" } {
67             gdb_test $cmd \
68                 [multi_line \
69                      "" \
70                      "File .*info_qt.c:" \
71                      "${number}:        void info_fun1\\\(void\\\);" \
72                      "${number}:        int info_fun2\\\(char\\\);" \
73                      "${number}:        int info_fun2bis\\\(char\\\);" \
74                      "${number}:        entier info_fun2xxx\\\(char, int, int\\\);" \
75                      "${number}:        entier info_fun2yyy\\\(char, int, int\\\);" \
76                     ]
77         }
78 }
79
80 with_test_prefix "info functions nameregexp quiet no match" {
81     foreach cmd {
82         "info functions -q nowaythiscanmatch"
83         "info functions -q -- -q" } {
84             gdb_test_no_output $cmd
85         }
86 }
87
88 with_test_prefix "info functions typeregexp nameregexp" {
89     foreach cmd {
90         "info functions -t entier -q info_fun"
91         "info functions -q -t 'entier (' -- info_fun"
92         "info functions -q -t '(char, int, int)' -- info_fun"
93         "info functions -q -t 'entier (char, int, int)' -- info_fun" } {
94             gdb_test $cmd \
95                 [multi_line \
96                      "" \
97                      "File .*info_qt.c:" \
98                      "${number}:        entier info_fun2xxx\\\(char, int, int\\\);" \
99                      "${number}:        entier info_fun2yyy\\\(char, int, int\\\);" \
100                     ]
101         }
102 }
103
104 with_test_prefix "info functions typeregexp nameregexp no match" {
105     gdb_test_no_output "info functions -t ganze_Zahl -q info_fun" \
106         "quiet output info functions no matching type"
107 }
108
109 ############# Test 'info variables'.
110
111 with_test_prefix "info variables nameregexp" {
112     foreach cmd {
113         "info variables info_qt"
114         "info variables -- info_qt"
115         "info variables ^info_qt" } {
116             gdb_test $cmd \
117                 [multi_line \
118                      "All variables matching regular expression \".*info_qt.*\":" \
119                      "" \
120                      "File .*info_qt.c:" \
121                      "${number}:        entier info_qt_ent;" \
122                      "${number}:        int info_qt_inc;" \
123                     ]
124         }
125 }
126
127 with_test_prefix "info variables nameregexp quiet no match" {
128     foreach cmd {
129         "info variables -q nowaythiscanmatch"
130         "info variables -q -- -q" } {
131             gdb_test_no_output $cmd
132         }
133 }
134
135 with_test_prefix "info variables typeregexp nameregexp quiet" {
136     foreach cmd {
137         "info variables -t entier -q info_qt"
138         "info variables -q -t entier -- info_qt" } {
139             gdb_test $cmd \
140                 [multi_line \
141                      "" \
142                      "File .*info_qt.c:" \
143                      "${number}:        entier info_qt_ent;" \
144                     ]
145         }
146 }
147
148 with_test_prefix "info variables typeregexp nameregexp quiet no match" {
149     gdb_test_no_output "info variables -t ganze_Zahl -q info_at" \
150         "quiet output info variables no matching type"
151 }
152
153
154
155 ############# Test 'info args' in function setup.
156
157 gdb_test "frame 1" ".* in setup .*" "set frame 1 for info args"
158
159 with_test_prefix "info args matching all args" {
160     foreach cmd {
161         "info args"
162         "info args arg_"
163         "info args g"
164         "info args -- .*" } {
165             gdb_test $cmd \
166                 [multi_line \
167                      "arg_c = 100 'd'" \
168                      "arg_i = 3" \
169                      "arg_j = 4" \
170                     ]
171         }
172 }
173
174 with_test_prefix "info args matching some args" {
175     foreach cmd {
176         "info args -t int"
177         "info args arg_[ij]"} {
178             gdb_test $cmd \
179                 [multi_line \
180                      "arg_i = 3" \
181                      "arg_j = 4" \
182                     ]
183         }
184 }
185
186 with_test_prefix "info args no match" {
187     gdb_test "info args nowaythiscanmatch" "No matching arguments." "no matching args"
188     gdb_test_no_output "info args -q nowaythiscanmatch" "quiet no matching args"
189     gdb_test_no_output "info args -q -t entier" "quiet no matching args with type"
190 }
191
192 ############# Test 'info locals' in function setup.
193
194 gdb_test "frame 1" ".* in setup .*" "set frame 1 for info locals"
195
196 with_test_prefix "info locals matching all locals" {
197     foreach cmd {
198         "info locals"
199         "info locals loc_arg_"
200         "info locals g"
201         "info locals -- .*" } {
202             gdb_test $cmd \
203                 [multi_line \
204                      "loc_arg_c = 100 'd'" \
205                      "loc_arg_i = 3" \
206                      "loc_arg_j = 4" \
207                     ]
208         }
209 }
210
211 with_test_prefix "info locals matching some locals" {
212     foreach cmd {
213         "info locals -t int"
214         "info locals arg_[ij]"
215         "info locals loc_arg_[ij]"} {
216             gdb_test $cmd \
217                 [multi_line \
218                      "loc_arg_i = 3" \
219                      "loc_arg_j = 4" \
220                     ]
221         }
222 }
223
224 with_test_prefix "info locals no match" {
225     gdb_test "info locals nowaythiscanmatch" "No matching locals." "no matching locals"
226     gdb_test_no_output "info locals -q nowaythiscanmatch" "quiet no matching locals"
227     gdb_test_no_output "info locals -q -t ganze_Zahl loc" "quiet no matching locals with type"
228 }
229
230 # Verify that the rest of the args is taken as a single regexp.
231 with_test_prefix "rest of args as single regexp" {
232     gdb_test "info functions abc def" \
233         "All functions matching regular expression \\\"abc def\\\":" \
234         "single regexp"
235
236     gdb_test "info functions -t uvw abc def" \
237         "All functions matching regular expression \\\"abc def\\\" with type matching regulation expression \\\"uvw\\\":" \
238         "-t noquote single regexp"
239
240     gdb_test "info functions -t 'uvw xyz' abc def" \
241         "All functions matching regular expression \\\"abc def\\\" with type matching regulation expression \\\"uvw xyz\\\":" \
242         "-t quote single regexp"
243 }