binutils-gdb/gdb/testsuite/gdb.base/list-ambiguous.exp
Andrew Burgess 1d506c26d9 Update copyright year range in header of all files managed by GDB
This commit is the result of the following actions:

  - Running gdb/copyright.py to update all of the copyright headers to
    include 2024,

  - Manually updating a few files the copyright.py script told me to
    update, these files had copyright headers embedded within the
    file,

  - Regenerating gdbsupport/Makefile.in to refresh it's copyright
    date,

  - Using grep to find other files that still mentioned 2023.  If
    these files were updated last year from 2022 to 2023 then I've
    updated them this year to 2024.

I'm sure I've probably missed some dates.  Feel free to fix them up as
you spot them.
2024-01-12 15:49:57 +00:00

84 lines
3.0 KiB
Plaintext

# Copyright 2017-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test the "list" command with linespecs that expand to multiple
# locations.
standard_testfile list-ambiguous0.c list-ambiguous1.c
# Set EDITOR to true to prevent that GDB's edit command starts an actual
# editor.
setenv EDITOR true
if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $srcfile2] \
{debug}]} {
return -1
}
# Build source listing pattern based on an inclusive line range.
proc line_range_pattern { range_start range_end } {
global line_re
for {set i $range_start} {$i <= $range_end} {incr i} {
append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
}
verbose -log "pattern $pattern"
return $pattern
}
# Test the "list" command with linespecs that expand to multiple
# locations.
proc test_list_ambiguous_symbol {symbol_line symbol} {
global srcfile srcfile2
set lineno0 [gdb_get_line_number $symbol_line $srcfile]
set lineno1 [gdb_get_line_number $symbol_line $srcfile2]
set lines0_re [line_range_pattern [expr $lineno0 - 5] [expr $lineno0 + 4]]
set lines1_re [line_range_pattern [expr $lineno1 - 5] [expr $lineno1 + 4]]
set any "\[^\r\n\]*"
set h0_re "file: \"${any}list-ambiguous0.c\", line number: $lineno0, symbol: \"$symbol\""
set h1_re "file: \"${any}list-ambiguous1.c\", line number: $lineno1, symbol: \"$symbol\""
gdb_test "list $symbol" "${h0_re}${lines0_re}\r\n${h1_re}${lines1_re}"
gdb_test "list main,$symbol" \
"Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
gdb_test "list ,$symbol" \
"Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
gdb_test "list $symbol,main" \
"Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
gdb_test "list $symbol,$symbol" \
"Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
gdb_test "list $symbol," \
"Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
# While at it, test the "edit" command as well, since it shares
# code with "list".
gdb_test "edit $symbol" \
"Specified line is ambiguous:\r\n${h0_re}\r\n${h1_re}"
}
proc test_list_ambiguous_function {} {
test_list_ambiguous_symbol "ambiguous_fun (void)" "ambiguous_fun"
test_list_ambiguous_symbol "ambiguous_var" "ambiguous_var"
}
gdb_test_no_output "set listsize 10"
test_list_ambiguous_function