gdb/python: don't allow the user to delete window title attributes
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / list-ambiguous.exp
CommitLineData
3666a048 1# Copyright 2017-2021 Free Software Foundation, Inc.
e439fa14
PA
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
b76f3a42
TV
21# Set EDITOR to true to prevent that GDB's edit command starts an actual
22# editor.
23setenv EDITOR true
24
e439fa14
PA
25if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $srcfile2] \
26 {debug}]} {
27 return -1
28}
29
30# Build source listing pattern based on an inclusive line range.
31
32proc line_range_pattern { range_start range_end } {
33 global line_re
34
35 for {set i $range_start} {$i <= $range_end} {incr i} {
36 append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
37 }
38
39 verbose -log "pattern $pattern"
40 return $pattern
41}
42
43# Test the "list" command with linespecs that expand to multiple
44# locations.
45
e5f25bc5 46proc test_list_ambiguous_symbol {symbol_line symbol} {
e439fa14
PA
47 global srcfile srcfile2
48
e5f25bc5
PA
49 set lineno0 [gdb_get_line_number $symbol_line $srcfile]
50 set lineno1 [gdb_get_line_number $symbol_line $srcfile2]
e439fa14
PA
51 set lines0_re [line_range_pattern [expr $lineno0 - 5] [expr $lineno0 + 4]]
52 set lines1_re [line_range_pattern [expr $lineno1 - 5] [expr $lineno1 + 4]]
53
54 set any "\[^\r\n\]*"
06871ae8
PA
55 set h0_re "file: \"${any}list-ambiguous0.c\", line number: $lineno0, symbol: \"$symbol\""
56 set h1_re "file: \"${any}list-ambiguous1.c\", line number: $lineno1, symbol: \"$symbol\""
e5f25bc5
PA
57 gdb_test "list $symbol" "${h0_re}${lines0_re}\r\n${h1_re}${lines1_re}"
58
59 gdb_test "list main,$symbol" \
60 "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
61 gdb_test "list ,$symbol" \
62 "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
63 gdb_test "list $symbol,main" \
64 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
65 gdb_test "list $symbol,$symbol" \
66 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
67 gdb_test "list $symbol," \
68 "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
e439fa14
PA
69
70 # While at it, test the "edit" command as well, since it shares
71 # code with "list".
e5f25bc5 72 gdb_test "edit $symbol" \
e439fa14
PA
73 "Specified line is ambiguous:\r\n${h0_re}\r\n${h1_re}"
74}
75
e5f25bc5
PA
76proc test_list_ambiguous_function {} {
77 test_list_ambiguous_symbol "ambiguous_fun (void)" "ambiguous_fun"
78 test_list_ambiguous_symbol "ambiguous_var" "ambiguous_var"
79}
80
e439fa14
PA
81gdb_test_no_output "set listsize 10"
82
83test_list_ambiguous_function
This page took 0.48925 seconds and 4 git commands to generate.