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