Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 2008-2018 Free Software Foundation, Inc. |
776592bf DE |
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 file is part of the gdb testsuite. | |
17 | ||
18 | # This test verifies that setting breakpoint on line in inline | |
19 | # function will fire in all instantiations of that function. | |
20 | ||
776592bf DE |
21 | if { [skip_cplus_tests] } { continue } |
22 | ||
f5f3a911 | 23 | standard_testfile mb-inline1.cc mb-inline2.cc |
776592bf | 24 | set hdrfile "${testfile}.h" |
776592bf | 25 | |
4c93b1db | 26 | if [get_compiler_info "c++"] { |
776592bf DE |
27 | return -1 |
28 | } | |
29 | ||
5b362f04 | 30 | if {[prepare_for_testing "failed to prepare" $testfile \ |
f5f3a911 TT |
31 | [list $srcfile $srcfile2] {debug c++}]} { |
32 | return -1 | |
33 | } | |
776592bf DE |
34 | |
35 | set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile] | |
36 | ||
37 | # Set a breakpoint with multiple locations. | |
38 | ||
39 | gdb_test "break $hdrfile:$bp_location" \ | |
f8eba3c6 | 40 | "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ |
776592bf DE |
41 | "set breakpoint" |
42 | ||
3a0ed5d7 DE |
43 | # Do "info break" now so we can easily compare it with the later "info break" |
44 | # if problems arise. | |
45 | gdb_test "info break" \ | |
46 | "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*" | |
47 | ||
776592bf | 48 | gdb_run_cmd |
fa43b1d7 | 49 | gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "run to breakpoint" |
776592bf DE |
50 | |
51 | gdb_test "continue" \ | |
52 | ".*Breakpoint.*foo \\(i=1\\).*" \ | |
53 | "run to breakpoint 2" | |
54 | ||
55 | # Try disabling a single location. We also test | |
56 | # that at least in simple cases, the enable/disable | |
57 | # state of locations survive "run". | |
58 | # Early bug would disable 1.1 and enable 1.2 when program is run. | |
a8d52276 | 59 | gdb_test_no_output "disable 1.2" "disabling location: disable" |
776592bf DE |
60 | |
61 | gdb_run_cmd | |
fa43b1d7 | 62 | gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "disabling location: run to breakpoint" |
776592bf | 63 | |
ab5c6a72 YQ |
64 | gdb_test_multiple "info break" "disabled breakpoint 1.2" { |
65 | -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" { | |
66 | pass "disabled breakpoint 1.2" | |
67 | } | |
68 | -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" { | |
69 | # When inferior is restarted, breakpoint locations will be updated. | |
70 | # On uclinux, it is not guaranteed that new inferior is located the | |
71 | # same address as previous one, so status/state of breakpoint location | |
72 | # will loose. The heuristic of GDB should be improved. | |
73 | setup_kfail gdb/12924 "*-*-uclinux*" | |
74 | fail "disabled breakpoint 1.2" | |
75 | } | |
76 | } | |
9ab4e744 DE |
77 | |
78 | # Make sure we can set a breakpoint on a source statement that spans | |
79 | # multiple lines. | |
80 | ||
81 | delete_breakpoints | |
82 | ||
83 | set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile] | |
84 | ||
85 | if { ![runto_main] } { | |
bc6c7af4 | 86 | fail "can't run to main for multi_line_foo tests." |
9ab4e744 DE |
87 | return 0 |
88 | } | |
89 | ||
90 | gdb_test "break $hdrfile:$bp_location" \ | |
f8eba3c6 | 91 | "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ |
9ab4e744 DE |
92 | "set multi_line_foo breakpoint" |
93 | gdb_test "continue" \ | |
94 | ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ | |
95 | "run to multi_line_foo breakpoint 4 afn" | |
96 | gdb_test "continue" \ | |
97 | ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \ | |
98 | "run to multi_line_foo breakpoint 4 bfn" |