old-cross-binutils/gdb/testsuite/gdb.linespec/linespec.exp
Tom Tromey 4aac40c837 gdb
* NEWS: Add item.
	* symtab.h (compare_filenames_for_search): Declare.
	* symtab.c (compare_filenames_for_search): New function.
	(iterate_over_some_symtabs): Use it.
	* symfile.h (struct quick_symbol_functions)
	<map_symtabs_matching_filename>: Change spec.
	* psymtab.c (partial_map_symtabs_matching_filename): Use
	compare_filenames_for_search.  Update for new spec.
	* dwarf2read.c (dw2_map_symtabs_matching_filename): Use
	compare_filenames_for_search.  Update for new spec.
	* breakpoint.c (clear_command): Use compare_filenames_for_search.
gdb/doc
	* gdb.texinfo (Specify Location): Document relative file name
	handling.
gdb/testsuite
	* gdb.linespec/linespec.exp: Change some tests to use $decimal.
	Add tests for relative directory.
2012-01-16 20:40:53 +00:00

122 lines
4.1 KiB
Text

# Copyright 2011-2012 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/>.
# Tests of ambiguous linespecs.
set testfile linespec
set exefile lspec
set binfile ${objdir}/${subdir}/${exefile}
set baseone base/one/thefile.cc
set basetwo base/two/thefile.cc
if {[skip_cplus_tests]} {
unsupported linespec.exp
return
}
if {[prepare_for_testing ${testfile}.exp $exefile \
[list lspec.cc $baseone $basetwo] \
{debug nowarnings c++}]} {
return -1
}
gdb_test_no_output "set multiple-symbols all" \
"set multiple-symbols to all for linespec tests"
set l1 [gdb_get_line_number "thefile breakpoint" $baseone]
set l2 [gdb_get_line_number "thefile breakpoint" $basetwo]
if {$l1 != $l2} {
error "somebody incompatibly modified the source files needed by linespec.exp"
}
gdb_test "break one/thefile.cc:$l1" \
"Breakpoint $decimal at $hex: file .*thefile.cc, line $l1." \
"single-location break using dir/file:line"
gdb_test "clear one/thefile.cc:$l1" \
"Deleted breakpoint $decimal *" \
"clear breakpoint using dir/file:line"
gdb_test "break thefile.cc:$l1" \
"Breakpoint $decimal at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \
"multi-location break using file:line"
gdb_test "break dupname" \
"Breakpoint $decimal at $hex: dupname. \[(\]2 locations\[)\]" \
"multi-location break using duplicate function name"
gdb_test "break dupname:label" \
"Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \
"multi-location break using duplicate function name and label"
gdb_test_no_output "set breakpoint pending off" \
"disable pending breakpoints for linespec tests"
# This is PR breakpoints/12856.
gdb_test "break lspec.cc:nosuchfunction" \
"Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
"set breakpoint on non-existent function"
gdb_test "break NameSpace::overload" \
"Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \
"set breakpoint at all instances of NameSpace::overload"
gdb_test "break lspec.cc:NameSpace::overload" \
"Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
"set breakpoint at lspec.cc instance of NameSpace::overload"
gdb_test "break lspec.cc:NameSpace::overload(double)" \
"Function \"NameSpace::overload\\(double\\)\" not defined in \"lspec.cc\"." \
"set breakpoint at non-existent lspec.cc instance of NameSpace::overload"
gdb_test "break NameSpace::overload()" \
"Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
"set breakpoint at specific instance of NameSpace::overload"
# This should manage to set a breakpoint even though body.h does not
# include all of the function in question.
set line [gdb_get_line_number "body breakpoint no code" body.h]
gdb_test "break body.h:$line" \
"Breakpoint \[0-9\]+.*" \
"set breakpoint in body.h"
# This should only have a single location -- in f1.
set line [gdb_get_line_number "f1 breakpoint" lspec.h]
gdb_test "break lspec.h:$line" \
"Breakpoint \[0-9\]+ at $hex: file .*lspec.h, line $line." \
"set breakpoint in f1"
#
# Multi-inferior tests.
#
gdb_test "add-inferior" "Added inferior 2" \
"add inferior for linespec tests"
gdb_test "inferior 2" "Switching to inferior 2 .*" \
"switch to inferior 2 for linespec tests"
# Note that in particular this should not cause errors when re-setting
# breakpoints.
gdb_test "file $binfile" \
"Reading symbols from .*done." \
"set the new inferior file for linespec tests"
gdb_test "break main" \
"Breakpoint \[0-9\]+ at $hex: main. .2 locations." \
"set breakpoint at main in both inferiors"