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