the "ambiguous linespec" series
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
7b6bb8da 1# Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
ed0616c6
VP
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# This test verifies that setting breakpoint on line in template
17# function will fire in all instantiations of that template.
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
759f0f0b 23if { [skip_stl_tests] } { continue }
c3ea9a14 24
62172bb9
UW
25# On SPU this test fails because the executable exceeds local storage size.
26if { [istarget "spu*-*-*"] } {
27 return 0
28}
29
ed0616c6
VP
30
31set testfile "mb-templates"
32set srcfile ${testfile}.cc
33set binfile ${objdir}/${subdir}/${testfile}
34
35if [get_compiler_info ${binfile} "c++"] {
36 return -1
37}
38
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
40 untested mb-templates.exp
41 return -1
42}
43
44gdb_exit
45gdb_start
46gdb_reinitialize_dir $srcdir/$subdir
47gdb_load ${binfile}
48
49set bp_location [gdb_get_line_number "set breakpoint here"]
50
51# Set a breakpoint with multiple locations
52# and a condition.
53
54gdb_test "break $srcfile:$bp_location if i==1" \
f8eba3c6 55 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
ed0616c6
VP
56 "initial condition: set breakpoint"
57
58gdb_run_cmd
59gdb_expect {
60 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
61 pass "initial condition: run to breakpoint"
62 }
63 -re "$gdb_prompt $" {
64 fail "initial condition: run to breakpoint"
65 }
66 timeout {
67 fail "initial condition: run to breakpoint (timeout)"
68 }
69}
70
71gdb_test "continue" \
72 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
73 "initial condition: run to breakpoint 2"
74
75# Set breakpoint with multiple locations.
76# Separately set the condition.
77gdb_exit
78gdb_start
79gdb_reinitialize_dir $srcdir/$subdir
80gdb_load ${binfile}
81
82gdb_test "break $srcfile:$bp_location" \
f8eba3c6 83 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
ed0616c6
VP
84 "separate condition: set breakpoint"
85
a8d52276 86gdb_test_no_output "condition 1 i==1" \
ed0616c6
VP
87 "separate condition: set condition"
88
89gdb_run_cmd
90gdb_expect {
91 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
92 pass "separate condition: run to breakpoint"
93 }
94 -re "$gdb_prompt $" {
95 fail "separate condition: run to breakpoint"
96 }
97 timeout {
98 fail "separate condition: run to breakpoint (timeout)"
99 }
100}
101
102gdb_test "continue" \
103 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
104 "separate condition: run to breakpoint 2"
105
106# Try disabling a single location. We also test
107# that at least in simple cases, the enable/disable
108# state of locations surive "run".
a8d52276 109gdb_test_no_output "disable 1.1" "disabling location: disable"
ed0616c6
VP
110
111gdb_run_cmd
112gdb_expect {
113 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
114 pass "disabling location: run to breakpoint"
115 }
116 -re "$gdb_prompt $" {
117 fail "disabling location: run to breakpoint"
118 }
119 timeout {
120 fail "disabling location: run to breakpoint (timeout)"
121 }
122}
123
124# Try disabling entire breakpoint
a8d52276 125gdb_test_no_output "enable 1.1" "disabling location: enable"
ed0616c6
VP
126
127
a8d52276 128gdb_test_no_output "disable 1" "disable breakpoint: disable"
ed0616c6
VP
129
130gdb_run_cmd
131gdb_expect {
fda326dd 132 -re "$inferior_exited_re normally.*$gdb_prompt $" {
ed0616c6
VP
133 pass "disable breakpoint: run to breakpoint"
134 }
135 -re "$gdb_prompt $" {
136 fail "disable breakpoint: run to breakpoint"
137 }
138 timeout {
139 fail "disable breakpoint: run to breakpoint (timeout)"
140 }
141}
142
143# Make sure breakpoint can be set on a specific instantion.
144delete_breakpoints
145gdb_test "break 'void foo<int>(int)'" ".*" \
146 "instantiation: set breakpoint"
147
148
149gdb_run_cmd
150gdb_expect {
151 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
152 pass "instantiation: run to breakpoint"
153 }
154 -re "$gdb_prompt $" {
155 fail "instantiation: run to breakpoint"
156 }
157 timeout {
158 fail "instantiation: run to breakpoint (timeout)"
159 }
160}
161
162gdb_test "continue" \
163 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
164 "instantiation: run to breakpoint 2"
165
9ab4e744
DE
166
167# Make sure we can set a breakpoint on a source statement that spans
168# multiple lines.
169
170delete_breakpoints
171
172set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
173
174if { ![runto_main] } {
175 fail "Can't run to main for multi_line_foo tests."
176 return 0
177}
178
179gdb_test "break $srcfile:$bp_location" \
f8eba3c6 180 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
9ab4e744
DE
181 "set multi_line_foo breakpoint"
182gdb_test "continue" \
183 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
184 "run to multi_line_foo breakpoint 2 <int>"
185gdb_test "continue" \
186 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
187 "run to multi_line_foo breakpoint 2 <double>"
This page took 0.489294 seconds and 4 git commands to generate.