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