* gdb.cp/templates.cc (GetMax): New template.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
0fb0cc75 1# Copyright 2007, 2008, 2009 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
c3ea9a14
DE
23if { [skip_cplus_tests] } { continue }
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
30set prms_id 0
31set bug_id 0
32
33set testfile "mb-templates"
34set srcfile ${testfile}.cc
35set binfile ${objdir}/${subdir}/${testfile}
36
37if [get_compiler_info ${binfile} "c++"] {
38 return -1
39}
40
41if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
42 untested mb-templates.exp
43 return -1
44}
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49gdb_load ${binfile}
50
51set bp_location [gdb_get_line_number "set breakpoint here"]
52
53# Set a breakpoint with multiple locations
54# and a condition.
55
56gdb_test "break $srcfile:$bp_location if i==1" \
57 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
58 "initial condition: set breakpoint"
59
60gdb_run_cmd
61gdb_expect {
62 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
63 pass "initial condition: run to breakpoint"
64 }
65 -re "$gdb_prompt $" {
66 fail "initial condition: run to breakpoint"
67 }
68 timeout {
69 fail "initial condition: run to breakpoint (timeout)"
70 }
71}
72
73gdb_test "continue" \
74 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
75 "initial condition: run to breakpoint 2"
76
77# Set breakpoint with multiple locations.
78# Separately set the condition.
79gdb_exit
80gdb_start
81gdb_reinitialize_dir $srcdir/$subdir
82gdb_load ${binfile}
83
84gdb_test "break $srcfile:$bp_location" \
85 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
86 "separate condition: set breakpoint"
87
88gdb_test "condition 1 i==1" "" \
89 "separate condition: set condition"
90
91gdb_run_cmd
92gdb_expect {
93 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
94 pass "separate condition: run to breakpoint"
95 }
96 -re "$gdb_prompt $" {
97 fail "separate condition: run to breakpoint"
98 }
99 timeout {
100 fail "separate condition: run to breakpoint (timeout)"
101 }
102}
103
104gdb_test "continue" \
105 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
106 "separate condition: run to breakpoint 2"
107
108# Try disabling a single location. We also test
109# that at least in simple cases, the enable/disable
110# state of locations surive "run".
111gdb_test "disable 1.1" "" "disabling location: disable"
112
113gdb_run_cmd
114gdb_expect {
115 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
116 pass "disabling location: run to breakpoint"
117 }
118 -re "$gdb_prompt $" {
119 fail "disabling location: run to breakpoint"
120 }
121 timeout {
122 fail "disabling location: run to breakpoint (timeout)"
123 }
124}
125
126# Try disabling entire breakpoint
127gdb_test "enable 1.1" "" "disabling location: enable"
128
129
130gdb_test "disable 1" "" "disable breakpoint: disable"
131
132gdb_run_cmd
133gdb_expect {
134 -re "Program exited normally.*$gdb_prompt $" {
135 pass "disable breakpoint: run to breakpoint"
136 }
137 -re "$gdb_prompt $" {
138 fail "disable breakpoint: run to breakpoint"
139 }
140 timeout {
141 fail "disable breakpoint: run to breakpoint (timeout)"
142 }
143}
144
145# Make sure breakpoint can be set on a specific instantion.
146delete_breakpoints
147gdb_test "break 'void foo<int>(int)'" ".*" \
148 "instantiation: set breakpoint"
149
150
151gdb_run_cmd
152gdb_expect {
153 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
154 pass "instantiation: run to breakpoint"
155 }
156 -re "$gdb_prompt $" {
157 fail "instantiation: run to breakpoint"
158 }
159 timeout {
160 fail "instantiation: run to breakpoint (timeout)"
161 }
162}
163
164gdb_test "continue" \
165 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
166 "instantiation: run to breakpoint 2"
167
This page took 0.175723 seconds and 4 git commands to generate.