gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.linespec / linespec.exp
1 # Copyright 2011-2012 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 set testfile linespec
19
20 set exefile lspec
21 set binfile ${objdir}/${subdir}/${exefile}
22
23 set baseone base/one/thefile.cc
24 set basetwo base/two/thefile.cc
25
26 if {[skip_cplus_tests]} {
27 unsupported linespec.exp
28 return
29 }
30
31 if {[prepare_for_testing ${testfile}.exp $exefile \
32 [list lspec.cc $baseone $basetwo] \
33 {debug nowarnings c++}]} {
34 return -1
35 }
36
37 gdb_test_no_output "set multiple-symbols all" \
38 "set multiple-symbols to all for linespec tests"
39
40 set l1 [gdb_get_line_number "thefile breakpoint" $baseone]
41 set l2 [gdb_get_line_number "thefile breakpoint" $basetwo]
42
43 if {$l1 != $l2} {
44 error "somebody incompatibly modified the source files needed by linespec.exp"
45 }
46
47 gdb_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
51 gdb_test "clear one/thefile.cc:$l1" \
52 "Deleted breakpoint $decimal *" \
53 "clear breakpoint using dir/file:line"
54
55 gdb_test "break thefile.cc:$l1" \
56 "Breakpoint $decimal at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \
57 "multi-location break using file:line"
58
59 gdb_test "break dupname" \
60 "Breakpoint $decimal at $hex: dupname. \[(\]2 locations\[)\]" \
61 "multi-location break using duplicate function name"
62
63 gdb_test "break dupname:label" \
64 "Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \
65 "multi-location break using duplicate function name and label"
66
67 gdb_test_no_output "set breakpoint pending off" \
68 "disable pending breakpoints for linespec tests"
69
70 # This is PR breakpoints/12856.
71 gdb_test "break lspec.cc:nosuchfunction" \
72 "Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
73 "set breakpoint on non-existent function"
74
75 gdb_test "break NameSpace::overload" \
76 "Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \
77 "set breakpoint at all instances of NameSpace::overload"
78
79 gdb_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
83 gdb_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
87 gdb_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.
93 set line [gdb_get_line_number "body breakpoint no code" body.h]
94 gdb_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.
99 set line [gdb_get_line_number "f1 breakpoint" lspec.h]
100 gdb_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
108 gdb_test "add-inferior" "Added inferior 2" \
109 "add inferior for linespec tests"
110
111 gdb_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.
116 gdb_test "file $binfile" \
117 "Reading symbols from .*done." \
118 "set the new inferior file for linespec tests"
119
120 gdb_test "break main" \
121 "Breakpoint \[0-9\]+ at $hex: main. .2 locations." \
122 "set breakpoint at main in both inferiors"
This page took 0.035094 seconds and 5 git commands to generate.