Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 2008-2012 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 | ||
776592bf DE |
23 | |
24 | set testfile "mb-inline" | |
25 | set hdrfile "${testfile}.h" | |
26 | set srcfile1 "${testfile}1.cc" | |
27 | set objfile1 "${testfile}1.o" | |
28 | set srcfile2 "${testfile}2.cc" | |
29 | set objfile2 "${testfile}2.o" | |
30 | set binfile "${objdir}/${subdir}/${testfile}" | |
31 | ||
32 | if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { | |
33 | untested mb-inline.exp | |
34 | return -1 | |
35 | } | |
36 | ||
37 | if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { | |
38 | untested mb-inline.exp | |
39 | return -1 | |
40 | } | |
41 | ||
42 | if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } { | |
43 | untested mb-inline.exp | |
44 | return -1 | |
45 | } | |
46 | ||
4c93b1db | 47 | if [get_compiler_info "c++"] { |
776592bf DE |
48 | return -1 |
49 | } | |
50 | ||
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load ${binfile} | |
55 | ||
56 | set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile] | |
57 | ||
58 | # Set a breakpoint with multiple locations. | |
59 | ||
60 | gdb_test "break $hdrfile:$bp_location" \ | |
f8eba3c6 | 61 | "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ |
776592bf DE |
62 | "set breakpoint" |
63 | ||
64 | gdb_run_cmd | |
65 | gdb_expect { | |
66 | -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { | |
67 | pass "run to breakpoint" | |
68 | } | |
69 | -re "$gdb_prompt $" { | |
70 | fail "run to breakpoint" | |
71 | } | |
72 | timeout { | |
73 | fail "run to breakpoint (timeout)" | |
74 | } | |
75 | } | |
76 | ||
77 | gdb_test "continue" \ | |
78 | ".*Breakpoint.*foo \\(i=1\\).*" \ | |
79 | "run to breakpoint 2" | |
80 | ||
81 | # Try disabling a single location. We also test | |
82 | # that at least in simple cases, the enable/disable | |
83 | # state of locations survive "run". | |
84 | # Early bug would disable 1.1 and enable 1.2 when program is run. | |
a8d52276 | 85 | gdb_test_no_output "disable 1.2" "disabling location: disable" |
776592bf DE |
86 | |
87 | gdb_run_cmd | |
88 | gdb_expect { | |
89 | -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { | |
90 | pass "disabling location: run to breakpoint" | |
91 | } | |
92 | -re "$gdb_prompt $" { | |
93 | fail "disabling location: run to breakpoint" | |
94 | } | |
95 | timeout { | |
96 | fail "disabling location: run to breakpoint (timeout)" | |
97 | } | |
98 | } | |
99 | ||
ab5c6a72 YQ |
100 | gdb_test_multiple "info break" "disabled breakpoint 1.2" { |
101 | -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" { | |
102 | pass "disabled breakpoint 1.2" | |
103 | } | |
104 | -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" { | |
105 | # When inferior is restarted, breakpoint locations will be updated. | |
106 | # On uclinux, it is not guaranteed that new inferior is located the | |
107 | # same address as previous one, so status/state of breakpoint location | |
108 | # will loose. The heuristic of GDB should be improved. | |
109 | setup_kfail gdb/12924 "*-*-uclinux*" | |
110 | fail "disabled breakpoint 1.2" | |
111 | } | |
112 | } | |
9ab4e744 DE |
113 | |
114 | # Make sure we can set a breakpoint on a source statement that spans | |
115 | # multiple lines. | |
116 | ||
117 | delete_breakpoints | |
118 | ||
119 | set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile] | |
120 | ||
121 | if { ![runto_main] } { | |
122 | fail "Can't run to main for multi_line_foo tests." | |
123 | return 0 | |
124 | } | |
125 | ||
126 | gdb_test "break $hdrfile:$bp_location" \ | |
f8eba3c6 | 127 | "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \ |
9ab4e744 DE |
128 | "set multi_line_foo breakpoint" |
129 | gdb_test "continue" \ | |
130 | ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ | |
131 | "run to multi_line_foo breakpoint 4 afn" | |
132 | gdb_test "continue" \ | |
133 | ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \ | |
134 | "run to multi_line_foo breakpoint 4 bfn" |