1# Copyright 2011-2016 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# Tests of ambiguous linespecs. 17 18standard_testfile lspec.cc 19 20set exefile $testfile 21 22set baseone base/one/thefile.cc 23set basetwo base/two/thefile.cc 24 25if {[skip_cplus_tests]} { 26 unsupported linespec.exp 27 return 28} 29 30if {[prepare_for_testing ${testfile}.exp $exefile \ 31 [list $srcfile $baseone $basetwo] \ 32 {debug nowarnings c++}]} { 33 return -1 34} 35 36gdb_test_no_output "set multiple-symbols all" \ 37 "set multiple-symbols to all for linespec tests" 38 39set l1 [gdb_get_line_number "thefile breakpoint" $baseone] 40set l2 [gdb_get_line_number "thefile breakpoint" $basetwo] 41 42if {$l1 != $l2} { 43 error "somebody incompatibly modified the source files needed by linespec.exp" 44} 45 46# Copying files to a remote host loses the directory prefix during 47# compilation. 48if { [is_remote host] } { 49 untested "breakpoints using dir/file:line" 50} else { 51 gdb_test "break one/thefile.cc:$l1" \ 52 "Breakpoint $decimal at $hex: file .*thefile.cc, line $l1." \ 53 "single-location break using dir/file:line" 54 55 gdb_test "clear one/thefile.cc:$l1" \ 56 "Deleted breakpoint $decimal *" \ 57 "clear breakpoint using dir/file:line" 58} 59 60gdb_test "break thefile.cc:$l1" \ 61 "Breakpoint $decimal at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \ 62 "multi-location break using file:line" 63 64gdb_test "break dupname" \ 65 "Breakpoint $decimal at $hex: dupname. \[(\]2 locations\[)\]" \ 66 "multi-location break using duplicate function name" 67 68gdb_test "break dupname:label" \ 69 "Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \ 70 "multi-location break using duplicate function name and label" 71 72# Testing if the "condition" command completes only the breakpoints, 73# not the locations. 74gdb_test "complete condition " "condition $decimal\r\ncondition $decimal\r\ncondition $decimal" 75 76gdb_test_no_output "set breakpoint pending off" \ 77 "disable pending breakpoints for linespec tests" 78 79# This is PR breakpoints/12856. 80gdb_test "break lspec.cc:nosuchfunction" \ 81 "Function \"nosuchfunction\" not defined in \"lspec.cc\"." \ 82 "set breakpoint on non-existent function" 83 84gdb_test "break NameSpace::overload" \ 85 "Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \ 86 "set breakpoint at all instances of NameSpace::overload" 87 88gdb_test "break lspec.cc:NameSpace::overload" \ 89 "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \ 90 "set breakpoint at lspec.cc instance of NameSpace::overload" 91 92gdb_test "break lspec.cc:NameSpace::overload(double)" \ 93 "Function \"NameSpace::overload\\(double\\)\" not defined in \"lspec.cc\"." \ 94 "set breakpoint at non-existent lspec.cc instance of NameSpace::overload" 95 96gdb_test "break NameSpace::overload()" \ 97 "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \ 98 "set breakpoint at specific instance of NameSpace::overload" 99 100# This should manage to set a breakpoint even though body.h does not 101# include all of the function in question. 102set line [gdb_get_line_number "body breakpoint no code" body.h] 103gdb_test "break body.h:$line" \ 104 "Breakpoint \[0-9\]+.*" \ 105 "set breakpoint in body.h" 106 107# This should only have a single location -- in f1. 108set line [gdb_get_line_number "f1 breakpoint" lspec.h] 109gdb_test "break lspec.h:$line" \ 110 "Breakpoint \[0-9\]+ at $hex: file .*lspec.h, line $line." \ 111 "set breakpoint in f1" 112 113# 114# Multi-inferior tests. 115# 116 117gdb_test "add-inferior" "Added inferior 2" \ 118 "add inferior for linespec tests" 119 120gdb_test "inferior 2" "Switching to inferior 2 .*" \ 121 "switch to inferior 2 for linespec tests" 122 123# Note that in particular this should not cause errors when re-setting 124# breakpoints. 125gdb_test "file $binfile" \ 126 "Reading symbols from .*done." \ 127 "set the new inferior file for linespec tests" 128 129gdb_test "break main" \ 130 "Breakpoint \[0-9\]+ at $hex: main. .2 locations." \ 131 "set breakpoint at main in both inferiors" 132