1 # Copyright 2019-2020 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/>.
16 # Test 'info sources [-d | -b] [--] [REGEX]'
18 standard_testfile .c info_sources_base.c
20 if {[prepare_for_testing $testfile.exp $testfile \
21 [list $srcfile $srcfile2] debug]} {
22 untested $testfile.exp
26 # Executes "info sources " $args.
27 # EXPECT_SEEN_INFO_SOURCES 1 indicates that the source file info_sources.c must be seen
28 # in the output. Similarly, EXPECT_SEEN_INFO_SOURCES_BASE indicates that the source file
29 # info_sources_base.c must be seen in the output.
30 proc test_info_sources {args expect_seen_info_sources expect_seen_info_sources_base} {
33 set seen_info_sources 0
34 set seen_info_sources_base 0
35 set cmd [concat "info sources " $args]
36 gdb_test_multiple $cmd $cmd {
37 -re "^\[^,\]*info_sources.c(, |\[\r\n\]+)" {
38 set seen_info_sources 1
41 -re "^\[^,\]*info_sources_base.c(, |\[\r\n\]+)" {
42 set seen_info_sources_base 1
49 if {$seen_info_sources == $expect_seen_info_sources \
50 && $seen_info_sources_base == $expect_seen_info_sources_base} {
60 untested $testfile.exp
63 gdb_test "break some_other_func" ""
67 # List both files with no regexp:
68 test_info_sources "" 1 1
69 # Same but with option terminator:
70 test_info_sources "--" 1 1
72 # List both files with regexp matching anywhere in the filenames:
73 test_info_sources "info_sources" 1 1
74 test_info_sources "gdb.base" 1 1
76 # List both files with regexp matching the filename basenames,
77 # using various parts of the -basename option:
78 test_info_sources "-b info_sources" 1 1
79 test_info_sources "-basename info_sources" 1 1
80 test_info_sources "-b -- info_sources" 1 1
81 test_info_sources "-ba info_sources" 1 1
82 test_info_sources "-base -- info_sources" 1 1
83 test_info_sources "-basena info_sources" 1 1
84 test_info_sources "-basename -- info_sources" 1 1
86 # List only the file with basename matching regexp:
87 test_info_sources "-b base" 0 1
89 # List the files with dirname matching regexp,
90 # using various part of the -dirname option:
91 test_info_sources "-d base" 1 1
92 test_info_sources "-dirname base" 1 1
94 # Test non matching regexp, with option terminator:
95 test_info_sources "-b -- -d" 0 0
96 test_info_sources "-d -- -d" 0 0