Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
1 # Copyright 2007-2022 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 # This test verifies that setting breakpoint on line in template
17 # function will fire in all instantiations of that template.
18
19 if { [skip_stl_tests] } { continue }
20
21
22 standard_testfile .cc
23
24 if [get_compiler_info "c++"] {
25 return -1
26 }
27
28 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
29 return -1
30 }
31
32 set bp_location [gdb_get_line_number "set breakpoint here"]
33
34 # Set a breakpoint with multiple locations
35 # and a condition.
36
37 gdb_test "break $srcfile:$bp_location if i==1" \
38 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
39 "initial condition: set breakpoint"
40
41 gdb_run_cmd
42
43 set test "initial condition: run to breakpoint"
44 gdb_test_multiple "" $test {
45 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
46 pass $test
47 break
48 }
49 }
50
51 gdb_test "continue" \
52 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
53 "initial condition: run to breakpoint 2"
54
55 # Set breakpoint with multiple locations.
56 # Separately set the condition.
57
58 delete_breakpoints
59 gdb_test "kill" "" "kill" \
60 {Kill the program being debugged\? \(y or n\) } "y"
61
62 gdb_test "break $srcfile:$bp_location" \
63 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
64 "separate condition: set breakpoint"
65
66 gdb_test_no_output {condition $bpnum i==1} \
67 "separate condition: set condition"
68
69 gdb_run_cmd
70 gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint"
71
72 gdb_test "continue" \
73 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
74 "separate condition: run to breakpoint 2"
75
76 # Try disabling a single location. We also test
77 # that at least in simple cases, the enable/disable
78 # state of locations surive "run".
79 gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
80
81 gdb_run_cmd
82 gdb_test "" "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint"
83
84 # Try disabling entire breakpoint
85 gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
86
87
88 gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
89
90 gdb_run_cmd
91 gdb_test "" "$inferior_exited_re normally.*" "disable breakpoint: run to breakpoint"
92
93 # Make sure breakpoint can be set on a specific instantion.
94 delete_breakpoints
95 gdb_test "break 'void foo<int>(int)'" ".*" \
96 "instantiation: set breakpoint"
97
98
99 gdb_run_cmd
100 gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*" "instantiation: run to breakpoint"
101
102 gdb_test "continue" \
103 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
104 "instantiation: run to breakpoint 2"
105
106
107 # Make sure we can set a breakpoint on a source statement that spans
108 # multiple lines.
109
110 delete_breakpoints
111
112 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
113
114 if { ![runto_main] } {
115 fail "can't run to main for multi_line_foo tests."
116 return 0
117 }
118
119 gdb_test "break $srcfile:$bp_location" \
120 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
121 "set multi_line_foo breakpoint"
122 gdb_test "continue" \
123 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
124 "run to multi_line_foo breakpoint 2 <int>"
125 gdb_test "continue" \
126 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
127 "run to multi_line_foo breakpoint 2 <double>"
This page took 0.032304 seconds and 4 git commands to generate.