]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/list-ambiguous.exp
Make "list ambiguous" show symbol names too
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / list-ambiguous.exp
CommitLineData
e439fa14
PA
1# Copyright 2017 Free Software Foundation, Inc.
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
16# Test the "list" command with linespecs that expand to multiple
17# locations.
18
19standard_testfile list-ambiguous0.c list-ambiguous1.c
20
21if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $srcfile2] \
22 {debug}]} {
23 return -1
24}
25
26# Build source listing pattern based on an inclusive line range.
27
28proc line_range_pattern { range_start range_end } {
29 global line_re
30
31 for {set i $range_start} {$i <= $range_end} {incr i} {
32 append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
33 }
34
35 verbose -log "pattern $pattern"
36 return $pattern
37}
38
39# Test the "list" command with linespecs that expand to multiple
40# locations.
41
e5f25bc5 42proc test_list_ambiguous_symbol {symbol_line symbol} {
e439fa14
PA
43 global srcfile srcfile2
44
e5f25bc5
PA
45 set lineno0 [gdb_get_line_number $symbol_line $srcfile]
46 set lineno1 [gdb_get_line_number $symbol_line $srcfile2]
e439fa14
PA
47 set lines0_re [line_range_pattern [expr $lineno0 - 5] [expr $lineno0 + 4]]
48 set lines1_re [line_range_pattern [expr $lineno1 - 5] [expr $lineno1 + 4]]
49
50 set any "\[^\r\n\]*"
06871ae8
PA
51 set h0_re "file: \"${any}list-ambiguous0.c\", line number: $lineno0, symbol: \"$symbol\""
52 set h1_re "file: \"${any}list-ambiguous1.c\", line number: $lineno1, symbol: \"$symbol\""
e5f25bc5
PA
53 gdb_test "list $symbol" "${h0_re}${lines0_re}\r\n${h1_re}${lines1_re}"
54
55 gdb_test "list main,$symbol" \
56 "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
57 gdb_test "list ,$symbol" \
58 "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
59 gdb_test "list $symbol,main" \
60 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
61 gdb_test "list $symbol,$symbol" \
62 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
63 gdb_test "list $symbol," \
64 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
e439fa14
PA
65
66 # While at it, test the "edit" command as well, since it shares
67 # code with "list".
e5f25bc5 68 gdb_test "edit $symbol" \
e439fa14
PA
69 "Specified line is ambiguous:\r\n${h0_re}\r\n${h1_re}"
70}
71
e5f25bc5
PA
72proc test_list_ambiguous_function {} {
73 test_list_ambiguous_symbol "ambiguous_fun (void)" "ambiguous_fun"
74 test_list_ambiguous_symbol "ambiguous_var" "ambiguous_var"
75}
76
e439fa14
PA
77gdb_test_no_output "set listsize 10"
78
79test_list_ambiguous_function